我的 Ubuntu 18.04.3 服务器有问题。该服务器通过 wifi 连接到我的家庭网络,并具有静态 IP 地址。它大多数时候运行正常,但我反复遇到以下问题:
- 我 ssh 进入机器,发现有许多可用的升级
- 我安装升级
- 我重新启动
- 我无法再通过 ssh 访问该机器
- 我进入机器并登录。欢迎屏幕上没有显示 IP 地址
- 我重启了一下。一切又恢复正常了。
我查看了成功和不成功启动(成功建立连接)的日志。日志大致相似,但我发现成功启动的日志结尾为:
wpa_supplicant[760]: wlp1s0: WPA: Group rekeying completed with 40:0d:10:ad:70:2f [GTK=TKIP]
启动失败似乎会短暂地建立连接,但随后会出现:
wpa_supplicant[763]: nl80211: deinit ifname=p2p-dev-wlp1s0 disabled_11b_rates=0
systemd[1]: Stopping WPA supplicant for netplan wlp1s0...
etc...
没有明确的错误,只有关于结束连接的消息。有人知道为什么会发生这种情况吗?是否可以在重启后立即运行脚本来查看是否已建立连接,如果没有,则尝试获取连接?
编辑20191222:
自从第一次问这个问题以来,我现在有两个 cron 作业在周日早上运行。第一个执行更新并重新启动。第二个,一个小时后,再次重新启动。这似乎让我在使用服务器时一直在线。检查日志后,服务器似乎在第一次重新启动后有时在线,在第二次重新启动后始终在线。
输出:猫/etc/netplan/*.yaml
50-云-初始化.yaml
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
enp3s0:
addresses: []
dhcp4: true
version: 2
wifi配置.yaml
network:
version: 2
renderer: networkd
wifis:
wlp1s0:
dhcp4: no
dhcp6: no
addresses: [192.168.0.66/24]
gateway4: 192.168.0.1
nameservers:
addresses: [192.168.0.1, 8.8.8.8]
access-points:
"99PinkGins":
password: "###############"
optional: true
ethernets:
enp3s0:
addresses: [192.168.0.66/24]
gateway4: 192.168.0.1
nameservers:
addresses: [192.168.0.1, 8.8.8.8]
optional: true
输出猫/等/网络/接口
# ifupdown has been replaced by netplan(5) on this system. See
# /etc/netplan for current configuration.
# To re-enable ifupdown on this system, you can run:
# sudo apt install ifupdown
输出sudo lshw -C 网络
*-network
description: Wireless interface
product: Wireless 8260
vendor: Intel Corporation
physical id: 0
bus info: pci@0000:01:00.0
logical name: wlp1s0
version: 3a
serial: 00:bb:60:41:7a:8a
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
configuration: broadcast=yes driver=iwlwifi driverversion=4.15.0-72-generic firmware=34.0.1 ip=192.168.0.66 latency=0 link=yes multicast=yes wireless=IEEE 802.11
resources: irq:28 memory:fbefe000-fbefffff
*-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:03:00.0
logical name: enp3s0
version: 06
serial: 1c:6f:65:28:8d:14
size: 10Mbit/s
capacity: 1Gbit/s
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=half firmware=rtl_nic/rtl8168e-1.fw latency=0 link=no multicast=yes port=MII speed=10Mbit/s
resources: irq:17 ioport:ee00(size=256) memory:fbbff000-fbbfffff memory:fbbf8000-fbbfbfff
答案1
/etc/netplan 中只有一个 .yaml 文件。它看起来应该类似于此...
network:
version: 2
renderer: networkd
wifis:
wlp1s0:
addresses: [192.168.0.66/24] # don't use the same IP address as enp3s0
gateway4: 192.168.0.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]
access-points:
"99PinkGins":
password: "###############"
ethernets:
enp3s0:
dhcp4: true
optional: true
sudo netplan --debug generate
sudo netplan apply
reboot