Ubuntu 18.04 LTS 上的网络存在一些重大问题。全新安装。我在安装过程中设置了一个静态 IP,该 IP 有效了几天,并且在多次重新启动后仍然保持设置。现在界面显示没有IP。看来当我设置该 IP 时,它确实生成了一个看起来正确的 netplan,但 netplan apply 没有执行任何操作。
我以前安装时也发生过这种情况。我一直在搞乱一些 DNS 的东西,所以我想我只是重新镜像机器而不是接触任何网络实用程序,但我仍然遇到问题。
该问题在安装后大约一天半出现,看似随机。问题开始时我并没有使用这台机器,到目前为止我在这次安装中所做的唯一一件事就是使用 samba 和 SFTP 设置了几个 docker 容器。
我的 50-cloud-init.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:
version: 2
renderer: networkd
ethernets:
enp0s25:
dhcp4: no
addresses: [192.168.0.32/24]
gateway4: 192.168.0.1
nameservers:
addresses: [1.1.1.1,8.8.8.8]
netplan --debug apply 的终端输出
** (generate:2227): DEBUG: 23:11:19.520: Processing input file /etc/netplan/50-cloud-init.yaml..
** (generate:2227): DEBUG: 23:11:19.520: starting new processing pass
** (generate:2227): DEBUG: 23:11:19.520: enp0s25: setting default backend to 1
** (generate:2227): DEBUG: 23:11:19.520: Generating output files..
** (generate:2227): DEBUG: 23:11:19.520: NetworkManager: definition enp0s25 is not for us (backend 1)
DEBUG:netplan generated networkd configuration exists, restarting networkd
DEBUG:no netplan generated NM configuration exists
DEBUG:enp0s25 not found in {}
DEBUG:Merged config:
network:
bonds: {}
bridges: {}
ethernets:
enp0s25:
addresses:
- 192.168.0.32/24
dhcp4: false
gateway4: 192.168.0.1
nameservers:
addresses:
- 1.1.1.1
- 8.8.8.8
vlans: {}
wifis: {}
DEBUG:Skipping non-physical interface: lo
DEBUG:Skipping non-physical interface: docker0
DEBUG:Skipping non-physical interface: br-98e8ea9c70cb
DEBUG:{}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for enp0s25
DEBUG:netplan triggering .link rules for docker0
DEBUG:netplan triggering .link rules for br-98e8ea9c70cb
我的 ifconfig
br-98e8ea9c70cb: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.18.0.1 netmask 255.255.0.0 broadcast 172.18.255.255
ether 02:42:51:a6:a3:66 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
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:d5:d6:46:8e 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
enp0s25: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 00:24:7e:00:e0:30 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 interrupt 16 memory 0xfc500000-fc520000
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 7926 bytes 592108 (592.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 7926 bytes 592108 (592.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
答案1
您是否以正确的方式配置了静态 IP?请参阅本教程。请记住,18.04 中配置静态 IP 与 16.04 中不同。
除此之外,我建议查看网络中是否有任何其他主机“窃取”了该 IP,也许尝试为该主机使用其他静态 IP。确保ping
新的静态 IP 以确保其可用。
最后确保运行sudo netplan apply
, 或sudo netplan --debug apply
以便运行新配置。
我最好的猜测是/etc/netplan/50-cloud-init.yaml
配置错误,因此请再仔细检查一次。
祝你好运。