我这周过得很糟糕,一直在尝试解决以太网连接问题。以太网正常工作了一分钟,然后就断开了连接。顶部的网络图标一直显示已连接,但我必须通过单击“有线连接 1”断开连接并重新连接,才能保持几秒钟/几分钟的连接。
为了解决这个问题,我每分钟运行一次 cron 作业来断开连接并重新连接,代码如下:
#!/bin/bash
sudo ifdown enp4s0
sudo ifup enp4s0
请帮忙。我需要一个更持久的解决方案来实现稳定的以太网连接。
lspci | grep -i realtek
04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd.
RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 01)
lsmod | grep r816
r8168 499712 0
dmesg | grep r816
[ 2.207551] r8168: loading out-of-tree module taints kernel.
[ 2.207789] r8168: module verification failed: signature and/or required key missing - tainting kernel
[ 2.208146] r8168 Gigabit Ethernet driver 8.044.02-NAPI loaded
[ 2.208243] r8168 0000:04:00.0: Default use INTx.
[ 2.230190] r8168: This product is covered by one or more of the following patents: US6,570,884, US6,115,776, and US6,327,625.
[ 2.230194] r8168 Copyright (C) 2017 Realtek NIC software team <[email protected]>
[ 2.305436] r8168 0000:04:00.0 enp4s0: renamed from eth0
[ 23.483150] r8168: enp4s0: link up
[ 866.740512] r8168: enp4s0: link up
[71714.965195] r8168: enp4s0: link up
[71773.494292] r8168: enp4s0: link up
sudo ethtool enp4s0
Settings for enp4s0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: Unknown!
Duplex: Half
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
MDI-X: Unknown
Supports Wake-on: pumbg
Wake-on: ug
Current message level: 0x00000033 (51)
drv probe ifdown ifup
Link detected: no
ifconfig
enp4s0 Link encap:Ethernet HWaddr 00:26:18:11:78:a8
inet addr:192.168.26.30 Bcast:192.168.27.255 Mask:255.255.254.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:394947 errors:0 dropped:0 overruns:0 frame:0
TX packets:278710 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:270000748 (270.0 MB) TX bytes:37833932 (37.8 MB)
Interrupt:18 Base address:0xa000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:38302 errors:0 dropped:0 overruns:0 frame:0
TX packets:38302 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:3045435 (3.0 MB) TX bytes:3045435 (3.0 MB)
lshw
*-network
description: Ethernet interface
product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
vendor: Realtek Semiconductor Co., Ltd.
physical id: 0
bus info: pci@0000:04:00.0
logical name: enp4s0
version: 01
serial: 00:26:18:11:78:a8
size: 1Gbit/s
capacity: 1Gbit/s
width: 64 bits
clock: 33MHz
capabilities: bus_master cap_list rom ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=r8168 driverversion=8.044.02-NAPI duplex=full latency=0 link=yes multicast=yes port=twisted pair speed=1Gbit/s
resources: irq:18 ioport:d800(size=256) memory:f9fff000-f9ffffff memory:f9fc0000-f9fdffff
cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto enp4s0
allow-hotplug enp4s0
iface enp4s0 inet dhcp
pre-up ifconfig enp4s0 hw ether 00:26:18:11:78:A8
cat /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq
[ifupdown]
managed=true
uname -r
4.8.0-58-generic
我做过的事情:
1) 使用 Synaptic 安装 r8168-dkms。2
) 将 IPv6 设置“方法”部分设置为“忽略”。3
) 将我的 Internet DNS 服务器更改为 8.8.8.8、8.8.4.4...等。4
) 将“MTU”更改为 9000。5
) 将接口文件更改为:auto lo iface lo inet loopback auto enp4s0 iface enp4s0 inet dhcp
以及静态。
)sudo apt-get purge r8168-dkms 来自Ubuntu 14.04 有线连接不断断开
7)一切https://unixblogger.com/2011/10/18/the-pain-of-an-realtek-rtl8111rtl8168-ethernet-card/
8)安装旧版本的r8168,然后:
sudo update-initramfs -u
echo "blacklist r8169" | sudo tee -a /etc/modprobe.d/blacklist.conf
9)阅读https://ubuntuforumsdot org/archive/index.php/t-2291730.html
10)https://ubuntuforums 上的所有内容 dot org/showthread.php?t=2248047
11)冷启动。12
)
sudo sh -c "echo 'net.ipv6.conf.all.disable_ipv6 = 1' >> /etc/sysctl.conf"
sudo sh -c "echo 'net.ipv6.conf.default.disable_ipv6 = 1' >> /etc/sysctl.conf"
sudo sh -c "echo 'net.ipv6.conf.lo.disable_ipv6 = 1' >> /etc/sysctl.conf"
sudo sysctl -p
sudo sed -i 's/false/true/g' /etc/NetworkManager/NetworkManager.conf
sudo reboot -i NOW
13)https://nosemaj dot org/hardy-r8168
14)用其他设备测试以太网电缆。15
)哭。16
)问我妈妈。
更新 #1
dkms status
bbswitch, 0.8, 4.8.0-36-generic, x86_64: installed
bbswitch, 0.8, 4.8.0-58-generic, x86_64: installed
nvidia-375, 375.66, 4.8.0-36-generic, x86_64: installed
nvidia-375, 375.66, 4.8.0-58-generic, x86_64: installed
r8168, 8.041.00: added
modinfo r8168 | grep -i version
version: 8.044.02-NAPI
srcversion: 5388F61A23A68A548D001CF
vermagic: 4.8.0-58-generic SMP mod_unload modversions
sudo apt-get purge r8168-dkms
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
r8168-dkms*
0 upgraded, 0 newly installed, 1 to remove and 13 not upgraded.
After this operation, 1,109 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 243432 files and directories currently installed.)
Removing r8168-dkms (8.041.00-1) ...
------------------------------
Deleting module version: 8.041.00
completely from the DKMS tree.
------------------------------
Done.
Purging configuration files for r8168-dkms (8.041.00-1) ...
要删除的命令:
sudo apt-get remove r8168-dkms
sudo apt-get purge r8168-dkms
sudo /sbin/modprobe -r r8168
这些命令都没有删除 8.044。
更新 #2
dkms status
bbswitch, 0.8, 4.8.0-36-generic, x86_64: installed
bbswitch, 0.8, 4.8.0-58-generic, x86_64: installed
nvidia-375, 375.66, 4.8.0-36-generic, x86_64: installed
nvidia-375, 375.66, 4.8.0-58-generic, x86_64: installed
r8168, 8.041.00: added
sudo dkms build r8168/8.041.00 -k "$(uname -r)/$(uname -p)"
Kernel preparation unnecessary for this kernel. Skipping...
Building module:
cleaning build area....
make KERNELRELEASE=4.8.0-58-generic -C /lib/modules/4.8.0-58-generic/build M=/var/lib/dkms/r8168/8.041.00/build....(bad exit status: 2)
ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/r8168-dkms.0.crash'
Error! Bad return status for module build on kernel: 4.8.0-58-generic (x86_64)
Consult /var/lib/dkms/r8168/8.041.00/build/make.log for more information.
cat /var/lib/dkms/r8168/8.041.00/build/make.log
DKMS make.log for r8168-8.041.00 for kernel 4.8.0-58-generic (x86_64)
Tue Jul 11 16:03:35 AST 2017
make: Entering directory '/usr/src/linux-headers-4.8.0-58-generic'
LD /var/lib/dkms/r8168/8.041.00/build/built-in.o
CC [M] /var/lib/dkms/r8168/8.041.00/build/r8168_n.o
/var/lib/dkms/r8168/8.041.00/build/r8168_n.c: In function ‘rtl8168_fix_features’:
/var/lib/dkms/r8168/8.041.00/build/r8168_n.c:4212:30: error: ‘NETIF_F_ALL_CSUM’ undeclared (first use in this function)
features &= ~NETIF_F_ALL_CSUM;
^
/var/lib/dkms/r8168/8.041.00/build/r8168_n.c:4212:30: note: each undeclared identifier is reported only once for each function it appears in
/var/lib/dkms/r8168/8.041.00/build/r8168_n.c: In function ‘rtl8168_start_xmit’:
/var/lib/dkms/r8168/8.041.00/build/r8168_n.c:24599:12: error: ‘struct net_device’ has no member named ‘trans_start’
dev->trans_start = jiffies;
^
scripts/Makefile.build:289: recipe for target '/var/lib/dkms/r8168/8.041.00/build/r8168_n.o' failed
make[1]: *** [/var/lib/dkms/r8168/8.041.00/build/r8168_n.o] Error 1
Makefile:1491: recipe for target '_module_/var/lib/dkms/r8168/8.041.00/build' failed
make: *** [_module_/var/lib/dkms/r8168/8.041.00/build] Error 2
make: Leaving directory '/usr/src/linux-headers-4.8.0-58-generic'
更新 #3
尝试使用 r8168 V 8.042 并失败后...我尝试了版本 8.043.02 并取得了一定成功,尽管我们还没有找到最终的解决方案。
sudo dkms build r8168/8.043.02 -k "$(uname -r)/$(uname -p)"
Module r8168/8.043.02 already built for kernel 4.8.0-58-generic/4
sudo dkms install r8168/8.043.02 -k "$(uname -r)/$(uname -p)"
Module r8168/8.043.02 already installed on kernel 4.8.0-58-generic/x86_64
dkms status
bbswitch, 0.8, 4.8.0-58-generic, x86_64: installed
nvidia-375, 375.66, 4.8.0-58-generic, x86_64: installed
r8168, 8.043.02, 4.8.0-58-generic, x86_64: installed (WARNING! Diff between built and installed module!)
更新 #4
ls -al /var/lib/dkms/r8168
total 12
drwxr-xr-x 3 root root 4096 Jul 11 16:43 .
drwxr-xr-x 5 root root 4096 Jul 11 16:42 ..
drwxr-xr-x 4 root root 4096 Jul 11 16:43 8.043.02
lrwxrwxrwx 1 root root 32 Jul 11 16:43 kernel-4.8.0-58-generic-x86_64 -> 8.043.02/4.8.0-58-generic/x86_64
modinfo r8168 | grep -i version
version: 8.044.02-NAPI
srcversion: 5388F61A23A68A548D001CF
vermagic: 4.8.0-58-generic SMP mod_unload modversions
ls -al /lib/modules/4.8.0-58-generic/updates/dkms
total 18624
drwxr-xr-x 2 root root 4096 Jul 1 11:01 .
drwxr-xr-x 3 root root 4096 Jul 1 11:00 ..
-rw-r--r-- 1 root root 22720 Jul 1 11:00 bbswitch.ko
-rw-r--r-- 1 root root 85488 Jul 1 11:01 nvidia_375_drm.ko
-rw-r--r-- 1 root root 16735368 Jul 1 11:01 nvidia_375.ko
-rw-r--r-- 1 root root 1086360 Jul 1 11:01 nvidia_375_modeset.ko
-rw-r--r-- 1 root root 1124728 Jul 1 11:01 nvidia_375_uvm.ko
modinfo /lib/modules/4.8.0-58-generic/updates/dkms/r8168.ko
modinfo: ERROR: Module /lib/modules/4.8.0-58-generic/updates/dkms/r8168.ko not found.
更新 5
看起来好像这个命令删除了 8.044 驱动程序,现在只剩下 8.043.02 驱动程序。
sudo apt-get -y dist-upgrade
答案1
来自评论...
你真的做需要在你的配置中运行 r8168-dkms
撤消你所做的所有更改...都没有解决问题,反而产生了新的问题
经过仔细检查,我发现您正在为 Ubuntu 17.10(在 16.04 系统上)使用 r8168-dkms (8.044.02-NAPI)。请安装正确的版本并重新测试。
在您的网络 GUI 中,您设置了多个“有线连接”配置文件。它们将被命名为有线连接、有线连接 1、有线连接 2 等。删除除有线连接之外的所有配置文件。
更新#1:
假设当前状态dkms status
显示r8168, 8.041.00 : added
...
sudo dkms build r8168/8.041.00 -k "$(uname -r)/$(uname -p)"
sudo dkms install r8168/8.041.00 -k "$(uname -r)/$(uname -p)"
注意:您可能需要确认正确的值r8168/8.041.00(模块/版本)通过查看/usr/src
或/var/lib/dkms/r8168
。
dkms status
應該顯示r8168, 8.041.0 installed
。
reboot
modinfo r8168 | grep -i version
应该说8.041.00
。
更新 #2:
- r8168 v8.041.00 对于 16.04.2(内核 4.8.0-58)来说太旧了
- 我们现在使用的是 r8168 v8.043.02
更新 #3:
我们将彻底删除 r8168-dkms 并取消将 r8169 列入黑名单,然后从 Ubuntu 存储库重新安装 r8168-dkms。
sudo dkms remove r8168/8.043.02 -k "$(uname -r)/$(uname -p)"
sudo apt-get purge r8168-dkms
cd /var/lib/dkms
ls -al
- 不应显示 r8168
cd /usr/src
ls -al
- 不应显示 r8168.043.02
find /lib -name r8168.ko
- 不应显示 r8168.ko
cd /etc/modprobe.d
ls -al r8168*
- 不应显示任何文件
grep -i r816 *
- 将 grep 的输出编辑为问题作为更新 #n
cd
sudo modprobe -r r8168
sudo update-initramfs -u -k "$(uname -r)"
- 到此为止,通过 @heynnema 与我联系