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


    问题:

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

    今天在虚拟机用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
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    解决办法:

    百度后找到的解决办法:

    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
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22

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

    sudo service NetworkManager stop
    sudo rm /var/lib/NetworkManager/NetworkManager.state
    sudo service NetworkManager start
    
    • 1
    • 2
    • 3

    现在可以上网了:

    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
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    参考链接

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

  • 相关阅读:
    k8s-service-3-clusterip
    cannot allocate memory in static TLS block
    ES6 入门教程 24 Module 的语法 24.4 import 命令 & 24.5 模块的整体加载
    性能测试基础知识及性能指标
    【优化模型】报童的诀窍
    基于Spingboot的HIS医院门诊信息系统
    Shiro安全框架
    NTP服务器工作原理
    2023高教社杯全国大学生数学建模竞赛选题建议
    链表经典面试题(三)
  • 原文地址:https://blog.csdn.net/qq_41356707/article/details/133709824