虚拟机 ubuntu 22.04 ping不通问题
虚拟机 ubuntu 22.04 下发现没有网络,使用ping百度发现ping不通问题
输出
查看网关
输出 没有IP地址,正常应该会有IP地址的。
检查网络连接
输出 发现ens33是没有启动的,它是以太网接口。
ens33: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether 00:0c:29:81:ef:42 txqueuelen 1000 (以太网)
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<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 2249 bytes 161163 (161.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2249 bytes 161163 (161.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
启动以太网接口
再查看发现启动是启动了,但是查询 route -n 发现IP还是空白。ping也不通。
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::20c:29ff:fe81:ef42 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:81:ef:42 txqueuelen 1000 (以太网)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 17 bytes 2375 (2.3 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 2889 bytes 206603 (206.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2889 bytes 206603 (206.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
更新DNS
在文件中,更新和新增以下内容:
使用 DHCP 获取 IP 地址
重启网络服务
这个时候重新查询IP,发现有了,直接ping百度也OK了,修好了。
以上问题可以简化为以下两个命令:
评论