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

相关推荐
Joseph Cooper27 分钟前
STM32MP157 Linux驱动学习笔记(四):典型总线与设备模型(SPI/USB)
linux·stm32·学习
坚持就完事了37 分钟前
Linux中的mv命令
linux·运维·服务器
SongYuLong的博客42 分钟前
Claude Code安装配置(Linux)
linux·运维·服务器
linux修理工1 小时前
禁用 Windows 跳转列表和最近文档跟踪的注册表修改
运维
栈低来信1 小时前
kernel信号量源码分析
linux
AC赳赳老秦1 小时前
OpenClaw权限管理实操:团队共享Agent,设置操作权限,保障数据安全
服务器·开发语言·前端·javascript·excel·deepseek·openclaw
结衣结衣.2 小时前
手把手教你实现文档搜索引擎
linux·c++·搜索引擎·开源·c++11
Elastic 中国社区官方博客2 小时前
使用 EDOT Browser 和 Kibana 进行 OpenTelemetry 浏览器端埋点
大数据·服务器·数据库·elasticsearch·搜索引擎·单元测试·可用性测试
智能运维指南2 小时前
2026 年企业IT运维监控系统选型指南:全栈可观测平台对比与落地建议
运维
sdm0704272 小时前
进程间通信
linux·运维·服务器