我有一个用于接口 eno1 的静态 IP 地址,该地址应成为 kvm/qemu 的桥接器。我的静态 IP netplan 配置(Ubuntu 18.04)如下所示,并且正常运行:
network:
version: 2
#renderer: NetworkManager
renderer: networkd
ethernets:
eno1:
dhcp4: false
dhcp6: false
addresses: [XXX.XXX.196.33/20]
gateway4: XXX.XXX.192.254
nameservers:
addresses: [XXX.XXX.192.80]
遗憾的是,我的桥接配置不适用于该接口。应用后我无法路由。
network:
version: 2
#renderer: NetworkManager
renderer: networkd
ethernets:
eno1:
dhcp4: false
dhcp6: false
bridges:
br0:
dhcp4: false
dhcp6: false
interfaces: [eno1]
addresses: [XXX.XXX.196.33/20]
gateway4: XXX.XXX.192.254
nameservers:
addresses: [XXX.XXX.192.80]
路由如下:
# route -n
Kernel-IP-Routentabelle
Ziel Router Genmask Flags Metric Ref Use Iface
0.0.0.0 XXX.XXX.192.254 0.0.0.0 UG 0 0 0 br0
XXX.XXX.192.0 0.0.0.0 255.255.240.0 U 0 0 0 br0
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
现在我尝试使用 dhcp 为网桥添加一个额外的 NIC,但也失败了:
network:
version: 2
renderer: NetworkManager
#renderer: networkd
ethernets:
eno1:
dhcp4: false
dhcp6: false
optional: true
addresses: [XXX.XXX.196.33/20]
gateway4: XXX.XXX.192.254
nameservers:
addresses: [XXX.XXX.192.80]
enp4s0:
dhcp4: true
bridges:
br0:
dhcp4: true
dhcp6: false
optional: true
interfaces: [enp4s0]
IP 地址显示桥接器的接口始终处于关闭状态!
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp4s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether 00:0a:cd:20:b6:05 brd ff:ff:ff:ff:ff:ff
3: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether f0:79:59:db:e1:76 brd ff:ff:ff:ff:ff:ff
inet XXX.XXX.196.33/20 brd XXX.XXX.207.255 scope global noprefixroute eno1
valid_lft forever preferred_lft forever
inet6 fe80::f279:59ff:fedb:e176/64 scope link
valid_lft forever preferred_lft forever
4: br0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 06:62:fa:ee:f8:c2 brd ff:ff:ff:ff:ff:ff
5: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:a4:3b:8b brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
6: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:a4:3b:8b brd ff:ff:ff:ff:ff:ff
启动时我没有收到任何错误消息
ip link set enp4s0 up
ip link set br0 up
但所有 NIC 仍然处于关闭状态。
怎么了?
好的,我终于让它工作了!上面的设置桥接的配置是正确的!
我错过了网桥获取新的 MAC 地址的机会,并且我们的 NAC 阻止为该 MAC 提供 IP,因为同一系统上我之前的网桥获得了不同的 MAC 地址。