DHCP 服务器设置 MTU 时链路震荡

DHCP 服务器设置 MTU 时链路震荡

我在 Ubuntu 18.04 系统上遇到了一个特殊的网络问题。我的一个以太网接口仅在使用一种特定品牌的路由器(Sierra Wireless MP70)且仅在启用 DHCP 时才会出现链路抖动。我已经彻底排除了其他因素。使用静态 IP 设置,链路功能正常,并且我没有看到其他问题(例如,没有数据包丢失)。

观察到的行为是,链路短暂联机并似乎获得 DHCP 租约,立即切换到NO-CARRIER,然后重复。

我以前认为这是一个物理层问题,但我发现NO-CARRIER在将链路从下到上切换后会短暂出现,因此我当前的假设是某些系统进程只是导致网络上下循环。

我对该设备的网络规划很简单:

    eth1:
      dhcp4: true
      dhcp4-overrides:
        use-routes: false

这是循环日志的部分systemd-networkd

eth1: Flags change: +LOWER_UP +RUNNING
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_34 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=12 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
eth1: Gained carrier
eth1: Acquiring DHCPv4 lease
DHCP CLIENT (0xe616919c): STARTED on ifindex 4
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=13 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
DHCP CLIENT (0xe616919c): DISCOVER
DHCP CLIENT (0xe616919c): OFFER
DHCP CLIENT (0xe616919c): REQUEST (requesting)
DHCP CLIENT (0xe616919c): ACK
DHCP CLIENT (0xe616919c): lease expires in 1d 23h 59min 59s
DHCP CLIENT (0xe616919c): T2 expires in 1d 18h
DHCP CLIENT (0xe616919c): T1 expires in 1d
eth1: DHCPv4 address 192.168.13.110/24 via 192.168.13.31
eth1: Setting MTU: 1430
Setting transient hostname: 'ifcb000'
Sent message type=method_call sender=n/a destination=org.freedesktop.hostname1 path=/org/freedesktop/hostname1 interface=org.freedesktop.hostname1 member=SetHostname cookie=14 reply_cookie=0 signature=sb error-name=n/a error-message=n/a
eth1: Flags change: -LOWER_UP
eth1: Setting MTU done.
eth1: Updating address: 192.168.13.110/24 (valid for 2d)
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_34 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=15 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=16 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
eth1: DHCP error: could not get routes: No data available
Got message type=method_return sender=:1.6 destination=:1.2 path=n/a interface=n/a member=n/a cookie=3 reply_cookie=14 signature=n/a error-name=n/a error-message=n/a
eth1: Flags change: -RUNNING
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_34 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=17 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
eth1: Lost carrier
DHCP CLIENT (0xe616919c): STOPPED
eth1: DHCP lease lost
eth1: Removing address 192.168.13.110
eth1: Setting MTU: 1500
Setting transient hostname: 'n/a'
Sent message type=method_call sender=n/a destination=org.freedesktop.hostname1 path=/org/freedesktop/hostname1 interface=org.freedesktop.hostname1 member=SetHostname cookie=18 reply_cookie=0 signature=sb error-name=n/a error-message=n/a
eth1: Removing address 192.168.13.110
eth1: State is configuring, dropping config
Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=19 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
eth1: Removing address: 192.168.13.110/24 (valid for 2d)
Got message type=method_return sender=:1.6 destination=:1.2 path=n/a interface=n/a member=n/a cookie=4 reply_cookie=18 signature=n/a error-name=n/a error-message=n/a
eth1: Setting MTU done.
eth1: Adding address: fe80::206:d5ff:fe2f:60c2/64 (valid forever)
eth1: Gained IPv6LL
eth1: Discovering IPv6 routers
NDISC: Started IPv6 Router Solicitation client
NDISC: Sent Router Solicitation, next solicitation in 4s
eth1: Flags change: +LOWER_UP +RUNNING

答案1

通过进一步调试,我确定这与 DHCP 服务器传递的 DHCP 选项 26(接口 MTU)设置有关。 Linux 使用默认 MTU 1500,但服务器发送的 MTU 为 1430。

我可以禁用遵循 DHCP 建议的 MTU ( use-mtu: false),或将 DHCP 服务器的 MTU 设置调整为 1500。这可以避免该问题。

为了确认这一点,我注意到该命令sudo ip link set dev eth1 mtu 1430会导致链接断开然后又恢复。

相关内容