处理一个奇怪的问题,即 netplan 未检测到其中一个主从设备的上行链路中断,并且未选择另一个从设备。我还尝试设置 mii-monitor-interval 的所有参数,但似乎也不起作用。
root@core2:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
root@core2:~# uname -a
Linux core2 4.15.0-121-generic #123-Ubuntu SMP Mon Oct 5 16:16:40 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
root@core2:~# dpkg -l | grep netplan
ii netplan.io0.98-0ubuntu1~18.04.1 amd64 YAML network configuration abstraction for various backends
root@core2:~#
Config file ->
network:
version: 2
renderer: networkd
ethernets:
enp6s0f0:
dhcp4: no
enp6s0f1:
dhcp4: no
bonds:
bond0:
addresses:
- 10.10.10.250/24
gateway4: 10.10.10.1
nameservers:
addresses: [8.8.8.8]
interfaces:
- enp6s0f0
- enp6s0f1
parameters:
mode: active-backup
primary: enp6s0f0
mii-monitor-interval: 10s
min-links: 1
down-delay: 50
有趣的问题是,将 mii-monitor-interval 值设置为 10 秒后,该事件不会在绑定接口上更新。它显示 0ms,这意味着 netplan 未监控 mii 上行链路。
root@core2:~# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: enp6s0f0 (primary_reselect always)
Currently Active Slave: enp6s0f0
MII Status: up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: enp6s0f1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:1b:21:3e:3f:29
Slave queue ID: 0
Slave Interface: enp6s0f0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:1b:21:3e:3f:28
Slave queue ID: 0
root@core2:~#
答案1
这个问题提出很久之后,我又遇到了类似的问题。
更改 netplan 配置中的值并执行 netplan apply 不会改变现有的 mii-monitor-interval,而是将其保留为 0(因此关闭)
重启即可使其生效。删除 bond 设备 (ip link delete interfacename) 和应用 netplan 也同样有效。
Netplan 不适合以这种方式进行更改。如果债券存在,它不会改变它。
答案2
编辑3
我在 ubuntu 20.04 中遇到了同样的问题。
我可以更改绑定的主设备,但如果我断开网卡的电缆,就不会发生故障转移路由。
MIIMonitorSec 在 /run/systemd/network 中正确设置
啊,完全重启并小心地重新启动 ping 探测后它就开始工作了。
这是我的配置:
network:
version: 2
renderer: networkd
ethernets:
eno1:
addresses: []
dhcp4: false
dhcp6: false
eno2:
addresses: []
dhcp4: false
dhcp6: false
bonds:
bond0:
dhcp4: no
interfaces: [eno2, eno1]
parameters:
mode: active-backup
primary: eno1
mii-monitor-interval: 200
bridges:
br0:
interfaces: [bond0]
dhcp4: false
dhcp6: false
addresses: [192.168.1.2/24]
gateway4: 192.168.1.1
nameservers:
addresses: [192.168.1.1]
测试用例1:
i. ping foo.bar ii. (从主绑定网卡上移除电缆)
ping 卡住
iii. CTRL-C(中止 ping)
iv. ping foo.bar # 重启 ping 探测
预计:
ping foo.bar
0.2 ms success
(..)
NIC Copper is down
package loss
ping foo.bar
0.2 ms success