我在运行 Ubuntu 20.04 的新 VPS 上遇到间歇性网络问题。大约十分之一的情况是,网络在重新启动后无法启动。
发生这种情况时,服务器似乎正常启动,但我无法通过 ssh 或 http 连接。此外,在邮件日志中,我收到如下错误:“未找到主机或域名。name=gmail.com type=MX 的名称服务错误:找不到主机,请重试”。所以我认为问题是网络未正常启动。
系统日志中存在与网络有关的错误,每次网络启动时都会报告这些错误。然而,大多数时候,网络没有任何问题,所以我不确定它们是否相关。
服务器使用netplan/networkd。这是 /etc/netplan/01-eth0.yaml 的输出:
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
dhcp6: no
addresses:
- 66.175.209.4/24 # Your Linode's public IPv4 address.
- "2600:3c03::f03c:92ff:fe7c:62b6/128" # Primary IPv6 address.
- "2600:3c03:e001:730::/64" # Added by me for unique v6 IP
gateway4: 66.175.209.1 # Primary IPv4 gateway.
gateway6: "fe80::1" # Primary IPv6 gateway.
nameservers:
search: [members.linode.com] # Search domain.
addresses: [66.228.42.5,"2600:3c03::7",96.126.106.5,50.116.53.5] # DNS Server IP addresses.
这是输出networkctl status
- 请注意最后两行的错误:
● State: routable
Address: 66.175.209.4 on eth0
2600:3c03::f03c:92ff:fe7c:62b6 on eth0
2600:3c03:e001:730:: on eth0
fe80::f03c:92ff:fe7c:62b6 on eth0
Gateway: 66.175.209.1 (ICANN, IANA Department) on eth0
fe80::1 (Cisco Systems, Inc) on eth0
DNS: 66.228.42.5
96.126.106.5
50.116.53.5
2600:3c03::7
Search Domains: members.linode.com
Sep 11 03:59:01 eagle systemd-networkd[439]: Enumeration completed
Sep 11 03:59:01 eagle systemd-networkd[439]: eth0: IPv6 successfully enabled
Sep 11 03:59:01 eagle systemd-networkd[439]: eth0: Link UP
Sep 11 03:59:01 eagle systemd-networkd[439]: eth0: Gained carrier
Sep 11 03:59:01 eagle systemd[1]: Started Network Service.
Sep 11 03:59:01 eagle systemd[1]: Starting Wait for Network to be Configured...
Sep 11 03:59:03 eagle systemd-networkd[439]: eth0: Gained IPv6LL
Sep 11 03:59:03 eagle systemd[1]: Finished Wait for Network to be Configured.
Sep 11 03:59:04 eagle systemd-networkd[439]: eth0: Could not set NDisc route or address: Invalid argument
Sep 11 03:59:04 eagle systemd-networkd[439]: eth0: Failed
这是输出networkctl
:
1 lo loopback carrier unmanaged
2 eth0 ether routable failed
2 links listed.
这是输出ip addr
:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether f2:3c:92:7c:62:b6 brd ff:ff:ff:ff:ff:ff
inet 66.175.209.4/24 brd 66.175.209.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 2600:3c03:e001:730::/64 scope global
valid_lft forever preferred_lft forever
inet6 2600:3c03::f03c:92ff:fe7c:62b6/128 scope global
valid_lft forever preferred_lft forever
inet6 fe80::f03c:92ff:fe7c:62b6/64 scope link
valid_lft forever preferred_lft forever
我向 systemd-networkd 添加了调试 - 这是相关输出:
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: Link state is up-to-date
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: found matching network '/run/systemd/network/10-netplan-eth0.network'
Sep 18 05:12:07 eagle systemd-networkd[203638]: Setting '/proc/sys/net/ipv6/conf/eth0/disable_ipv6' to '0'
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: IPv6 successfully enabled
Sep 18 05:12:07 eagle systemd-networkd[203638]: Setting '/proc/sys/net/ipv6/conf/eth0/proxy_ndp' to '0'
Sep 18 05:12:07 eagle systemd-networkd[203638]: Setting '/proc/sys/net/ipv6/conf/eth0/use_tempaddr' to '0'
Sep 18 05:12:07 eagle systemd-networkd[203638]: Setting '/proc/sys/net/ipv6/conf/eth0/accept_ra' to '0'
Sep 18 05:12:07 eagle systemd-networkd[203638]: LLDP: Started LLDP client
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: Started LLDP.
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: Setting address genmode for link
Sep 18 05:12:07 eagle systemd-networkd[203638]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.188 path=n/a interface=n/a member=n/a cookie=1 reply_cookie=1 signature=s error-name=n/a error-messa
ge=n/a
Sep 18 05:12:07 eagle systemd-networkd[203638]: Bus bus-api-network: changing state HELLO → RUNNING
Sep 18 05:12:07 eagle systemd-networkd[203638]: Got message type=signal sender=org.freedesktop.DBus.Local destination=n/a path=/org/freedesktop/DBus/Local interface=org.freedesktop.DBus.Local member=Connected cookie=429496
7295 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a
Sep 18 05:12:07 eagle systemd-networkd[203638]: Got message type=signal sender=org.freedesktop.DBus destination=:1.188 path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameAcquired cookie=2 reply_cookie=0 s
ignature=s error-name=n/a error-message=n/a
Sep 18 05:12:07 eagle systemd-networkd[203638]: Got message type=signal sender=org.freedesktop.DBus destination=:1.188 path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameAcquired cookie=3 reply_cookie=0 s
ignature=s error-name=n/a error-message=n/a
Sep 18 05:12:07 eagle systemd-networkd[203638]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.188 path=n/a interface=n/a member=n/a cookie=4 reply_cookie=2 signature=u error-name=n/a error-messa
ge=n/a
Sep 18 05:12:07 eagle systemd-networkd[203638]: Successfully acquired requested service name.
Sep 18 05:12:07 eagle systemd-networkd[203638]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.188 path=n/a interface=n/a member=n/a cookie=5 reply_cookie=3 signature=n/a error-name=n/a error-mes
sage=n/a
Sep 18 05:12:07 eagle systemd-networkd[203638]: Match type='signal',sender='org.freedesktop.login1',path='/org/freedesktop/login1',interface='org.freedesktop.login1.Manager',member='PrepareForSleep' successfully installed.
Sep 18 05:12:07 eagle systemd-networkd[203638]: lo: Link state is up-to-date
Sep 18 05:12:07 eagle systemd-networkd[203638]: lo: State changed: pending -> unmanaged
Sep 18 05:12:07 eagle systemd-networkd[203638]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_31 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=9 reply_
cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: Setting address genmode done.
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: Removing route: dst: n/a, src: n/a, gw: fe80::1, prefsrc: n/a, scope: global, table: main, proto: static, type: unicast
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: Discovering IPv6 routers
Sep 18 05:12:07 eagle systemd-networkd[203638]: NDISC: Started IPv6 Router Solicitation client
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: State changed: pending -> configuring
Sep 18 05:12:07 eagle systemd-networkd[203638]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=10 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: Setting addresses
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: Forgetting route: dst: n/a, src: n/a, gw: fe80::1, prefsrc: n/a, scope: global, table: main, proto: static, type: unicast
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: Remembering updated address: 66.175.209.4/24 (valid forever)
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: Remembering updated address: 2600:3c03::f03c:92ff:fe7c:62b6/128 (valid forever)
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: Remembering updated address: 2600:3c03:e001:730::/64 (valid forever)
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: Addresses set
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: Configuring route: dst: n/a, src: n/a, gw: fe80::1, prefsrc: n/a, scope: global, table: main, proto: static, type: unicast
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: Configuring route: dst: n/a, src: n/a, gw: 66.175.209.1, prefsrc: n/a, scope: global, table: main, proto: static, type: unicast
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: Setting routes
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: Remembering route: dst: n/a, src: n/a, gw: fe80::1, prefsrc: n/a, scope: global, table: main, proto: static, type: unicast
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: Routes set
Sep 18 05:12:07 eagle systemd-networkd[203638]: eth0: State changed: configuring -> configured
Sep 18 05:12:07 eagle systemd-networkd[203638]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=11 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Sep 18 05:12:08 eagle systemd-networkd[203638]: NDISC: Sent Router Solicitation, next solicitation in 4s
Sep 18 05:12:08 eagle systemd-networkd[203638]: NDISC: Received Router Advertisement: flags none preference medium lifetime 60 sec
Sep 18 05:12:08 eagle systemd-networkd[203638]: NDISC: Invoking callback for 'router' event.
Sep 18 05:12:08 eagle systemd-networkd[203638]: eth0: Configuring route: dst: n/a, src: n/a, gw: fe80::2c09:59ff:fe49:329f, prefsrc: n/a, scope: global, table: main, proto: ra, type: unicast
Sep 18 05:12:08 eagle systemd-networkd[203638]: rtnl: received route message without ifindex, ignoring
Sep 18 05:12:08 eagle systemd-networkd[203638]: eth0: Could not set NDisc route or address: Invalid argument
Sep 18 05:12:08 eagle systemd-networkd[203638]: eth0: Failed
Sep 18 05:12:08 eagle systemd-networkd[203638]: eth0: State changed: configured -> failed
Sep 18 05:12:08 eagle systemd-networkd[203638]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=12 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Sep 18 05:12:08 eagle systemd-networkd[203638]: NDISC: Stopping IPv6 Router Solicitation client
Sep 18 05:12:13 eagle systemd-networkd[203638]: rtnl: received non-static neighbor, ignoring.
Sep 18 05:12:14 eagle systemd-networkd[203638]: rtnl: received non-static neighbor, ignoring.
Sep 18 05:12:14 eagle systemd-networkd[203638]: rtnl: received non-static neighbor, ignoring.
失败之前的行是:rtnl: received route message without ifindex, ignoring
知道这意味着什么/如何解决它?我找不到任何对 ipv6 地址“fe80::2c09:59ff:fe49:329f”的引用。这与 ipv6 网关“fe80::1”有关吗?
我已尝试更改 .yaml 文件,但到目前为止,没有什么可以阻止报告的错误。它们可能是转移注意力的东西,因为无论如何网络通常都会出现。
当网络无法启动时,我可以从内部控制台连接到服务器。当我无法连接时,上面的输出没有任何区别。
如果不是网络问题,还有什么可以解释这个间歇性问题?
答案1
我通过添加修复了错误
accept-ra: no
到 netplan.yaml
配置文件。这将禁用路由器通告,这似乎会导致上述错误。