Ubuntu 20.04 中以太网电缆被拔掉,但在 Windows 中却可以正常工作

Ubuntu 20.04 中以太网电缆被拔掉,但在 Windows 中却可以正常工作

抱歉,但我根本不是 Linux 专家。

我刚买了一块新主板;华硕 ROG Strix B550-f Gaming(Wifi),我在 Ubuntu 20.04 中遇到了 wifi 和以太网问题。我的机器上同时安装了 Ubuntu 和 Windows,在 Windows 中一切都运行正常。

我刚刚在 BIOS 中禁用了快速启动,启动到 Windows,重新启动并启动到 Ubuntu,现在 Wifi 似乎可以正常工作了。虽然它看起来非常随机。

我也尝试过各种方法让以太网工作,但 90% 的时间我都处于“电缆拔出”状态。但有时它能工作,这很奇怪。以下是一些调试值

❯ uname -sr
Linux 5.4.0-53-generic
❯ ifconfig   
br-ac361f0ce01c: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.49.1  netmask 255.255.255.0  broadcast 192.168.49.255
        ether 02:42:f6:16:5e:18  txqueuelen 0  (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

br-c6025e770d8b: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.23.0.1  netmask 255.255.0.0  broadcast 172.23.255.255
        inet6 fe80::42:38ff:fe34:66b3  prefixlen 64  scopeid 0x20<link>
        ether 02:42:38:34:66:b3  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 188  bytes 28806 (28.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:11:c5:bc:8d  txqueuelen 0  (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

enp6s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 24:4b:fe:5b:75:e9  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 memory 0xfc200000-fc2fffff  

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 1986  bytes 192527 (192.5 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1986  bytes 192527 (192.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth6cf3b52: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::50fe:f9ff:fee2:8d22  prefixlen 64  scopeid 0x20<link>
        ether 52:fe:f9:e2:8d:22  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 234  bytes 34831 (34.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp5s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.9.127  netmask 255.255.255.0  broadcast 192.168.9.255
        inet6 fe80::da03:df99:d9b4:2c69  prefixlen 64  scopeid 0x20<link>
        ether a8:7e:ea:33:04:eb  txqueuelen 1000  (Ethernet)
        RX packets 319841  bytes 465543077 (465.5 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 45130  bytes 6174880 (6.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
❯ dmesg | grep eth
[    1.168629] igc 0000:06:00.0 eth0: MAC: 24:4b:fe:5b:75:e9
[    1.169098] igc 0000:06:00.0 enp6s0: renamed from eth0
[   14.753497] br-c6025e770d8b: port 1(veth6cf3b52) entered blocking state
[   14.753500] br-c6025e770d8b: port 1(veth6cf3b52) entered disabled state
[   14.753579] device veth6cf3b52 entered promiscuous mode
[   14.753705] br-c6025e770d8b: port 1(veth6cf3b52) entered blocking state
[   14.753706] br-c6025e770d8b: port 1(veth6cf3b52) entered forwarding state
[   14.754075] br-c6025e770d8b: port 1(veth6cf3b52) entered disabled state
[   14.999187] eth0: renamed from vethd33a5f6
[   15.035135] IPv6: ADDRCONF(NETDEV_CHANGE): veth6cf3b52: link becomes ready
[   15.035175] br-c6025e770d8b: port 1(veth6cf3b52) entered blocking state
[   15.035176] br-c6025e770d8b: port 1(veth6cf3b52) entered forwarding state
❯ sudo lshw -c network                             
  *-network                 
       description: Wireless interface
       product: Wi-Fi 6 AX200
       vendor: Intel Corporation
       physical id: 0
       bus info: pci@0000:05:00.0
       logical name: wlp5s0
       version: 1a
       serial: a8:7e:ea:33:04:eb
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix bus_master cap_list ethernet physical wireless
       configuration: broadcast=yes driver=iwlwifi driverversion=5.4.0-53-generic firmware=48.4fa0041f.0 ip=192.168.9.127 latency=0 link=yes multicast=yes wireless=IEEE 802.11
       resources: irq:33 memory:fc400000-fc403fff
  *-network
       description: Ethernet interface
       product: Intel Corporation
       vendor: Intel Corporation
       physical id: 0
       bus info: pci@0000:06:00.0
       logical name: enp6s0
       version: 02
       serial: 24:4b:fe:5b:75:e9
       capacity: 1Gbit/s
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi msix pciexpress bus_master cap_list ethernet physical 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=igc driverversion=0.0.1-k latency=0 link=no multicast=yes port=twisted pair
       resources: irq:37 memory:fc200000-fc2fffff memory:fc300000-fc303fff
  *-network:0
       description: Ethernet interface
       physical id: 1
       logical name: docker0
       serial: 02:42:11:c5:bc:8d
       capabilities: ethernet physical
       configuration: broadcast=yes driver=bridge driverversion=2.3 firmware=N/A ip=172.17.0.1 link=no multicast=yes
  *-network:1
       description: Ethernet interface
       physical id: 2
       logical name: veth6cf3b52
       serial: 52:fe:f9:e2:8d:22
       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: br-c6025e770d8b
       serial: 02:42:38:34:66:b3
       capabilities: ethernet physical
       configuration: broadcast=yes driver=bridge driverversion=2.3 firmware=N/A ip=172.23.0.1 link=yes multicast=yes
  *-network:3
       description: Ethernet interface
       physical id: 4
       logical name: br-ac361f0ce01c
       serial: 02:42:f6:16:5e:18
       capabilities: ethernet physical
       configuration: broadcast=yes driver=bridge driverversion=2.3 firmware=N/A ip=192.168.49.1 link=no multicast=yes
❯ cat /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=false

[device]
wifi.scan-rand-mac-address=no
❯ cat /etc/resolv.conf                       
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad

我希望有人能发现问题所在。我还尝试手动设置 DHCP、网络掩码和网关。

更新 1

我刚试过

❯ sudo ifconfig enp6s0 down  
❯ sudo ifconfig enp6s0 up
❯ sudo /etc/init.d/network-manager restart

部分修复了以太网。现在我的电缆实际上连接到了我的路由器(连接到桥接路由器),但互联网无法正常工作。但是,如果我手动将 DNS 名称服务器更改8.8.8.8

❯ sudo nano /etc/resolv.conf

resolv.conf然后它就起作用了。我意识到states中的第一行

This file is managed by man:systemd-resolved(8). Do not edit.

那么我该怎么做呢?另外,我敢打赌,如果我重新启动,以太网将无法工作,但也许有人知道如何让它现在工作?

更新 2

我已将 DNS 设置为 8.8.8.8,运行正常。但重启时仍显示电缆已拔出,我手动解决了此问题

sudo ifconfig enp6s0 down && sudo ifconfig enp6s0 up

我尝试添加,auto enp6s0/etc/network/interfaces不起作用。仅供参考;/etc/network/interfaces之前不存在

答案1

您是否尝试在 /etc/profile 中添加 sudo ifconfig enp6s0 down && sudo ifconfig enp6s0 up 作为临时解决方案。

答案2

下次重新启动时,所做的更改/etc/resolv.conf将被替换,但这很容易修复:

首先,获取resolvconf

sudo apt install resolvconf

编辑/etc/resolvconf/resolv.conf.d/head文件,添加:

nameserver 8.8.4.4
nameserver 8.8.8.8

然后重新启动resolvconf

sudo service resolvconf restart

至于以太网接口,我以前在启动期间曾见过这种情况,并且存在竞争条件。将其添加到/etc/network/interfaces

auto enp6s0

这应该可以解决问题。

相关内容