我尝试在两个交换机之间建立绑定,这两个交换机链接到一个与摄像头(10.0.10.10)相连的交换机:
Camera
|
|
Switch 1 - - - - - - - -
| |
| A | B
| |
Switch Primary Switch Secondary
| |
C | enp3s4f0 D | enp3s4f1
| |
| |
---------------------------
|Ubuntu 18.04 |
| bond0 |
|------------------------ |
目标是当连接 A/B/C/D 中的任何一个断开时,能够 ping 通摄像头。目前,如果连接 A 断开,则无法 ping 通摄像头。如果任何其他连接失败,它仍然可以 ping 通摄像头。
这是我的 01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
enp3s4f0:
addresses: [ ]
enp3s4f1:
addresses: [ ]
bonds:
bond0:
addresses: [ 10.0.10.101/24 ]
gateway4: 10.0.10.10
nameservers:
addresses: [ 1.1.1.1, 1.1.1.0 ]
interfaces: [ enp3s4f0, enp3s4f1 ]
parameters:
mode: active-backup
primary: enp3s4f0
应用 netplan 后,没有抛出任何错误:
sudo netplan apply
问题是,当 A 断开连接时,服务器仍将连接 C 识别为活动连接,因此绑定不会改变其接口,因此它会继续尝试从主交换机访问摄像头,但这是不可能的。
答案1
来自 netplan.io 参考页面这里我们发现债券参数可以帮助我们:
arp-interval (scalar)
Set the interval value for how frequently ARP link monitoring should
happen. The default value is 0, which disables ARP monitoring. For the
networkd backend, this maps to the ARPIntervalSec= property. If no time
suffix is specified, the value will be interpreted as milliseconds.
arp-ip-targets (sequence of scalars) IPs of other hosts on the link which
should be sent ARP requests in order to validate that a slave is up.
This option is only used when arp-interval is set to a value other than 0.
At least one IP address must be given for ARP link monitoring to function.
Only IPv4 addresses are supported. You can specify up to 16 IP addresses.
The default value is an empty list.
因此,在 bond0 节中,我们进行了以下更改:
parameters:
mode: active-backup
primary: enp3s4f0
到:
parameters:
mode: active-backup
primary: enp3s4f0
arp-interval: 10
arp-ip-targets: 10.0.10.10
现在,当摄像机离线时,bond0 可以成功切换到另一台交换机,并使摄像机重新上线。