Arch-Linux

從 Win 10 重新啟動到 Linux 後,eth 網路沒有連接

  • April 30, 2021

我正在雙啟動 Win 10 和 EndeavourOS。不知何故,Windows 確實弄亂了我的網卡,因此在啟動 Linux 時我無法訪問網路。當我第一次遇到這個問題時,我重新安裝了 EndeavourOS,它又可以正常工作了。但直到下一次 Windows 啟動和連續的 Linux 再次啟動。

從 EndeavourOS live usb 棒啟動時,NIC 也可以正常工作。

那是網卡:

[me@pc ~]$ /usr/bin/lspci | /bin/egrep -i 'network|ethernet'
01:00.1 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 1a)

我發現很多相當老的執行緒建議關閉 Win 10 中的各種區域網路喚醒和其他電源設置,嘗試了所有但無濟於事。

有趣的是,網卡似乎確實通過 DHCP 獲得了正確的 IP 地址。

登錄到 KDE 後,nic 似乎記住了它的最後一個 DHCP 配置:

[me@pc ~]$ 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: enp1s0f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
   link/ether e0:4f:43:e8:12:e3 brd ff:ff:ff:ff:ff:ff
   inet 192.168.99.10/24 brd 192.168.99.255 scope global dynamic noprefixroute enp1s0f1
      valid_lft 43007sec preferred_lft 43007sec
   inet6 fe80::48e3:71dd:df1b:797b/64 scope link noprefixroute 
      valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
   link/ether 9a:11:4e:51:2b:86 brd ff:ff:ff:ff:ff:ff permaddr 9c:fc:e8:dd:b1:2f

但是,沒有連接到網路:

[me@pc ~]$ ping 192.168.99.10
PING 192.168.99.10 (192.168.99.10) 56(84) bytes of data.
64 bytes from 192.168.99.10: icmp_seq=1 ttl=64 time=0.031 ms
64 bytes from 192.168.99.10: icmp_seq=2 ttl=64 time=0.058 ms
64 bytes from 192.168.99.10: icmp_seq=3 ttl=64 time=0.057 ms
^C
--- 192.168.99.10 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2053ms
rtt min/avg/max/mdev = 0.031/0.048/0.058/0.012 ms

[me@pc ~]$ ping 192.168.99.1
PING 192.168.99.1 (192.168.99.1) 56(84) bytes of data.
From 192.168.99.10 icmp_seq=1 Destination Host Unreachable
From 192.168.99.10 icmp_seq=2 Destination Host Unreachable
From 192.168.99.10 icmp_seq=3 Destination Host Unreachable
^C
--- 192.168.99.1 ping statistics ---
6 packets transmitted, 0 received, +3 errors, 100% packet loss, time 5226ms
pipe 3
[me@pc ~]$ sudo dmesg | grep r8168
[    6.133867] r8168: loading out-of-tree module taints kernel.
[    6.242244] r8168: module verification failed: signature and/or required key missing - tainting kernel
[    6.244316] r8168 Gigabit Ethernet driver 8.048.03-NAPI loaded
[    6.262759] r8168: This product is covered by one or more of the following patents: US6,570,884, US6,115,776, and US6,327,625.
[    6.264779] r8168  Copyright (C) 2020  Realtek NIC software team <nicfae@realtek.com> 
[    6.512649] r8168 0000:01:00.1 enp1s0f1: renamed from eth0
[   10.578772] r8168: enp1s0f1: link up

我還嘗試切換到稍舊版本的 r8168 模組(lts),但無濟於事。

我記得它可以工作,在 Windows 和 Linux 之間來回切換,但此時只有重新安裝似乎有幫助。我當然想規避。即使這意味著在啟動或其他黑客攻擊期間以某種方式重置網卡。

編輯

新證據:

我通過 NetworkManager 手動配置了網卡,現在它不斷斷開並再次連接:

