VMware虚拟机安装的Ubuntu,桥接方式静态ip,内网可以访问,ping外网不可用

1.环境说明

系统:Ubuntu 24.04

环境:VMware下桥接静态IP设置

2.问题:ping www.baidu.com报错

复制代码
[~] ping www.baidu.com                                                         
ping: www.baidu.com: Temporary failure in name resolution

3.解决办法

(1)利用route -n命令查询网关正常的服务器,用命令设置网关

  • 没有网关的服务器

    [~] route -n
    Kernel IP routing table
    Destination Gateway Genmask Flags Metric Ref Use Iface
    192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 ens33

  • 有网关的正常服务器

    [root@localhost /]# route -n
    Kernel IP routing table
    Destination Gateway Genmask Flags Metric Ref Use Iface
    0.0.0.0 192.168.122.254 0.0.0.0 UG 0 0 0 ens33
    192.168.122.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33

(2)设置网关

复制代码
[~] sudo route add default gw 192.168.122.254                                  
[~] route -n                                                                   
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.122.254 0.0.0.0         UG    0      0        0 ens33
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 ens33

(3)测试能正常连通外网

参照:https://blog.csdn.net/qq_32927563/article/details/132297413

相关推荐
轻松Ai享生活3 小时前
5 节课深入学习Linux Cgroups
linux
christine-rr3 小时前
linux常用命令(4)——压缩命令
linux·服务器·redis
三坛海会大神5554 小时前
LVS与Keepalived详解(二)LVS负载均衡实现实操
linux·负载均衡·lvs
東雪蓮☆4 小时前
深入理解 LVS-DR 模式与 Keepalived 高可用集群
linux·运维·服务器·lvs
qq_264220894 小时前
LVS负载均衡群集和LVS+Keepalived群集
运维·负载均衡·lvs
树码小子4 小时前
Java网络编程:(socket API编程:TCP协议的 socket API -- 回显程序的服务器端程序的编写)
java·网络·tcp/ip
乌萨奇也要立志学C++4 小时前
【Linux】进程概念(二):进程查看与 fork 初探
linux·运维·服务器
雨落Liy4 小时前
Nginx 从入门到进阶:反向代理、负载均衡与高性能实战指南
运维·nginx·负载均衡
Yyyy4825 小时前
Nginx负载均衡集群实验步骤
运维·nginx·负载均衡
绿箭柠檬茶5 小时前
Ubuntu 服务器配置转发网络访问
服务器·网络·ubuntu