多年来,我在 Ubuntu 16.04 LTS 中一直使用相同的设置。今天早上突然无法访问互联网,除非我关闭 WiFi。我只能在关闭 WiFi 或以太网的情况下访问。
我已经多次重启笔记本电脑,运行sudo apt update && sudo apt upgrade
,重启路由器并查看路由器配置:
WiFi 卡的“DHCP-Reserved”设置很显眼。我的所有 IP 地址都是静态的:
$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 alien
# Add to router static IP address list
192.168.0.10 alien AW 17R3 WiFi 9c:b6:d0:10:37:f7
192.168.0.12 alien AW 17R3 Ethernet 28:f1:0e:2a:1a:ed
192.168.0.11 phone Moto E4 Plus d0:77:14:c8:bc:e5
192.168.0.13 dell Inspiron 17R-SE-7720 Ethernet 5c:f9:dd:5c:9c:53
192.168.0.14 dell Inspiron 17R-SE-7720 WiFi 60:6c:66:86:de:bd
192.168.0.15 hs100 Sony TV Wall Light 50:d4:f7:eb:41:35
192.168.0.16 android-47cdabb50f83a5ee Sony Bravia TV KBL 50W800C
192.168.0.17 hs103 Toshiba 32" TV 18:4F:32:8D:AA:97
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
以太网和 Wifi 卡:
$ lspci -v | grep -i net -A6
3b:00.0 Ethernet controller: Qualcomm Atheros Killer E2400 Gigabit Ethernet Controller (rev 10)
Subsystem: Device 0707:2400
Flags: bus master, fast devsel, latency 0, IRQ 16
Memory at dd600000 (64-bit, non-prefetchable) [size=256K]
I/O ports at d000 [size=128]
Capabilities: <access denied>
Kernel driver in use: alx
--
3c:00.0 Network controller: Qualcomm Atheros QCA6174 802.11ac Wireless Network Adapter (rev 32)
Subsystem: Bigfoot Networks, Inc. QCA6174 802.11ac Wireless Network Adapter
Flags: bus master, fast devsel, latency 0, IRQ 137
Memory at dd200000 (64-bit, non-prefetchable) [size=2M]
Capabilities: <access denied>
Kernel driver in use: ath10k_pci
Kernel modules: ath10k_pci
不确定路由是否相关,但它在这里:
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 100 0 0 enp59s0
0.0.0.0 192.168.0.1 0.0.0.0 UG 600 0 0 wlp60s0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 enp59s0
192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 enp59s0
192.168.0.0 0.0.0.0 255.255.255.0 U 600 0 0 wlp60s0
编辑于 2021 年 2 月 2 日
问题是,当以太网和 WiFi 都连接时,DNS 查找不起作用。互联网可通过直接 IP 寻址获得。当 Wifi 和以太网都连接时,查看路由器的值似乎在发生变化?
所以现在我将进入 DNS 兔子洞......
答案1
以太网连接时停用 WiFi
首先,我尝试从 ISP 获取新的电缆调制解调器。
然后我发现了一个当以太网(网络)连接时自动禁用WiFi的脚本:
#!/bin/bash
export LC_ALL=C
enable_disable_wifi ()
{
result=$(nmcli dev | grep "ethernet" | grep -w "connected")
if [ -n "$result" ]; then
nmcli radio wifi off
else
nmcli radio wifi on
fi
}
if [ "$2" = "up" ]; then
enable_disable_wifi
fi
if [ "$2" = "down" ]; then
enable_disable_wifi
fi
脚本必须在特定目录中创建。创建后将其标记为可执行:
chmod a+x /etc/NetworkManager/dispatcher.d/70-wifi-wired-exclusive.sh