Apr 13 10:40:27 pc NetworkManager[487]: <info>  [1618303227.2299] manager: NetworkManager state is now CONNECTING
Apr 13 10:40:27 pc NetworkManager[487]: <info>  [1618303227.2513] device (enp1s0f1): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Apr 13 10:40:27 pc NetworkManager[487]: <info>  [1618303227.2520] device (enp1s0f1): state change: config -> ip-config (reason 'none', sys-iface-state: 'managed')
Apr 13 10:40:27 pc NetworkManager[487]: <info>  [1618303227.2546] device (enp1s0f1): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')
Apr 13 10:40:27 pc NetworkManager[487]: <info>  [1618303227.2587] device (enp1s0f1): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
Apr 13 10:40:27 pc NetworkManager[487]: <info>  [1618303227.2589] device (enp1s0f1): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
Apr 13 10:40:27 pc NetworkManager[487]: <info>  [1618303227.2596] manager: NetworkManager state is now CONNECTED_LOCAL
Apr 13 10:40:27 pc NetworkManager[487]: <info>  [1618303227.2605] manager: NetworkManager state is now CONNECTED_SITE
Apr 13 10:40:27 pc NetworkManager[487]: <info>  [1618303227.2607] policy: set 'Wired connection 1' (enp1s0f1) as default for IPv4 routing and DNS
Apr 13 10:40:27 pc NetworkManager[487]: <info>  [1618303227.2640] device (enp1s0f1): Activation: successful, device activated.
Apr 13 10:40:35 pc NetworkManager[487]: <info>  [1618303235.3135] device (enp1s0f1): carrier: link connected
Apr 13 10:40:35 pc NetworkManager[487]: <info>  [1618303235.3142] device (enp1s0f1): state change: activated -> unavailable (reason 'carrier-changed', sys-iface-state: 'managed')
Apr 13 10:40:35 pc NetworkManager[487]: <info>  [1618303235.3667] manager: NetworkManager state is now CONNECTED_LOCAL
Apr 13 10:40:35 pc NetworkManager[487]: <info>  [1618303235.3678] manager: NetworkManager state is now DISCONNECTED
Apr 13 10:40:40 pc NetworkManager[487]: <info>  [1618303240.3191] device (enp1s0f1): state change: unavailable -> disconnected (reason 'none', sys-iface-state: 'managed')
Apr 13 10:40:40 pc NetworkManager[487]: <info>  [1618303240.3223] policy: auto-activating connection 'Wired connection 1' (e76e5718-9a47-3733-818b-30aaa862bcf4)
Apr 13 10:40:40 pc NetworkManager[487]: <info>  [1618303240.3235] device (enp1s0f1): Activation: starting connection 'Wired connection 1' (e76e5718-9a47-3733-818b-30aaa862bcf4)
Apr 13 10:40:40 pc NetworkManager[487]: <info>  [1618303240.3238] device (enp1s0f1): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Apr 13 10:40:40 pc NetworkManager[487]: <info>  [1618303240.3247] manager: NetworkManager state is now CONNECTING
...start all over

所以 nic 本身現在正在工作,但只是在一定程度上:

[me@pc ~]$ ping 192.168.99.1
PING 192.168.99.1 (192.168.99.1) 56(84) bytes of data.
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
From 192.168.99.8 icmp_seq=12 Destination Host Unreachable
From 192.168.99.8 icmp_seq=13 Destination Host Unreachable
From 192.168.99.8 icmp_seq=14 Destination Host Unreachable
64 bytes from 192.168.99.1: icmp_seq=15 ttl=64 time=1.65 ms
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable
ping: sendmsg: Network is unreachable

回答我自己的問題。

由於我放棄了 Windows 10 以支持在 VM 中執行它,我認為我沒有解決這個問題,而是繞過了它。但今天同樣的症狀又開始了。經過一些探勘和嘗試不同的 DHCP 客戶端而不是 NetworkManager 的內置客戶端后,我終於找到了為我的 NIC 使用另一個驅動程序的解決方案。

# rmmod r8168

# modprobe r8169

我的乙太網又好了。

堅持通過

# echo blacklist r8168 > /etc/modprobe.d/r8168.conf
# echo r8169 > /etc/modules-load.d/r8169.conf

以這種方式命名 r8168.conf 對於覆蓋 /usr/lib/modprobe.d/r8168.conf 中提供的軟體包配置至關重要。

引用自:https://unix.stackexchange.com/questions/644760