Netplan 桥接主机获取静态 IP 地址而不是桥接器

Netplan 桥接主机获取静态 IP 地址而不是桥接器

我正在尝试为 KVM 客户端和主机连接配置桥接器。桥接器从未正确配置,物理 NIC 总是最终获得静态 IP 地址,而桥接器被分配动态 IP 地址。路由器中保留了静态 IP,这可能是导致这种情况的原因,但我不想删除 DHCP 保留。我做错了什么吗?

我的 Netplan 配置如下:

network:
    version: 2
    renderer: NetworkManager
    ethernets:
        enp2s0:
            dhcp4: no
            dhcp6: no
    bridges:
        br0:
            dhcp4: no
            dhcp6: no
            interfaces: [enp2s0]
            gateway4: 192.168.0.1
            addresses: [192.168.0.100/24]
            macaddress: 40:b0:34:30:c5:bf # Same as the physical NIC
            nameservers:
                addresses: [8.8.8.8, 8.8.4.4]
            parameters:
                stp: false
                forward-delay: 0

netplan --debug apply输出:https://pastebin.com/9yfMfWj0

ip route输出:

default via 192.168.0.1 dev enp2s0 src 192.168.0.100 metric 202 
default via 192.168.0.1 dev br0 proto dhcp src 192.168.0.101 metric 230 
169.254.0.0/16 dev br-c87c70358e53 scope link src 169.254.162.89 metric 207 
169.254.0.0/16 dev docker0 scope link src 169.254.164.22 metric 208 
169.254.0.0/16 dev veth66c4130 scope link src 169.254.120.192 metric 210 
169.254.0.0/16 dev veth97ef893 scope link src 169.254.172.222 metric 212 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 
172.18.0.0/16 dev br-c87c70358e53 proto kernel scope link src 172.18.0.1 
172.25.0.0/16 dev br-a88b0c435e9a proto kernel scope link src 172.25.0.1 linkdown 
172.26.0.0/16 dev br-bbd6b452a7d7 proto kernel scope link src 172.26.0.1 linkdown 
172.28.0.0/16 dev br-7f9c923a0aa0 proto kernel scope link src 172.28.0.1 linkdown 
192.168.0.0/24 dev enp2s0 proto dhcp scope link src 192.168.0.100 metric 202 
192.168.0.0/24 dev br0 proto dhcp scope link src 192.168.0.101 metric 230

编辑1:

我尝试过使用 networkd 并禁用 NetworkManager,但还是遇到了同样的问题。我注意到桥接器被分配了列出的静态 IP 和辅助 IP,但静态 IP 也分配给了物理卡。

ip addr输出:

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: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000
    link/ether 40:b0:34:30:c5:bf brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.100/24 brd 192.168.0.255 scope global noprefixroute enp2s0
       valid_lft forever preferred_lft forever
12: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 40:b0:34:30:c5:bf brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.100/24 brd 192.168.0.255 scope global br0
       valid_lft forever preferred_lft forever
    inet 192.168.0.101/24 brd 192.168.0.255 scope global secondary noprefixroute br0
       valid_lft forever preferred_lft forever
    inet6 2607:fea8:c40:5d30::77c0/128 scope global dynamic noprefixroute 
       valid_lft 140769sec preferred_lft 140769sec
    inet6 2607:fea8:c40:5d30:42b0:34ff:fe30:c5bf/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 172799sec preferred_lft 172799sec
    inet6 2607:fea8:c40:5d30:ef6d:24e5:94a9:fc6a/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 172799sec preferred_lft 172799sec
    inet6 fe80::fded:8289:a1a3:580b/64 scope link 
       valid_lft forever preferred_lft forever

相关内容