当我将家庭服务器 wifi 切换到新路由器后,机器无法访问互联网。
所以这就是我所做的,修改了 run 中的 netplan yaml 文件\etc\netplan\50-clould.yaml
:
sudo netplan generate
sudo netplan apply
netlan yaml 内容:
network:
version: 2
renderer: networkd
wifis:
wlo1:
dhcp4: true
dhcp6: true
access-points:
"SSID":
password: "Password"
wifi 连接成功并且获取到 IP,我就可以 ssh 到我的机器了:
$ 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: wlo1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 30:f7:72:52:83:3b brd ff:ff:ff:ff:ff:ff
inet 192.168.2.14/24 brd 192.168.2.255 scope global dynamic wlo1
valid_lft 258159sec preferred_lft 258159sec
inet6 fe80::32f7:72ff:fe52:833b/64 scope link
valid_lft forever preferred_lft forever
$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.2.1 0.0.0.0 UG 600 0 0 wlo1
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 wlo1
192.168.2.1 0.0.0.0 255.255.255.255 UH 600 0 0 wlo1
192.168.2.1 是路由器 IP,我无法从我的 ubuntu 服务器机器内部 ping 通:
$ ping 192.168.2.1
PING 192.168.2.1 (192.168.2.1) 56(84) bytes of data.
From 192.168.2.14 icmp_seq=1 Destination Host Unreachable
我必须提一下,如果我重新连接到我的旧路由器,一切都会正常工作。
这是网络日志:
Sep 21 15:51:43 miniserver systemd[1]: Starting Network Manager...
Sep 21 15:51:44 miniserver NetworkManager[709]: <info> [1663789904.0433] NetworkManager (version 1.22.10) is starting... (for the first time)
Sep 21 15:51:44 miniserver NetworkManager[709]: <info> [1663789904.0438] Read config: /etc/NetworkManager/NetworkManager.conf (lib: 10-dns-resolved.conf, 10-globally-managed-devices.conf, no-mac-addr-change.conf) (run: netplan.conf) (etc: default-wifi-powersave-on.conf)
Sep 21 15:51:44 miniserver systemd[1]: Started Network Manager.
Sep 21 15:51:44 miniserver NetworkManager[709]: <info> [1663789904.1077] bus-manager: acquired D-Bus service "org.freedesktop.NetworkManager"
Sep 21 15:51:44 miniserver NetworkManager[709]: <info> [1663789904.1978] manager[0x556a032c5040]: monitoring kernel firmware directory '/lib/firmware'.
Sep 21 15:51:44 miniserver NetworkManager[709]: <info> [1663789904.2016] monitoring ifupdown state file '/run/network/ifstate'.
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.3707] hostname: hostname: using hostnamed
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.3708] hostname: hostname changed from (none) to "miniserver"
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.3728] dns-mgr[0x556a032aa290]: init: dns=systemd-resolved rc-manager=symlink, plugin=systemd-resolved
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.3778] rfkill1: found Wi-Fi radio killswitch (at /sys/devices/pci0000:00/0000:00:1c.3/0000:02:00.0/ieee80211/phy0/rfkill1) (driver rtl8723be)
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.3795] manager[0x556a032c5040]: rfkill: Wi-Fi hardware radio set enabled
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.3796] manager[0x556a032c5040]: rfkill: WWAN hardware radio set enabled
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.4272] Loaded device plugin: NMWwanFactory (/usr/lib/x86_64-linux-gnu/NetworkManager/1.22.10/libnm-device-plugin-wwan.so)
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.4329] Loaded device plugin: NMAtmManager (/usr/lib/x86_64-linux-gnu/NetworkManager/1.22.10/libnm-device-plugin-adsl.so)
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.4444] Loaded device plugin: NMWifiFactory (/usr/lib/x86_64-linux-gnu/NetworkManager/1.22.10/libnm-device-plugin-wifi.so)
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.4549] Loaded device plugin: NMTeamFactory (/usr/lib/x86_64-linux-gnu/NetworkManager/1.22.10/libnm-device-plugin-team.so)
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.4710] Loaded device plugin: NMBluezManager (/usr/lib/x86_64-linux-gnu/NetworkManager/1.22.10/libnm-device-plugin-bluetooth.so)
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.4734] manager: rfkill: Wi-Fi enabled by radio killswitch; enabled by state file
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.4744] manager: rfkill: WWAN enabled by radio killswitch; enabled by state file
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.4753] manager: Networking is enabled by state file
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.4764] dhcp-init: Using DHCP client 'internal'
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.4892] settings: Loaded settings plugin: ifupdown ("/usr/lib/x86_64-linux-gnu/NetworkManager/1.22.10/libnm-settings-plugin-ifupdown.so")
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.4990] settings: Loaded settings plugin: keyfile (internal)
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.4990] ifupdown: management mode: unmanaged
Sep 21 15:51:45 miniserver NetworkManager[709]: <warn> [1663789905.4998] ifupdown: interfaces file /etc/network/interfaces doesn't exist
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.5081] device (lo): carrier: link connected
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.5189] manager: (lo): new Generic device (/org/freedesktop/NetworkManager/Devices/1)
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.5397] device (wlo1): driver supports Access Point (AP) mode
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.5446] manager: (wlo1): new 802.11 Wi-Fi device (/org/freedesktop/NetworkManager/Devices/2)
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.5894] device (wlo1): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Sep 21 15:51:45 miniserver NetworkManager[709]: <warn> [1663789905.6325] Error: failed to open /run/network/ifstate
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.6887] modem-manager: ModemManager available
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.7110] supplicant: wpa_supplicant running
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.7111] device (wlo1): supplicant interface state: init -> starting
Sep 21 15:51:45 miniserver NetworkManager[709]: <error> [1663789905.8467] sup-iface[0x556a032d2900,wlo1]: error adding interface: wpa_supplicant couldn't grab this interface.
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.8468] device (wlo1): supplicant interface state: starting -> down
Sep 21 15:51:45 miniserver NetworkManager[709]: <info> [1663789905.8470] manager: startup complete
Sep 21 15:51:56 miniserver NetworkManager[709]: <warn> [1663789916.0140] device (wlo1): re-acquiring supplicant interface (#1).
Sep 21 15:51:56 miniserver NetworkManager[709]: <error> [1663789916.1026] sup-iface[0x556a032d29f0,wlo1]: error adding interface: wpa_supplicant couldn't grab this interface.
Sep 21 15:51:56 miniserver NetworkManager[709]: <info> [1663789916.1027] device (wlo1): supplicant interface state: starting -> down
Sep 21 15:52:06 miniserver NetworkManager[709]: <warn> [1663789926.0119] device (wlo1): re-acquiring supplicant interface (#2).
Sep 21 15:52:06 miniserver NetworkManager[709]: <error> [1663789926.1385] sup-iface[0x556a032d2ae0,wlo1]: error adding interface: wpa_supplicant couldn't grab this interface.
Sep 21 15:52:06 miniserver NetworkManager[709]: <info> [1663789926.1387] device (wlo1): supplicant interface state: starting -> down
Sep 21 15:52:16 miniserver NetworkManager[709]: <warn> [1663789936.0060] device (wlo1): re-acquiring supplicant interface (#3).
Sep 21 15:52:16 miniserver NetworkManager[709]: <error> [1663789936.1086] sup-iface[0x556a032d2bd0,wlo1]: error adding interface: wpa_supplicant couldn't grab this interface.
Sep 21 15:52:16 miniserver NetworkManager[709]: <info> [1663789936.1087] device (wlo1): supplicant interface state: starting -> down
Sep 21 15:52:26 miniserver NetworkManager[709]: <warn> [1663789946.0144] device (wlo1): re-acquiring supplicant interface (#4).
Sep 21 15:52:26 miniserver NetworkManager[709]: <error> [1663789946.1222] sup-iface[0x556a032d2cc0,wlo1]: error adding interface: wpa_supplicant couldn't grab this interface.
Sep 21 15:52:26 miniserver NetworkManager[709]: <info> [1663789946.1224] device (wlo1): supplicant interface state: starting -> down
Sep 21 15:52:36 miniserver NetworkManager[709]: <warn> [1663789956.0066] device (wlo1): re-acquiring supplicant interface (#5).
Sep 21 15:52:36 miniserver NetworkManager[709]: <error> [1663789956.1053] sup-iface[0x556a032d2cc0,wlo1]: error adding interface: wpa_supplicant couldn't grab this interface.
Sep 21 15:52:36 miniserver NetworkManager[709]: <info> [1663789956.1054] device (wlo1): supplicant interface state: starting -> down
Sep 21 15:52:36 miniserver NetworkManager[709]: <info> [1663789956.1055] device (wlo1): supplicant interface keeps failing, giving up