我的 Ubuntu 18.04 拒绝通过以太网连接到互联网。无论我做什么和尝试什么,我的互联网连接似乎 90% 的时间都无法正常工作,而且我也没有 wifi 适配器。
我尝试了这个解决方案:以太网无法连接(18.04.2)- 并且成功了……一次。之后就再也没有成功过。
顺便说一下,我的以太网电缆插入了另一端的路由器,而路由器使用的是不太可靠的移动 LTE 互联网。我确实尝试了各种设置来修复它,但问题从安装一开始就一直存在——虽然以前互联网有时能用,但最近似乎从来都不能用。
尝试的ping 8.8.8.8
结果是:
connect: Network is unreachable
输入ifconfig -a
结果为:
enp3s4f0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 9c:8e:99:35:15:80 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16
enp3s4f1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::5db5:ba12:c784:52de prefixlen 64 scopeid 0x20<link>
ether 9c:8e:99:35:15:81 txqueuelen 1000 (Ethernet)
RX packets 10 bytes 736 (736.0 B)
RX errors 168 dropped 0 overruns 0 frame 407
TX packets 133 bytes 23931 (23.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 17
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 1373 bytes 97213 (97.2 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1373 bytes 97213 (97.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
输入sudo service networking start
结果如下:
Job for networking.service failed because the control process exited with error code.
See "systemctl status networking.service" and "journalctl -xe" for details.
输入这些命令的结果是:
打字systemctl status networking.service
networking.service - Raise network interfaces
Loaded: loaded (/lib/systemd/system/networking.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-09-08 13:48:04 CEST; 2min 44s ago
Docs: man:interfaces(5)
Process: 2560 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
Process: 2558 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environmen
Main PID: 2560 (code=exited, status=1/FAILURE)
wrz 08 13:48:04 shino-ProLiant-ML310-G5p systemd[1]: Starting Raise network interfaces...
wrz 08 13:48:04 shino-ProLiant-ML310-G5p sh[2558]: /etc/network/interfaces:2: misplaced option
wrz 08 13:48:04 shino-ProLiant-ML310-G5p sh[2558]: ifquery: couldn't read interfaces file "/etc/network/interfac
wrz 08 13:48:04 shino-ProLiant-ML310-G5p ifup[2560]: /etc/network/interfaces:2: misplaced option
wrz 08 13:48:04 shino-ProLiant-ML310-G5p ifup[2560]: /sbin/ifup: couldn't read interfaces file "/etc/network/int
wrz 08 13:48:04 shino-ProLiant-ML310-G5p systemd[1]: networking.service: Main process exited, code=exited, statu
wrz 08 13:48:04 shino-ProLiant-ML310-G5p systemd[1]: networking.service: Failed with result 'exit-code'.
wrz 08 13:48:04 shino-ProLiant-ML310-G5p systemd[1]: Failed to start Raise network interfaces.
~
~
~
~
~
~
~
打字journalctl -xe
wrz 08 14:44:58 shino-ProLiant-ML310-G5p megasync[2307]: gdk_device_update_tool: assertion 'GDK_IS_DEVICE (devic
wrz 08 14:44:58 shino-ProLiant-ML310-G5p upowerd[1066]: unhandled action 'unbind' on /sys/devices/pci0000:00/000
wrz 08 14:44:58 shino-ProLiant-ML310-G5p update-notifier[2305]: gdk_device_update_tool: assertion 'GDK_IS_DEVICE
wrz 08 14:44:58 shino-ProLiant-ML310-G5p gnome-software[2303]: gdk_device_update_tool: assertion 'GDK_IS_DEVICE
wrz 08 14:44:58 shino-ProLiant-ML310-G5p gnome-terminal-[2125]: gdk_device_update_tool: assertion 'GDK_IS_DEVICE
wrz 08 14:44:58 shino-ProLiant-ML310-G5p nautilus-deskto[1837]: gdk_device_update_tool: assertion 'GDK_IS_DEVICE
wrz 08 14:44:58 shino-ProLiant-ML310-G5p gsd-media-keys[1781]: gdk_device_update_tool: assertion 'GDK_IS_DEVICE
wrz 08 14:44:58 shino-ProLiant-ML310-G5p gsd-keyboard[1770]: gdk_device_update_tool: assertion 'GDK_IS_DEVICE (d
wrz 08 14:44:58 shino-ProLiant-ML310-G5p transmission-gt[1834]: gdk_device_update_tool: assertion 'GDK_IS_DEVICE
wrz 08 14:44:58 shino-ProLiant-ML310-G5p gsd-color[1767]: gdk_device_update_tool: assertion 'GDK_IS_DEVICE (devi
wrz 08 14:44:58 shino-ProLiant-ML310-G5p gsd-clipboard[1759]: gdk_device_update_tool: assertion 'GDK_IS_DEVICE (
wrz 08 14:44:58 shino-ProLiant-ML310-G5p gsd-xsettings[1742]: gdk_device_update_tool: assertion 'GDK_IS_DEVICE (
wrz 08 14:44:58 shino-ProLiant-ML310-G5p gsd-power[1724]: gdk_device_update_tool: assertion 'GDK_IS_DEVICE (devi
wrz 08 14:44:58 shino-ProLiant-ML310-G5p /usr/lib/gdm3/gdm-x-session[1163]: (II) UnloadModule: "libinput"
wrz 08 14:44:58 shino-ProLiant-ML310-G5p /usr/lib/gdm3/gdm-x-session[1163]: (II) systemd-logind: releasing fd fo
wrz 08 14:44:58 shino-ProLiant-ML310-G5p gsd-wacom[1743]: gdk_device_update_tool: assertion 'GDK_IS_DEVICE (devi
wrz 08 14:44:58 shino-ProLiant-ML310-G5p gnome-shell[1573]: gdk_device_update_tool: assertion 'GDK_IS_DEVICE (de
wrz 08 14:44:58 shino-ProLiant-ML310-G5p /usr/lib/gdm3/gdm-x-session[1163]: (EE) systemd-logind: failed to relea
wrz 08 14:44:58 shino-ProLiant-ML310-G5p upowerd[1066]: unhandled action 'unbind' on /sys/devices/pci0000:00/000
wrz 08 14:44:58 shino-ProLiant-ML310-G5p upowerd[1066]: unhandled action 'unbind' on /sys/devices/pci0000:00/000
wrz 08 14:44:58 shino-ProLiant-ML310-G5p upowerd[1066]: unhandled action 'unbind' on /sys/devices/pci0000:00/000
wrz 08 14:44:58 shino-ProLiant-ML310-G5p upowerd[1066]: unhandled action 'unbind' on /sys/devices/pci0000:00/000
wrz 08 14:44:58 shino-ProLiant-ML310-G5p upowerd[1066]: unhandled action 'unbind' on /sys/devices/pci0000:00/000
我的 etc/network/interfaces 如下所示:
# interfaces(5) file used by ifup(8) and ifdown(8)
pre-up /usr/sbin/ethtool --change enp3s4f1 speed 100 duplex full autoneg off
顺便说一下,“wrz”是波兰语中“九月”的缩写。
此时我不知道该做什么了,我正在考虑重新安装。
编辑:好的,看起来它确实有时会连接,但只有在启动 Ubuntu 后一段时间(20-30 分钟)才会连接。我不确定这是否与打字有关,sudo modprobe r8169
我现在完全困惑了。
编辑 2 (2019 年 9 月 9 日) 好的,我正在运行 Ubuntu Desktop。有一根以太网电缆直接从我的路由器 TPLINK TL-MR3220 连接到我的计算机。路由器有一个移动 4G LTE 华为调制解调器,通过 USB 直接插入。我没有 wifi 适配器,因此目前无法无线连接。
我注释掉了 /etc/network/interfaces,重新启动并输入sudo lshw -C network
*-network:0
description: Ethernet interface
product: NetXtreme BCM5715 Gigabit Ethernet
vendor: Broadcom Inc. and subsidiaries
physical id: 4
bus info: pci@0000:03:04.0
logical name: enp3s4f0
version: a3
serial: 9c:8e:99:35:15:80
capacity: 1Gbit/s
width: 64 bits
clock: 66MHz
capabilities: pcix pm vpd msi bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=tg3 driverversion=3.137 firmware=5715-v3.29, UMP 1.23 latency=64 link=no mingnt=64 multicast=yes port=twisted pair
resources: irq:32 memory:f9ff0000-f9ffffff memory:f9fe0000-f9feffff
*-network:1
description: Ethernet interface
product: NetXtreme BCM5715 Gigabit Ethernet
vendor: Broadcom Inc. and subsidiaries
physical id: 4.1
bus info: pci@0000:03:04.1
logical name: enp3s4f1
version: a3
serial: 9c:8e:99:35:15:81
size: 10Mbit/s
capacity: 1Gbit/s
width: 64 bits
clock: 66MHz
capabilities: pcix pm vpd msi bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=tg3 driverversion=3.137 duplex=full firmware=5715-v3.29 latency=64 link=yes mingnt=64 multicast=yes port=twisted pair speed=10Mbit/s
resources: irq:33 memory:f9fd0000-f9fdffff memory:f9fc0000-f9fcffff
然后我输入cat /etc/netplan/*.yaml
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
我还检查了内容crontab -e
(没有编辑任何内容),除了注释之外,只有一行:
@reboot dhclient -r eth$ && dhclient eth$
似乎我有时能够在打字后建立连接sudo modprobe r8169
,但它似乎只在某些时候起作用,或者在一段时间后才起作用。
然后输入dhclient enp3s4f1
返回
RTNETLINK answers: Operation not permitted
再次输入sudo
似乎可以成功运行,但什么也没发生。我尝试了另一个以太网端口,结果相同。
编辑 3:拔下电缆,关闭计算机,重新启动,然后重新插入,似乎可以完美且立即地连接一切。
答案1
来自评论...
我检查了你的路由器的规格,它只有 10/100 LAN 端口。你得到的是 10Mb 连接。我怀疑是电缆问题,或者是自动协商问题。试试...
sudo ethtool -s enp3s4f1 speed 100 duplex full autoneg off
sudo dhclient enp3s4f1
然后检查sudo lshw -C network
参数size
,应该是100Mb
。然后ip a
应该显示一个 ipv4 地址。重新启动并确认它仍按预期工作。
另外,编辑您的/etc/network/interfaces
文件并删除...
pre-up /usr/sbin/ethtool --change enp3s4f1 speed 100 duplex full autoneg off
并添加...
auto lo
iface lo inet loopback