背景:
硬件:Thinkpad X301
在安装 Ubuntu 18.04.1 Server(64 位)时,安装卡在网络设置部分。网络设置超时,似乎没有为以太网接口(在本例中为 enp0s25)分配 IP 地址。
我下载了替代安装程序,安装过程顺利,DHCP 自动配置(在 16.04 服务器安装中也能完美运行)。但是安装后,18.04 挂在“等待网络配置”消息处。2 分钟后,它继续运行并允许我访问终端。
配置
启动后 ifconfig 的输出
enp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::222:68ff:fe0c:bf44 prefixlen 64 scopeid 0x20<link>
ether 00:22:68:0c:bf:44 txqueuelen 1000 (Ethernet)
RX packets 225 bytes 59069 (59.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 20 bytes 3686 (3.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 20 memory 0xf0600000-f0620000
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 528 bytes 32112 (32.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 528 bytes 32112 (32.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
启动后 ip addr show 的输出
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: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:22:68:0c:bf:44 brd ff:ff:ff:ff:ff:ff
inet6 fe80::222:68ff:fe0c:bf44/64 scope link
valid_lft forever preferred_lft forever
3: wls1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 00:21:6a:1d:ee:fe brd ff:ff:ff:ff:ff:ff
01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
enp0s25:
dhcp4: true
临时解决方案
尝试使用sudo ip addr add 192.168.0.107 dev enp0s25
- IP 已分配给接口,但没有互联网
然后我尝试sudo dhclient -v enp0s25
- 分配一个 IP 并上网
sudo dhclient -v enp0s25 后的输出
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: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:22:68:0c:bf:44 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.107/24 brd 192.168.0.255 scope global enp0s25
valid_lft forever preferred_lft forever
inet6 fe80::222:68ff:fe0c:bf44/64 scope link
valid_lft forever preferred_lft forever
3: wls1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 00:21:6a:1d:ee:fe brd ff:ff:ff:ff:ff:ff
总结 - 问题
为了让 ubuntu 在启动时自行获取动态 IP 地址,需要进行哪些更改?