@ubuntu:~$ ifconfig
lo: flags=73
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 591 bytes 37975 (37.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 591 bytes 37975 (37.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lxcbr0: flags=4099
inet 10.0.3.1 netmask 255.255.255.0 broadcast 0.0.0.0
ether 00:16:3e:00:00:00 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
其实不是接口不存在,只是接口没有UP
l@ubuntu:~$ ifconfig -a
ens33: flags=4098
ether 00:0c:29:60:ac:56 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
lo: flags=73
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 2253 bytes 141605 (141.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2253 bytes 141605 (141.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lxcbr0: flags=4099
inet 10.0.3.1 netmask 255.255.255.0 broadcast 0.0.0.0
ether 00:16:3e:00:00:00 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
解决办法:
sudo dhclient
@ubuntu:~$ ifconfig
ens33: flags=4163
inet 192.168.242.131 netmask 255.255.255.0 broadcast 192.168.242.255
inet6 fe80::20c:29ff:fe60:ac56 prefixlen 64 scopeid 0x20
ether 00:0c:29:60:ac:56 txqueuelen 1000 (Ethernet)
RX packets 6341 bytes 8528561 (8.5 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2153 bytes 164046 (164.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 2729 bytes 172609 (172.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2729 bytes 172609 (172.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lxcbr0: flags=4099
inet 10.0.3.1 netmask 255.255.255.0 broadcast 0.0.0.0
ether 00:16:3e:00:00:00 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