![绑定 wifi 和以太网接口 - 错误的本地 IP](https://linux22.com/image/1635654/%E7%BB%91%E5%AE%9A%20wifi%20%E5%92%8C%E4%BB%A5%E5%A4%AA%E7%BD%91%E6%8E%A5%E5%8F%A3%20-%20%E9%94%99%E8%AF%AF%E7%9A%84%E6%9C%AC%E5%9C%B0%20IP.png)
我正在尝试在我的 raspberry pi (Raspbian Linux 10) 上绑定两个互联网连接。绑定模式应为容错。主连接应为 wifi 连接 (wlan0),第二个连接应为 LTE Surfstick (eth1)。这里的问题是,当我关闭 wlan0 时,绑定接口会切换到 eth1,但会尝试通过 WLAN 的本地 IP 访问互联网。wifi 网络中的本地地址是 192.168.178.81,而 LTE-Surfstick 提供的地址是 192.168.8.100,因此当我禁用 wlan0 时,绑定会尝试通过 192.168.178.81 访问互联网。如果我将 eht1 更改为主连接,也会发生这种情况。我尝试的方法是安装 ifenslave 并编辑 /etc/network/interfaces 文档,如下所示:
auto bond0
iface bond0 inet dhcp
bond-slaves wlan0 eth1
bond-mode active-backup
bond-primary wlan0
bond-miimon 100
bond-fail_over_mac 1
allow-bond0 wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
wpa-bridge bond0
bond-give-a-chance 10
allow-bond0 eth1
allow-hotplug eth1
iface eth1 inet manual
pre-up sleep 15
当我像这样设置时,查看 /proc/net/bonding/bond0 显示:
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup) (fail_over_mac active)
Primary Slave: wlan0 (primary_reselect always)
Currently Active Slave: wlan0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Peer Notification Delay (ms): 0
Slave Interface: wlan0
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 8f:4f:87:cb:88:50
Slave queue ID: 0
Slave Interface: eth1
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 67:1b:4d:6e:c3:8c
Slave queue ID: 0
ping google 没问题。关闭 wlan0 并 ping google 172.217.21.195 后,返回:来自 192.168.178.81 目标主机无法访问。我也尝试使用 bond0 静态 IP 进行同样的操作,但也失败了。我知道我可能会混淆一些概念,也错过了一些非常琐碎的东西,但我对 Linux 和绑定还很陌生,所以很抱歉。谢谢!