问题
我最近将一台 Ubuntu 20.04 服务器搬到了新家,并尝试将其连接到网络。在我以前的家中,通过以太网电缆连接它没有问题,但用我的新调制解调器这样做却不行。在确认以太网电缆适用于我的笔记本电脑后,我开始调试并得出结论,我在 netplan 中配置了一些错误的东西。
尝试解决方案
运行$ ip a
最初产生以下输出:
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: eno1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether f8:b1:56:dc:47:25 brd ff:ff:ff:ff:ff:ff
3: br-cd5031a2a690: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:88:f5:00:c2 brd ff:ff:ff:ff:ff:ff
inet 172.29.0.1/16 brd 172.29.255.255 scope global br-cd5031a2a690
valid_lft forever preferred_lft forever
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:63:c5:ed:bf brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
5: br-6e210ada6a5d: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:cc:35:23:8d brd ff:ff:ff:ff:ff:ff
inet 172.30.0.1/16 brd 172.30.255.255 scope global br-6e210ada6a5d
valid_lft forever preferred_lft forever
inet6 fe80::42:ccff:fe35:238d/64 scope link
valid_lft forever preferred_lft forever
6: br-75e07944c75a: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:cb:38:ca:3c brd ff:ff:ff:ff:ff:ff
inet 172.27.0.1/16 brd 172.27.255.255 scope global br-75e07944c75a
valid_lft forever preferred_lft forever
inet6 fe80::42:cbff:fe38:ca3c/64 scope link
valid_lft forever preferred_lft forever
8: veth5501abf@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-6e210ada6a5d state UP group default
link/ether 3e:9d:7d:bc:07:5f brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet6 fe80::3c9d:7dff:febc:75f/64 scope link
valid_lft forever preferred_lft forever
10: veth5f8842d@if9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-75e07944c75a state UP group default
link/ether f2:f4:e9:50:51:ac brd ff:ff:ff:ff:ff:ff link-netnsid 3
inet6 fe80::f0f4:e9ff:fe50:51ac/64 scope link
valid_lft forever preferred_lft forever
12: veth6164405@if11: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-6e210ada6a5d state UP group default
link/ether 5e:f2:e1:fd:1f:4d brd ff:ff:ff:ff:ff:ff link-netnsid 2
inet6 fe80::5cf2:e1ff:fefd:1f4d/64 scope link
valid_lft forever preferred_lft forever
14: veth8f9aa5b@if13: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-6e210ada6a5d state UP group default
link/ether 46:c8:0b:f7:c5:ac brd ff:ff:ff:ff:ff:ff link-netnsid 1
inet6 fe80::44c8:bff:fef7:c5ac/64 scope link
valid_lft forever preferred_lft forever
16: vethc256b04@if15: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-75e07944c75a state UP group default
link/ether b6:7c:3e:1e:ec:7e brd ff:ff:ff:ff:ff:ff link-netnsid 1
inet6 fe80::b47c:3eff:fe1e:ec7e/64 scope link
valid_lft forever preferred_lft forever
这向我表明这eno1
是我需要修复的接口;所有桥接器和 veth 接口可能都来自我运行的 Docker 容器。
然后,我将01-netcfg.yaml
文件设置为以下推荐配置,以建立与动态 DHCP 分配 IP 的连接:
network:
version: 2
renderer: networkd
ethernets:
eno1:
dhcp4: true
并运行以下命令:
$ sudo netplan --debug generate
$ sudo netplan apply
$ sudo reboot
‘generate’命令的调试输出结果如下:
** (generate:4699): DEBUG: 04:02:19.020: Processing input file /etc/netplan/01-netcfg.yaml..
** (generate:4699): DEBUG: 04:02:19.021: starting new processing pass
** (generate:4699): DEBUG: 04:02:19.021: We have some netdefs, pass them through a final round of validation
** (generate:4699): DEBUG: 04:02:19.021: eno1: setting default backend to 1
** (generate:4699): DEBUG: 04:02:19.021: Configuration is valid
** (generate:4699): DEBUG: 04:02:19.021: Generating output files..
** (generate:4699): DEBUG: 04:02:19.021: NetworkManager: definition eno1 is not for us (backend 1)
(generate:4699): GLib-DEBUG: 04:02:19.021: posix_spawn avoided (fd close requested)
这NetworkManager: definition eno1 is not for us
似乎是一个问题,重新启动后我仍然无法 ping 任何东西:
$ ping 8.8.8.8
ping: connect: Network is unreachable
我使用这个推荐的配置重复了上述步骤01-netcfg.yaml
,并确认我使用的是空格而不是制表符,并且我的间距是正确的:
network:
version: 2
renderer: networkd
使用调试标志运行相同的设置命令将产生以下输出:
** (generate:5041): DEBUG: 04:09:33.721: Processing input file /etc/netplan/01-netcfg.yaml..
** (generate:5041): DEBUG: 04:09:33.721: starting new processing pass
** (generate:5041): DEBUG: 04:09:33.721: We have some netdefs, pass them through a final round of validation
** (generate:5041): DEBUG: 04:09:33.721: Generating output files..
(generate:5041): GLib-DEBUG: 04:09:33.721: posix_spawn avoided (fd close requested)
它不再有相关NetworkManager: definition eno1 is not for us
消息(因为eno1
没有指定),但是在应用这些生成的更改并重新启动后,我仍然无法连接。
我关注了许多帖子和指南,它们似乎推荐了这两种配置的变体,但我坚信有一个与我遇到的问题相同的配置是这个帖子。
这里,发帖人指出,部分问题来自内核 5.4.0-42-generic 中的一个错误,通过安装r8168-dkms
驱动程序解决了该问题。我也在运行内核 5.4.0-42-generic,并手动安装了此驱动程序/更新了 initramfs,但在重新启动并重试上述两个 netplan 配置后仍然没有成功。
$ sudo lshw -class network
此外,如果有帮助的话,这是我运行后的输出:
*-network
description: Ethernet interface
product: 82579LM Gigabit Network Connection (Lewisville)
vendor: Intel Corporation
physical id: 19
bus info: pci@0000:00:19.0
logical name: eno1
version: 04
serial: f8:b1:56:dc:47:25
capacity: 1Gbit/s
width: 32 bits
clock: 33MHz
capabilities: pm msi bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=e1000e driverversion=3.2.6-k firmware=0.13-4 latency=0 link=no multicast=yes port=twisted pair
resources: irq:25 memory:f7c00000-f7c1ffff memory:f7c39000-f7c39fff ioport:f080(size=32)
*-network:0
description: Ethernet interface
physical id: 1
logical name: br-75e07944c75a
serial: 02:42:cb:38:ca:3c
capabilities: ethernet physical
configuration: broadcast=yes driver=bridge driverversion=2.3 firmware=N/A ip=172.27.0.1 link=yes multicast=yes
*-network:1
description: Ethernet interface
physical id: 2
logical name: veth5f8842d
serial: f2:f4:e9:50:51:ac
size: 10Gbit/s
capabilities: ethernet physical
configuration: autonegotiation=off broadcast=yes driver=veth driverversion=1.0 duplex=full link=yes multicast=yes port=twisted pair speed=10Gbit/s
*-network:2
description: Ethernet interface
physical id: 3
logical name: vethc256b04
serial: b6:7c:3e:1e:ec:7e
size: 10Gbit/s
capabilities: ethernet physical
configuration: autonegotiation=off broadcast=yes driver=veth driverversion=1.0 duplex=full link=yes multicast=yes port=twisted pair speed=10Gbit/s
*-network:3
description: Ethernet interface
physical id: 4
logical name: br-6e210ada6a5d
serial: 02:42:cc:35:23:8d
capabilities: ethernet physical
configuration: broadcast=yes driver=bridge driverversion=2.3 firmware=N/A ip=172.30.0.1 link=yes multicast=yes
*-network:4
description: Ethernet interface
physical id: 5
logical name: veth5501abf
serial: 3e:9d:7d:bc:07:5f
size: 10Gbit/s
capabilities: ethernet physical
configuration: autonegotiation=off broadcast=yes driver=veth driverversion=1.0 duplex=full link=yes multicast=yes port=twisted pair speed=10Gbit/s
*-network:5
description: Ethernet interface
physical id: 6
logical name: br-cd5031a2a690
serial: 02:42:88:f5:00:c2
capabilities: ethernet physical
configuration: broadcast=yes driver=bridge driverversion=2.3 firmware=N/A ip=172.29.0.1 link=no multicast=yes
*-network:6
description: Ethernet interface
physical id: 7
logical name: docker0
serial: 02:42:63:c5:ed:bf
capabilities: ethernet physical
configuration: broadcast=yes driver=bridge driverversion=2.3 firmware=N/A ip=172.17.0.1 link=no multicast=yes
*-network:7
description: Ethernet interface
physical id: 8
logical name: veth6164405
serial: 5e:f2:e1:fd:1f:4d
size: 10Gbit/s
capabilities: ethernet physical
configuration: autonegotiation=off broadcast=yes driver=veth driverversion=1.0 duplex=full link=yes multicast=yes port=twisted pair speed=10Gbit/s
*-network:8
description: Ethernet interface
physical id: 9
logical name: veth8f9aa5b
serial: 46:c8:0b:f7:c5:ac
size: 10Gbit/s
capabilities: ethernet physical
configuration: autonegotiation=off broadcast=yes driver=veth driverversion=1.0 duplex=full link=yes multicast=yes port=twisted pair speed=10Gbit/s
要求
有人能帮我修复 Netplan 的问题,让我的服务器上的以太网重新工作吗?非常感谢您的帮助,如果您需要我提供任何其他信息,请随时询问 :)
答案1
显示的输出NetworkManager: definition eno1 is not for us
是正确的;它只是告诉你这个接口是由后端处理的,networkd
而不是NetworkManager
由那个接口处理的。当你从 yaml 中删除对 的引用时eno1
,你告诉 netplan 不要配置任何接口,这不是你想要的。
并且您的ip a
输出显示eno1
接口被列为NO-CARRIER
。这通常表示您的硬件能够进行链接检测,并且在这种情况下检测到没有链接。因此,您可能需要尝试不同的以太网电缆,验证电缆是否安装到位,并尝试连接到调制解调器以外的设备以检查这不是调制解调器问题。