VMware中Ubuntu(Linux)无法连接网络解决办法记录

问题:

操作系统:Ubuntu 22.04.3 LTS
VMware 版本:VMware® Workstation 17 Pro, 17.0.0 build-20800274

今天在虚拟机用Ubuntu的时候,发现无法连接网络,如下:

wd@wd-virtual-machine:~$ 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  (本地环回)
        RX packets 3771  bytes 269507 (269.5 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3771  bytes 269507 (269.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

解决办法:

百度后找到的解决办法:

wd@wd-virtual-machine:~$ sudo service NetworkManager stop
wd@wd-virtual-machine:~$ sudo rm /var/lib/NetworkManager/NetworkManager.state
wd@wd-virtual-machine:~$ sudo service NetworkManager start
wd@wd-virtual-machine:~$ ifconfig
ens37: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.57.130  netmask 255.255.255.0  broadcast 192.168.57.255
        inet6 fe80::8947:d00e:df37:4c58  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:58:9f:34  txqueuelen 1000  (以太网)
        RX packets 16  bytes 3783 (3.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 46  bytes 5459 (5.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 4899  bytes 350386 (350.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4899  bytes 350386 (350.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

就是依次运行下面三条语句即可:

sudo service NetworkManager stop
sudo rm /var/lib/NetworkManager/NetworkManager.state
sudo service NetworkManager start

现在可以上网了:

wd@wd-virtual-machine:~$ ping baidu.com
PING baidu.com (39.156.66.10) 56(84) bytes of data.
64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=1 ttl=128 time=41.4 ms
64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=2 ttl=128 time=41.2 ms
64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=3 ttl=128 time=41.2 ms
64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=4 ttl=128 time=41.4 ms
64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=5 ttl=128 time=41.3 ms
64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=6 ttl=128 time=41.2 ms
64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=7 ttl=128 time=41.1 ms
^C
--- baidu.com ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6012ms
rtt min/avg/max/mdev = 41.080/41.251/41.435/0.107 ms

参考链接

解决VM虚拟机中ubuntu系统上不了网的问题,请直接看方法四,前面三种方法都没什么用,至少我是这样的。还有就是他的文章中停止和启动的命令中的network-manager我需要换成NetworkManager才可以。

你可能感兴趣的:(linux,ubuntu,网络)