今天使用 VMware 运行 Ubuntu 20.14TLS 虚拟机,Ubuntu 启动成功后没有网络图标显示,也无法上网了。
在网上找了很多办法进行尝试,最终解决办法如下:
使用 ifconfig -a 命令查看本机所有的网卡,如下:
hxstrive@ubuntu:~/Desktop$ ifconfig -a docker0: flags=4098<BROADCAST,MULTICAST> mtu 1500 ether 02:42:05:b9:02:0b txqueuelen 0 (以太网) 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 ens33: flags=4098<BROADCAST,MULTICAST> mtu 1500 ether 00:0c:29:76:d5:2b txqueuelen 1000 (以太网) RX packets 20981 bytes 29053809 (29.0 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 11186 bytes 869423 (869.4 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 (本地环回) RX packets 2784 bytes 216523 (216.5 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2784 bytes 216523 (216.5 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
使用 ifconfig ens33 up 命令去启动网卡,如下:
hxstrive@ubuntu:~/Desktop$ ifconfig -a docker0: flags=4098<BROADCAST,MULTICAST> mtu 1500 ether 02:42:05:b9:02:0b txqueuelen 0 (以太网) 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 ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.31.131 netmask 255.255.255.0 broadcast 192.168.31.255 inet6 fe80::ea21:2a90:7d62:6f4b prefixlen 64 scopeid 0x20<link> ether 00:0c:29:76:d5:2b txqueuelen 1000 (以太网) RX packets 21042 bytes 29070398 (29.0 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 11266 bytes 884535 (884.5 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 (本地环回) RX packets 2844 bytes 221579 (221.5 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2844 bytes 221579 (221.5 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
再次使用 ifconfig 命令,网卡 ens33 已经展示出来了。如果存在 IP 地址,则尝试一下是否能够上网,不能就去配置一下正确IP地址即可。如果没有 IP 地址,则使用 dhclient 命令来自动获取 IP 地址。命令如下:
hxstrive@ubuntu:~/Desktop$ sudo dhclient ens33 hxstrive@ubuntu:~/Desktop$
成功执行了 dhclient 命令,使用 ifconfig 去看看有 ip 没有。