eno1, eno2, eno3, eno4
我在 Ubuntu 18.04 服务器上配置 netplan 以绑定使用 802.3ad 协议命名的四个硬件以太网端口时遇到一些问题。我查阅了网络规划手册页并将以下配置文件放在一起/etc/netplan/50-cloud-init.yaml
:
network:
version: 2
renderer: networkd
ethernets:
eports:
match:
name: eno*
bonds:
bond0:
interfaces: [eports]
addresses: [192.168.1.101/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
parameters:
mode: 802.3ad
lacp-rate: fast
mii-monitor-interval: 100
运行命令后,sudo netplan --debug apply
我收到以下信息:
** (generate:6473): DEBUG: 00:39:14.911: Processing input file //etc/netplan/50-cloud-init.yaml..
** (generate:6473): DEBUG: 00:39:14.911: starting new processing pass
** (generate:6473): DEBUG: 00:39:14.911: eports: setting default backend to 1
** (generate:6473): DEBUG: 00:39:14.911: bond0: setting default backend to 1
** (generate:6473): DEBUG: 00:39:14.912: Generating output files..
** (generate:6473): DEBUG: 00:39:14.912: NetworkManager: definition eports is not for us (backend 1)
** (generate:6473): DEBUG: 00:39:14.912: NetworkManager: definition bond0 is not for us (backend 1)
DEBUG:netplan generated networkd configuration exists, restarting networkd
DEBUG:no netplan generated NM configuration exists
DEBUG:device eno2 operstate is up, not replugging
DEBUG:netplan triggering .link rules for eno2
DEBUG:device lo operstate is unknown, not replugging
DEBUG:netplan triggering .link rules for lo
DEBUG:replug eno3: unbinding 0000:03:00.0 from /sys/bus/pci/drivers/igb
DEBUG:replug eno3: rebinding 0000:03:00.0 to /sys/bus/pci/drivers/igb
DEBUG:replug eno1: unbinding 0000:01:00.0 from /sys/bus/pci/drivers/igb
DEBUG:replug eno1: rebinding 0000:01:00.0 to /sys/bus/pci/drivers/igb
DEBUG:Cannot replug bond0: cannot read link /sys/class/net/bond0/device: [Errno 2] No such file or directory: '/sys/class/net/bond0/device'
DEBUG:netplan triggering .link rules for bond0
DEBUG:replug eno4: unbinding 0000:04:00.0 from /sys/bus/pci/drivers/igb
DEBUG:replug eno4: rebinding 0000:04:00.0 to /sys/bus/pci/drivers/igb
我不知道该怎么理解这个声明
Cannot replug bond0: cannot read link /sys/class/net/bond0/device: [Errno 2] No such file or directory: '/sys/class/net/bond0/device'
因为该目录/sys/class/net/bond0
是由命令生成的netplan apply
。
我检查了我的ifconfig
输出,我的网络设备似乎配置正确,但没有设置地址bond0
:
bond0: flags=5123<UP,BROADCAST,MASTER,MULTICAST> mtu 1500
ether XX:XX:XX:XX:XX:XX txqueuelen 1000 (Ethernet)
RX packets 112768 bytes 7785014 (7.7 MB)
RX errors 0 dropped 54 overruns 0 frame 0
TX packets 18854 bytes 2337896 (2.3 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eno1: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST> mtu 1500
ether XX:XX:XX:XX:XX:XX txqueuelen 1000 (Ethernet)
RX packets 290 bytes 19322 (19.3 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 55 bytes 6820 (6.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xdf400000-df47ffff
eno2: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST> mtu 1500
ether XX:XX:XX:XX:XX:XX txqueuelen 1000 (Ethernet)
RX packets 73991 bytes 29824155 (29.8 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 20848 bytes 2110417 (2.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xdf300000-df37ffff
eno3: flags=6147<UP,BROADCAST,SLAVE,MULTICAST> mtu 1500
ether XX:XX:XX:XX:XX:XX txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xdf200000-df27ffff
eno4: flags=6147<UP,BROADCAST,SLAVE,MULTICAST> mtu 1500
ether XX:XX:XX:XX:XX:XX txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xdf100000-df17ffff
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 2923 bytes 184477 (184.4 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2923 bytes 184477 (184.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
这些ether XX:XX:XX:XX:XX:XX
语句代替了每个接口的 MAC 地址。在原始输出中,所有地址都是相同的。
为了成功配置我的系统,我缺少什么?
答案1
经过一番挖掘,我发现 Ubuntu 18.04 使用一个名为 的实用程序cloud-init
来在启动序列期间处理网络配置和初始化。该文件/etc/cloud/cloud.cfg.d/50-curtin-networking.cfg
和其他.cfg
文件用于重新配置cloud-init
设置。我的配置文件设置如下:
network:
version: 2
ethernets:
eports:
match:
name: eno*
optional: true
bonds:
bond0:
interfaces: [eports]
addresses: [192.168.1.101/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
parameters:
mode: 802.3ad
lacp-rate: fast
mii-monitor-interval: 100
该optional: true
参数可防止系统在启动时等待有效的网络连接,这将为您省去等待 2 分钟机器启动的麻烦。更新配置文件后,运行以下命令来更新您的配置。
cloud-init clean -reboot
或者,运行以下命令可以获取一些调试信息,而无需重新启动计算机;但是,在早期启动阶段需要重新启动才能提交更改。
cloud-init clean
cloud-init init
cloud-init status