Alpine Linux 上的桥接网络

Alpine Linux 上的桥接网络

我正在尝试在 ExpressoBin 上设置三个接口,同时运行 Alpine 作为我的操作系统。我希望桥接端口 lan0 和 lan1,并让桥接端口尝试通过 DHCP 收集 IP,然后我希望第三个剩余端口也通过 DHCP 收集 IP。我似乎遇到了一些麻烦,我想我有时可能会与网络服务作斗争。下面是我尝试运行的一组网络设置,到目前为止尚未成功。什么应该有效:(应该很简单吧?)


auto lan0
iface lan0 inet manual

auto lan1
iface lan1 inet manual

auto wan
iface wan inet dhcp

auto br0
iface br0 inet dhcp
        bridge_ports lan1 lan0
Errors:
* Starting networking ... *   lan0 ... [ ok ]
 *   lan1 ... [ ok ]
 *   wan ...ip: ioctl 0x8914 failed: Network is down
 [ !! ]
 *   br0 ...ip: ioctl 0x8914 failed: Network is down
ip: ioctl 0x8914 failed: Network is down
sending commands to master dhcpcd process

不知道为什么 br0 “网络已关闭”,当它不是真正的物理接口时,如果正在构建它并为其分配了接口,我希望它能够启动?奇怪的是我在 lan1 上获得了 ip,但无法访问网络: ip a:

1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: bond0: <NO-CARRIER,BROADCAST,MULTICAST,UP400> mtu 1500 qdisc noqueue state DOWN qlen 1000
    link/ether ee:5d:d4:7a:8e:d1 brd ff:ff:ff:ff:ff:ff
3: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN qlen 1
    link/sit 0.0.0.0 brd 0.0.0.0
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 532
    link/ether f0:ad:4e:06:e0:18 brd ff:ff:ff:ff:ff:ff
    inet 169.254.75.204/16 brd 169.254.255.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::2d7e:4f3:18e4:6779/64 scope link 
       valid_lft forever preferred_lft forever
5: wan@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN qlen 1000
    link/ether f0:ad:4e:06:e0:18 brd ff:ff:ff:ff:ff:ff
6: lan0@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master br0 state LOWERLAYERDOWN qlen 1000
    link/ether f0:ad:4e:06:e0:18 brd ff:ff:ff:ff:ff:ff
7: lan1@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UP qlen 1000
    link/ether f0:ad:4e:06:e0:18 brd ff:ff:ff:ff:ff:ff
    inet 10.0.40.7/28 brd 10.0.40.15 scope global dynamic lan1
       valid_lft 85768sec preferred_lft 74968sec
    inet6 fe80::2d7e:4f3:18e4:6779/64 scope link 
       valid_lft forever preferred_lft forever
8: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    link/ether f0:ad:4e:06:e0:18 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::f2ad:4eff:fe06:e018/64 scope link 
       valid_lft forever preferred_lft forever

IP路由列表:

default via 10.0.40.1 dev lan1  src 10.0.40.7  metric 207 
10.0.40.0/28 dev lan1 scope link  src 10.0.40.7  metric 207 
169.254.0.0/16 dev eth0 scope link  src 169.254.75.204  metric 204 

但 ping 不起作用,即使我有一个 Ip 和一条对我来说看起来正确的路由。

使用较旧的接口格式:鉴于我的 ALpine 构建版本高于此链接中所述的版本,因此不需要这样做这里,

auto wan                      
iface wan inet dhcp           
                                
auto br0                                                             
iface br0 inet static                                               
        pre-up brctl addbr br0                                       
        pre-up echo 0 > /proc/sys/net/bridge/bridge-nf-call-arptables
        pre-up echo 0 > /proc/sys/net/bridge/bridge-nf-call-iptables
        post-down brctl delbr br0          
                                           
auto lan0                                  
iface lan0 inet manual                     
        up ip link set lan0 up             
        up brctl addif br0 lan0            
        down brctl delif br0 lan0 || true  
        down ip link set lan0 down         
                                           
auto lan1                                  
iface lan1 inet manual                     
        up ip link set lan1 up             
        up brctl addif br0 lan1                                      
        down brctl delif br0 lan1 || true                                                        
        down ip link set lan1 down 

错误:

 * Starting networking ... *   wan ...ip: ioctl 0x8914 failed: Network is down
 [ !! ]
 *   br0 ...ifup: don't have all variables for br0/inet
 [ !! ]
 *   lan0 ...ip: ioctl 0x8914 failed: Network is down
 [ !! ]
 *   lan1 ...ip: ioctl 0x8914 failed: Network is down
*snip*
 * Starting networking ... *   wan ...sending commands to master dhcpcd process
 [ ok ]
 *   br0 ...ifup: don't have all variables for br0/inet
 [ !! ]
 *   lan0 ...brctl: bridge br0: No such device
 [ !! ]
 *   lan1 ...brctl: bridge br0: No such device
 [ !! ]

最终结果:我在 lan1 上获得 IP 地址,而不是 br0。

7: lan1@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    link/ether f0:ad:4e:06:e0:18 brd ff:ff:ff:ff:ff:ff
    inet 10.0.40.7/28 brd 10.0.40.15 scope global dynamic lan1
       valid_lft 85737sec preferred_lft 74937sec

谁能告诉我我在这里搞砸了什么?我什至尝试切换到网络管理器服务并通过 nmtui 配置它,但我没有得到任何进一步的结果。 lan1 再次通过 DHCP 获得了 IP,但未能真正按照我的预期正确设置网络。

相关内容