脆弱的 netplan 文件

脆弱的 netplan 文件

我有一台 kvm 服务器,上面有多个 vlan,我想为每个 vlan 创建一个网桥。我整理了来自多个站点的文档,想出了一个有时有效,有时无效的方法。我需要的另一件事是让 br212(见下文)提供一个 IP 地址。有时有效,有时无效。这是一个简化版本,因为实际版本有超过 30 个网桥和 vlan。

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      dhcp4: no

  bridges:
# 10.66.12.0/22 - dev
    br212:
      interfaces: [vlan212]
      macaddress: "11:22:33:44:55:66"
      dhcp4: true

# 10.5.0.0/16 - cert
    br105:
      interfaces: [vlan105]
      dhcp4: no

# 172.16.0.0/16 - sandbox
    br16:
      interfaces: [vlan16]
      dhcp4: no

# 10.66.6.0/24 - logging
    br206:
      interfaces: [vlan206]
      dhcp4: no

  vlans:
    vlan105:
      accept-ra: no
      id: 105
      link: eno2

    vlan16:
      accept-ra: no
      id: 16
      link: eno2    

    vlan206:
      accept-ra: no
      id: 206
      link: eno2

    vlan212:
      accept-ra: no
      id: 212
      link: eno2

答案1

您的 .yaml 文件中有多余的空格字符。.yaml 文件对缩进、间距和制表符的要求非常严格。您也没有包含 en02: 代码。尝试一下这个框架,看看它是否适合您。

network: 
  version: 2
  renderer: networkd
  ethernets: 
    eno1: 
      optional: true
    en02: 
      match: 
        macaddress: "11:22:33:44:55:66"
      optional: true
  bridges: 
    br212: 
      interfaces: [vlan212]
      dhcp4: true
  vlans: 
    vlan212: 
      accept-ra: no
      id: 212
      link: eno2

答案2

好的,我解决了这个问题。步骤 1 - 确保您的网络设备已正确设置为中继,并且具有本机标记的 VLAN...

第 2 步——文件:

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    eno2:
      optional: true

  bridges:
# 10.66.12.0/22 - dev
    br212:
      interfaces: [vlan212]
      macaddress: "00:20:3e:42:0e:64"
      dhcp4: true

# 10.5.0.0/16 - cert
    br105:
      interfaces: [vlan105]
      dhcp4: no

# 172.16.0.0/16 - sandbox
    br16:
      interfaces: [vlan16]
      dhcp4: no

# 10.66.6.0/24 - logging
    br206:
      interfaces: [vlan206]
      dhcp4: no

# 10.66.8.0/22 - dev
    br208:
      interfaces: [vlan208]
      dhcp4: no

  vlans:
    vlan105:
      accept-ra: no
      id: 105
      link: eno2

    vlan16:
      accept-ra: no
      id: 16
      link: eno2

    vlan206:
      accept-ra: no
      id: 206
      link: eno2

    vlan208:
      accept-ra: no
      id: 208
      link: eno2

    vlan212:
      accept-ra: no
      id: 212
      link: eno2

相关内容