我在一个 Ubuntu 系统上,有几个物理网卡和一个配置的bridge0接口(为内部虚拟机和容器提供对LAN其余部分的访问)。我有一个专门应用于bridge0接口的MAC地址,并且我有绑定到我的 DHCP 服务器上该 MAC 的静态 IP。 bridge0 接口应该总是从 DHCP 服务器获取 192.168.15.150,但目前这不起作用,我不明白为什么。当然,这在几个月甚至几年内都按预期工作,现在开始表现不同,而且我没有对这部分配置进行任何显式更改。
当系统启动时,它从服务器获取(错误的)非静态地址,如下所示:
ifconfig
启动后立即输出:
lwobker@lwobker-vms:~$ ifconfig
bridge1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.15.249 netmask 255.255.255.0 broadcast 192.168.15.255
ether 00:17:b6:00:66:e8 txqueuelen 1000 (Ethernet)
RX packets 468 bytes 110557 (110.5 KB)
TX packets 305 bytes 53792 (53.7 KB)
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether ac:1f:6b:b3:ad:fa txqueuelen 1000 (Ethernet)
RX packets 689 bytes 221475 (221.4 KB)
TX packets 591 bytes 90791 (90.7 KB)
请注意eno1
(这是连接到 DHCP 服务器的物理接口)根本没有获得地址。
有趣的是,如果我手动进入控制台并执行 a ,dhclient -r
然后执行 a dhclient
,bridge0 接口现在会获得所需的 .150 地址,而 .249 地址会以某种方式“迁移”到接口eno1
...这对我来说毫无意义。
ifconfig
执行 dhclient 反弹后的输出:
bridge1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.15.150 netmask 255.255.255.0 broadcast 192.168.15.255
ether 00:17:b6:00:66:e8 txqueuelen 1000 (Ethernet)
RX packets 47973 bytes 3180002 (3.1 MB)
TX packets 23345 bytes 571811191 (571.8 MB)
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.15.249 netmask 255.255.255.0 broadcast 192.168.15.255
ether ac:1f:6b:b3:ad:fa txqueuelen 1000 (Ethernet)
RX packets 81247 bytes 15919012 (15.9 MB)
TX packets 458449 bytes 672351752 (672.3 MB)
/etc/network/interfaces
文件:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
# put eno1 and enp2s0 in manual mode becuase it's going to be a bridge slave
iface eno1 inet manual
iface ens2 inet manual
##Bridge Name ###
auto bridge1
### Bridge Information
iface bridge1 inet dhcp
bridge_ports eno1 ens2
bridge_stp off
bridge_fd 0.0
bridge_waitport 0
# we want to fix the MAC addr assigned to the bridge so it gets the right IP address
# each time from my DHCP server...
post-up ip link set bridge1 address 00:17:b6:00:66:e8