我使用 iprouter2 工具创建了一个 vxlan 隧道。命令如下:
ip link add vxlan2 type vxlan id 2 group 233.1.1.1 dev bond0 dstport 4789
但是当我重启网络或者“ifdown bond0”时,vxlan2 就消失了。这是为什么呢?在 CentOS 上不会出现这样的问题。
我检查了系统日志,发现了这样的信息:
Jul 18 11:38:04 ubuntu-22 named[2184]: configuring command channel from '/etc/bind/rndc.key'
Jul 18 11:38:04 ubuntu-22 named[2184]: configuring command channel from '/etc/bind/rndc.key'
Jul 18 11:38:04 ubuntu-22 named[2184]: reloading configuration succeeded
Jul 18 11:38:04 ubuntu-22 kernel: [ 6361.308330] bonding: bond0 is being deleted...
Jul 18 11:38:04 ubuntu-22 kernel: [ 6361.308609] device vxlan2 left promiscuous mode
Jul 18 11:38:04 ubuntu-22 kernel: [ 6361.308733] bond0 (unregistering): Released all slaves
Jul 18 11:38:04 ubuntu-22 named[2184]: any newly configured zones are now loaded
好像是被内核删除了。我不想我的 vxlan 隧道因为“ifdown bond0”而消失。我该怎么办?
我的Ubuntu服务器信息如下:
root@ubuntu-22:~# cat /etc/issue
Ubuntu 16.04.2 LTS \n \l
root@ubuntu-22:~# uname -a
Linux ubuntu-22 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
bond0信息如下:
root@ubuntu-22:~# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eno1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: ac:1f:6b:12:57:b4
Slave queue ID: 0
Slave Interface: eno2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: ac:1f:6b:12:57:b5
Slave queue ID: 0
答案1
我下载了 ifupdown 的源代码来查找原因。我发现在“iface_postdown”时使用“/bin/run-parts”调用了“/etc/network/if-post-down.d/ifenslave”脚本。在脚本的最后,程序会删除 master 本身:
# Remove the master itself
echo "-$IFACE" > /sys/class/net/bonding_masters
rm /run/network/ifenslave.$IFACE
当我注释掉“echo“-$IFACE”> /sys/class/net/bonding_masters”时,bond0 不会被删除。