今日打开 VMWare 虚拟机开启 Ubuntu21.10 系统,系统无法正常联网。通过 ifconfig 查看网络接口信息如下:
hxstrive@course:~/Desktop$ ifconfig
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 598 bytes 43498 (43.4 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 598 bytes 43498 (43.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0上面输出信息中,只有一个 lo 回路网络接口。
我们可以使用命令查看当前系统下面所有的网络接口,命令如下:
hxstrive@course:~/Desktop$ ifconfig -a
ens33: flags=4163<BROADCAST,MULTICAST> mtu 1500
inet6 fe80::20c:29ff:fe58:526 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:58:05:26 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 9 bytes 925 (925.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
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 1102 bytes 79962 (79.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1102 bytes 79962 (79.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0上面显示有两个网络接口,分别是 ens33 和 lo(回路)。
此时,我们可以使用命令启动 enss33 网络接口,命令如下:
hxstrive@course:~/Desktop$ sudo ifconfig ens33 up
[sudo] password for hxstrive:再次使用 ifconfig 命令查看网络接口信息,命令如下:
hxstrive@course:~/Desktop$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::20c:29ff:fe58:526 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:58:05:26 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 9 bytes 925 (925.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
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 599 bytes 43571 (43.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 599 bytes 43571 (43.5 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0遗憾的是,ens33 网络接口依然没有分配IP地址。
此时,使用命令动态分配IP,命令如下:
hxstrive@course:~/Desktop$ sudo dhclient ens33再次使用 ifconfig 命令查看网络接口信息,命令如下:
hxstrive@course:~/Desktop$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.116.134 netmask 255.255.255.0 broadcast 192.168.116.255
inet6 fe80::20c:29ff:fe58:526 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:58:05:26 txqueuelen 1000 (Ethernet)
RX packets 106 bytes 8900 (8.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 43 bytes 5691 (5.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
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 1084 bytes 78109 (78.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1084 bytes 78109 (78.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0最后,通过 ping 命令验证网络是否可用,命令如下:
hxstrive@course:~/Desktop$ ping www.baidu.com
PING www.a.shifen.com (14.215.177.39) 56(84) bytes of data.
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=1 ttl=128 time=43.4 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=2 ttl=128 time=42.2 ms
^C
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 42.240/42.797/43.355/0.557 ms