ubuntu 22.04:无法使用 netplan/openvswitch 设置 vlan ip/网关:应用时 vlan ip 消失

ubuntu 22.04:无法使用 netplan/openvswitch 设置 vlan ip/网关:应用时 vlan ip 消失

我的目的是使用 openvswitch 配置 Linux 交换机(6 个端口):

  • WLAN 端口:enp1s0
  • 5 个 LAN 端口(中继,未绑定):enp2s0 .. enp6s0

并具有 VLAN 9,10,11

我已经使用 openvswitch 配置了接口:

sudo ovs-vsctl show
95eeb1b7-973c-4b27-9f8f-6d9ff5745e40
    Bridge br-lan0
        fail_mode: standalone
        Port mibr-lan0
            Interface mibr-lan0
                error: "could not open network device mibr-lan0 (No such device)"
        Port enp6s0
            trunks: [0, 9, 10, 11]
            Interface enp6s0
        Port vlan11
            tag: 11
            Interface vlan11
                type: internal
        Port veth65e5a228
            Interface veth65e5a228
        Port vethc43ea8be
            Interface vethc43ea8be
        Port veth60a7dae9
            Interface veth60a7dae9
        Port enp3s0
            trunks: [0, 9, 10, 11]
            Interface enp3s0
        Port veth60fb5fcb
            Interface veth60fb5fcb
        Port enp5s0
            trunks: [0, 9, 10, 11]
            Interface enp5s0
        Port enp2s0
            trunks: [0, 9, 10, 11]
            Interface enp2s0
        Port vlan10
            tag: 10
            Interface vlan10
                type: internal
        Port vlan9
            tag: 9
            Interface vlan9
                type: internal
        Port enp4s0
            trunks: [0, 9, 10, 11]
            Interface enp4s0
        Port br-lan0
            Interface br-lan0
                type: internal
    ovs_version: "2.17.0"

然后手动设置 ips: sudo ip link set vlan9 up sudo ip link set vlan10 up sudo ip addr add 172.16.9.1/24 dev vlan9 sudo ip addr add 172.16.10.1/24 dev vlan10

并且有效:

    link/ether 6e:99:9d:c2:7f:d4 brd ff:ff:ff:ff:ff:ff
    inet 172.16.10.1/24 scope global vlan10
       valid_lft forever preferred_lft forever
10: vlan9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether b6:56:f9:9b:6e:4a brd ff:ff:ff:ff:ff:ff
    inet 172.16.9.1/24 scope global vlan9
       valid_lft forever preferred_lft forever


但是现在我想配置 netplan 以便它即使在重启后也能自动运行:

netplan 配置:

network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enp2s0: {}
    enp3s0: {}
    enp4s0: {}
    enp5s0: {}
    enp6s0: {}
    vlan9: 
      dhcp4: no
      addresses: [172.16.9.1/24]
      nameservers:
        search: [data.quentinhouse.intra]
        addresses: [172.16.9.1]
    vlan10:
      dhcp4: no
      addresses: [172.16.10.1/24]
      nameservers:
        search: [public.quentinhouse.intra]
        addresses: [172.16.10.1]

  bridges:
    br-lan0:
      addresses: [172.16.99.1/24]
      interfaces: [enp2s0, enp3s0,enp4s0,enp5s0,enp6s0]
      openvswitch: {} # this is an OVS port
      nameservers:
        search: [quentinhouse.intra]
        addresses: [172.16.99.1]

 LANG=C nmcli d
DEVICE        TYPE         STATE         CONNECTION          
enp1s0        ethernet     connected     Connexion filaire 1 
enp2s0        ethernet     disconnected  --                  
enp3s0        ethernet     disconnected  --                  
enp4s0        ethernet     disconnected  --                  
enp6s0        ethernet     disconnected  --                  
enp5s0        ethernet     unavailable   --                  
veth60a7dae9  ethernet     unmanaged     --                  
veth60fb5fcb  ethernet     unmanaged     --                  
veth65e5a228  ethernet     unmanaged     --                  
vethc43ea8be  ethernet     unmanaged     --                  
lo            loopback     unmanaged     --                  
br-lan0       openvswitch  unmanaged     --                  
ovs-system    openvswitch  unmanaged     --                  
vlan10        openvswitch  unmanaged     --                  
vlan11        openvswitch  unmanaged     --                  
vlan9         openvswitch  unmanaged     --

当我应用 netplan 时:

sudo netplan generate -> 没有错误 sudo netplan apply -> 没有错误

但 IP 消失:

9: vlan10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether 6e:99:9d:c2:7f:d4 brd ff:ff:ff:ff:ff:ff
10: vlan9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether b6:56:f9:9b:6e:4a brd ff:ff:ff:ff:ff:ff

那么发生了什么?

问候

相关内容