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

相关推荐
Root_Hacker35 分钟前
include文件包含个人笔记及c底层调试
android·linux·服务器·c语言·笔记·安全·php
REDcker1 小时前
RESTful API设计规范详解
服务器·后端·接口·api·restful·博客·后端开发
微学AI1 小时前
内网穿透的应用-告别局域网束缚!MonkeyCode+cpolar 解锁 AI 编程新体验
linux·服务器·网络
sunnyday04261 小时前
基于Netty构建WebSocket服务器实战指南
服务器·spring boot·websocket·网络协议
信创天地2 小时前
国产堡垒机部署实战:以奇安信、天融信为例构建运维安全三重防线
运维·安全
呉師傅2 小时前
东芝3525AC彩色复印机CC219测试页打印方法【实际操作】
运维·网络·windows·计算机外设·电脑
GeekyGuru3 小时前
TCP/IP协议栈深度解析:从分层原理到内核实现与调优
网络·网络协议·tcp/ip
凯子坚持 c3 小时前
Protocol Buffers C++ 进阶数据类型与应用逻辑深度解析
java·服务器·c++
宴之敖者、3 小时前
Linux——权限
linux·运维·服务器
刘叨叨趣味运维4 小时前
Linux性能排查实战:从“系统慢”到精准定位
linux