我的需求是聚合有线网卡和 Wi-Fi 无线网卡。问了 AI ,AI 说不行。
我之前在 armbian 上用 netplan 进行过配置和尝试,结果是可行的。
以我的机器为例,我的有线网卡接口名为 eth0, 无线网卡接口名是 wlan0.
新建的聚合接口名会是 bond0.
系统信息
加载 bonding 模块
interfaces 设置
eth0 设置
armbian 安装 pve 后,eth0 就已经变成 manual. 无须修改。
# /etc/network/interfaces
auto eth0
iface eth0 inet manual
wlan0 设置
添加 wlan0 的设置。
# /etc/network/interfaces
auto wlan0
iface wlan0 inet manual
wpa-ssid "wifissidqwe123"
wpa-psk "wifipskasdzxc"
metric 666
bond0 设置
添加 bond0 的设置。
bond-slaves填写被聚合网卡接口名。bond-mode填写 bond 模式。我需要的是active-backup, 因为我这个无线网卡有问题,只有 2.4Ghz,速度慢,还会断流、会丢包,仅作为备用。bond-primary填写主要接口,即流量优先从这个口传输。bond-miimon不知道是啥,pve 添加上去的值,不管它,能用就行。
# /etc/network/interfaces
auto bond0
iface bond0 inet manual
bond-slaves eth0 wlan0
bond-miimon 100
bond-mode active-backup
bond-primary eth0
vmbr0 设置
vmbr0 是 pve 默认的虚拟网桥,默认使用 eth0 作为网桥接口。这里改成我需要的 bond0.
完整的 interfaces 配置
仅供参考,不要直接复制粘贴。
警告
谨慎设置,小心失联!
# /etc/network/interfaces
# network interface settings; autogenerated
# Please do NOT modify this file directly, unless you know what
# you're doing.
#
# If you want to manage parts of the network configuration manually,
# please utilize the 'source' or 'source-directory' directives to do
# so.
# PVE will preserve these directives, but will NOT read its network
# configuration from sourced files, so do not attempt to move any of
# the PVE managed interfaces into external files!
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet manual
auto wlan0
iface wlan0 inet manual
wpa-ssid "wifissidqwe123"
wpa-psk "wifipskasdzxc"
metric 666
auto bond0
iface bond0 inet manual
bond-slaves eth0 wlan0
bond-miimon 100
bond-mode active-backup
bond-primary eth0
auto vmbr0
iface vmbr0 inet static
address 192.168.666.555/24
gateway 192.168.666.1
dns-nameservers 192.168.666.1
bridge-ports bond0
bridge-stp off
bridge-fd 0
hwaddress ether 84:c6:4d:ef:12:47
应用设置
我的设备没有显示接口,为了防止意外,我插了额外的一张 USB 无线网卡并配置好联网,以免失联。
在确保安全的前提下,重启 pve 主机。
不出意外的话应该不出意外。我的 pve 主机重启后可以正常联网,在我的 openwrt 路由器上可以看到 pve 主机对应的 lan 口处于启用状态, pve 主机也连接到 Wi-Fi 网络中。
测试
测试 bond 是否能够正常切换网卡,可以使用另一台设备持续 ping pve 主机,
如:
ping -i 1 -W 1 192.168.666.555ping -i 1 -W 1 192.168.666.555 -A
然后插、拔网线,查看 pve 主机是否有回应 ping。
例如:
我在 seq=10 时,断开了 pve 主机网线,随即看到 ping 的回应停顿了一下,随后延迟变大。
在 seq=20 左右,重新插上了网线,ping 回应没有停顿,过了一会,延迟变小。
通常来说,无线网卡的延迟大于有线网卡。因此在我的这个案例中,借助 ping 工具即可简单地观测 bond 网卡的切换情况。
| |