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

相关推荐
likfishdn1 分钟前
Linux的文件与目录管理
linux·运维·服务器
渲染101专业云渲染3 分钟前
川翔云电脑优势总结
服务器·3d·电脑·blender·maya
chian-ocean21 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=22 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
若云止水31 分钟前
Ubuntu 下 nginx-1.24.0 源码分析 - ngx_init_cycle 函数 - 详解(4)
数据库·nginx·ubuntu
橘子味的茶二32 分钟前
高级系统架构师--第十章:计算机网络
服务器·计算机网络·系统架构
Dontla1 小时前
Docker run --add-host参数解析(在容器启动时向/etc/hosts文件中添加自定义的主机名与IP映射)(适用于临时调试或测试)
tcp/ip·docker·容器
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
紫菜(Nori)1 小时前
短连接服务器压测-wrk
服务器·压力测试
追寻光1 小时前
Cannot find a valid baseurl for repo: base/7/x86_64
linux