Netplan 绑定/桥接 MTU 设置在 Bionic 系统上不受支持

Netplan 绑定/桥接 MTU 设置在 Bionic 系统上不受支持

我在 18.04 系统上运行 Netplan。我已经能够将我 16.04 系统上的大部分网络配置转换为 18.04 的 Netplan,但是现在当我尝试在使用 VLAN 绑定的网桥上将 MTU 设置为 9000 时遇到了问题。

我的配置:

# Ceph network configuration
network:
  version: 2
  renderer: networkd
  ethernets:
    eth2:
      dhcp4: no
      dhcp6: no
      optional: true
      mtu: 9000
    eth3:
      dhcp4: no
      dhcp6: no
      optional: true
      mtu: 9000
  bonds:
    bond1:
      interfaces: [ eth2, eth3 ]
      parameters:
        mode: 802.3ad
        mii-monitor-interval: 100
        lacp-rate: fast
  vlans:
    bond1.220:
      id: 220
      link: bond1
      mtu: 9000
  bridges:
    br-ceph-access:
      addresses: [ x.x.x.x/24 ]
      interfaces: [ bond1.220 ]
      parameters:
        forward-delay: 9
        hello-time: 2
        max-age: 12
        stp: false

我已将“mtu: 9000”添加到绑定的两个 NIC 以及 VLAN。我这样做是因为将“mtu: 9000”添加到绑定接口或桥接接口会产生错误“未知密钥 mtu”

无论如何,该mtu: 9000设置均不受尊重,正如您在ip a(通知mtu 15000)的相关部分中所看到的那样:

4: eth2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond1 state UP group default qlen 1000
    link/ether b2:07:76:18:10:5b brd ff:ff:ff:ff:ff:ff
5: eth3: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond1 state UP group default qlen 1000
    link/ether b2:07:76:18:10:5b brd ff:ff:ff:ff:ff:ff
10: br-ceph-access: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 4e:b5:52:25:a4:c5 brd ff:ff:ff:ff:ff:ff
    inet x.x.x.x/24 brd 172.16.238.255 scope global br-ceph-access
       valid_lft forever preferred_lft forever
11: bond1: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether b2:07:76:18:10:5b brd ff:ff:ff:ff:ff:ff

那么我错在哪里了?使用 Netplan 设置 mtu 的正确方法是什么?我发现了需要报告的错误吗?

答案1

我通过将 MTU 设置添加到“bonds:”和“bridges:”部分(从“ethernets:”部分中删除)解决了此问题。以下是工作配置:

# Ceph network configuration
network:
  version: 2
  renderer: networkd
  ethernets:
    eth2:
      dhcp4: no
      optional: true
    eth3:
      dhcp4: no
      optional: true
  bonds:
    bond1:
      interfaces: [ eth2, eth3 ]
      mtu: 9000
      parameters:
        mode: 802.3ad
        mii-monitor-interval: 100
        lacp-rate: fast
  vlans:
    bond1.220:
      id: 220
      link: bond1
      optional: true
  bridges:
    br-ceph-access:
      optional: true
      addresses: [ 172.16.238.133/24 ]
      interfaces: [ bond1.220 ]
      mtu: 9000
      parameters:
        forward-delay: 9
        hello-time: 2
        max-age: 12
        stp: false

答案2

我认为你想通过 MAC 地址匹配设备,否则很难systemd-networkd以准确了解要将 MTU 应用于哪些设备。您还应该为绑定本身指定 MTU 为 9000,因为当将绑定添加到底层接口时,其选项将应用于底层接口:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth2:
      match:
        macaddress: 00:00:aa:bb:cc:dd
      dhcp4: no
      dhcp6: no
      optional: true
      mtu: 9000
    eth3:
      match:
        macaddress: 01:01:aa:bb:cc:de
      dhcp4: no
      dhcp6: no
      optional: true
      mtu: 9000
  bonds:
    bond1:
      mtu: 9000
      interfaces: [ eth2, eth3 ]
      parameters:
        mode: 802.3ad
        mii-monitor-interval: 100
        lacp-rate: fast
  vlans:
    bond1.220:
      id: 220
      link: bond1
      mtu: 9000
  bridges:
    br-ceph-access:
      addresses: [ x.x.x.x/24 ]
      interfaces: [ bond1.220 ]
      parameters:
        forward-delay: 9
        hello-time: 2
        max-age: 12
        stp: false

但请注意,匹配设备本身也存在一系列问题;请参阅https://github.com/CanonicalLtd/netplan/commit/a27122bc8d8e066b1a90a7fd8d65342e8b906a8e

相关内容