设置 MTU 不适用于 systemd-networkd,但适用于“ip link set mtu”

设置 MTU 不适用于 systemd-networkd,但适用于“ip link set mtu”

我正在尝试更改MTU一个界面。
我注意到使用时它没有正确更改systemd-networkd,但当我使用该ip link set mtu命令时它可以工作。

当前MTU为 1500:

3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether aa:bb:cc:dd:ee:ff brd ff:ff:ff:ff:ff:ff promiscuity 0 addrgenmode eui64 numtxqueues 8 numrxqueues 8 gso_max_size 65536 gso_max_segs 65535 

现在,我更改了/etc/systemd/network/50_eth0.network文件并添加了:

[Link]
MTUBytes = 1000

systemd-networkd服务重启后syslog显示:

Nov 30 23:36:20 me kernel: [84974.429088] igb 0000:00:14.0: changing MTU from 1500 to 1280

当前MTU为 1280:

3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1280 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether aa:bb:cc:dd:ee:ff brd ff:ff:ff:ff:ff:ff promiscuity 0 addrgenmode eui64 numtxqueues 8 numrxqueues 8 gso_max_size 65536 gso_max_segs 65535 

正如您所看到的,我想要 1000,但它更改为 1280。我想我在某处读到过有关 IPv6 的限制。

现在,使用该ip工具时:

ip link set mtu 1000 dev eth0

syslog:

Nov 30 23:36:44 me kernel: [84998.785039] igb 0000:00:14.0: changing MTU from 1280 to 1000

当前MTU为 1000:

# ip -d link show dev eth0
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1000 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether aa:bb:cc:dd:ee:ff brd ff:ff:ff:ff:ff:ff promiscuity 0 numtxqueues 8 numrxqueues 8 gso_max_size 65536 gso_max_segs 65535 

为什么一种方法有效而另一种方法无效?
谢谢。

答案1

根据AB的评论。
事实上,MTUBytes[Link]节的 部分提到了以下 IPv6 注释:

MTUBytes=
The maximum transmission unit in bytes to set for the device. The usual suffixes K, M, G, are supported and are understood to the base of 1024.
Note that if IPv6 is enabled on the interface, and the MTU is chosen below 1280 (the minimum MTU for IPv6) it will automatically be increased to this value.

为该接口禁用 IPv6 后,我的 MTU 低于 1280。
我已使用本节的以下指令禁用了该接口的 IPv6 [Network],其none值是:

IPv6LinkLocalAddressGenerationMode=
Specifies how IPv6 link-local address is generated. Takes one of "eui64", "none", "stable-privacy" and "random". When unset, "stable-privacy" is used if IPv6StableSecretAddress= is specified, and if not, "eui64" is used. Note that if LinkLocalAddressing= is "no" or "ipv4", then IPv6LinkLocalAddressGenerationMode= will be ignored. Also, even if LinkLocalAddressing= is "yes" or "ipv6", setting IPv6LinkLocalAddressGenerationMode=none disables to configure an IPv6 link-local address.

相关内容