如何在 Ubuntu 20 上为 CloudStack 桥设置 Netplan 网络配置?

如何在 Ubuntu 20 上为 CloudStack 桥设置 Netplan 网络配置?

我正在尝试为我们的 CloudStack 测试设置一个主机,但是在使用 Netplan 配置网络桥接时我无法找出问题所在。

来自安装文档,他们展示了一个使用的示例/etc/network/interfaces。Ubuntu 20 改用 Netplan。目标是拥有如下配置:

auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet manual

auto eth0.200
iface eth0 inet manual

# management network
auto cloudbr0
iface cloudbr0 inet static
    bridge_ports eth0
    bridge_fd 0
    bridge_stp off
    bridge_maxwait 1
    address 192.168.42.11
    netmask 255.255.255.240
    gateway 192.168.42.1
    dns-nameservers 8.8.8.8 8.8.4.4
    dns-domain lab.example.org

# guest network
auto cloudbr1
iface cloudbr1 inet manual
    bridge_ports eth0.200
    bridge_fd 0
    bridge_stp off
    bridge_maxwait 1

输出ifconfig为:

ifconfig
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet XX.XX.XXX.XXX  netmask 255.255.255.0  broadcast XX.XX.XXX.XXX
        inet6 XXXX::XXXX:XXXX:XXXX:XXX  prefixlen 64  scopeid 0x20<link>
        inet6 XXXX::XXXX:XXXX:XXXX::  prefixlen 56  scopeid 0x0<global>
        ether XX:XX:XX:XX:XX:XX  txqueuelen 1000  (Ethernet)
        RX packets 791  bytes 113330 (113.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 767  bytes 104793 (104.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

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 20  bytes 2028 (2.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 20  bytes 2028 (2.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

此时,我明白在这种情况下我应该参考eno1而不是eth0

默认配置没有问题,我可以 ping 服务器。它看起来像:

cat 50-cloud-init.yaml
network:
    version: 2
    ethernets:
        eno1:
            accept-ra: false
            addresses:
            - XXXX:XXXX:XXX:XXXX::/56
            dhcp4: true
            match:
                macaddress: XX:XX:XX:XX:X:XX
            nameservers:
                addresses:
                - XXXX:XXXX:X:XXX::X
            routes:
            -   to: ::/0
                via: XXXX:XXXX:XXXX:XXff:ff:ff:ff:ff
            -   ......
            set-name: eno1

我已经修改了配置以包含他们在文档中建议的桥梁:

network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      accept-ra: false
      dhcp4: false
      optional: true

  bridges:
    cloudbr0:
      interfaces: [eno1]
      addresses:
        - XX.XX.XXX.XXX/24
      gateway4: XX.XX.XXX.XXX
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]

    cloudbr1:
      interfaces: [eno1.200]

然后我运行netplan --debug try测试它,得到以下结果:

netplan --debug try
DEBUG:eno1 not found in {}
DEBUG:cloudbr0 not found in {}
DEBUG:cloudbr1 not found in {'cloudbr0': {'interfaces': ['eno1'], 'addresses': ['XX.XX.XXX.XXX/24'], 'gateway4': 'XX.XX.XXX.XXX', 'nameservers': {'addresses': ['8.8.8.8', '8.8.4.4']}}}
DEBUG:Merged config:
network:
  bridges:
    cloudbr0:
      addresses:
      - XX.XX.XXX.XXX/24
      gateway4: XX.XX.XXX.XXX
      interfaces:
      - eno1
      nameservers:
        addresses:
        - 8.8.8.8
        - 8.8.4.4
    cloudbr1:
      interfaces:
      - eno1.200
  ethernets:
    eno1:
      accept-ra: false
      dhcp4: false
      optional: true
  renderer: networkd
  version: 2

DEBUG:New interfaces: set()
** (generate:1793): DEBUG: 09:53:40.751: starting new processing pass
** (generate:1793): DEBUG: 09:53:40.751: recording missing yaml_node_t eno1.200
(generate:1793): GLib-GIO-DEBUG: 09:53:40.757: _g_io_module_get_default: Found default implementation local (GLocalVfs) for ?gio-vfs?
/etc/netplan/50-cloud-init.yaml:22:20: Error in network definition: cloudbr1: interface 'eno1.200' is not defined
      interfaces: [eno1.200]
                   ^

An error occurred: the configuration could not be generated

现在,如果我改为,我[eno1.200]得到。[eno1]Error in network definition: cloudbr1: interface 'eno1' is already assigned to bridge cloudbr0

问:我的配置文件应该如何工作?

相关内容