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

相关推荐
人类群星闪耀时1 分钟前
服务器管理:从零开始的服务器安装与配置指南
运维·服务器
NiNg_1_23443 分钟前
使用Docker Compose一键部署
运维·docker·容器
萠哥啥都行1 小时前
Linux安装Docker以及Docker入门操作
运维·docker·容器
王哲晓1 小时前
Linux通过yum安装Docker
java·linux·docker
OkeyProxy1 小时前
怎麼在Ubuntu上設置全局代理
ubuntu·代理模式·proxy模式·ip代理·海外ip代理
小江湖19941 小时前
元数据保护者,Caesium压缩不丢重要信息
运维·学习·软件需求·改行学it
gopher95111 小时前
linux驱动开发-中断子系统
linux·运维·驱动开发
码哝小鱼1 小时前
firewalld封禁IP或IP段
linux·网络
鼠鼠龙年发大财1 小时前
【x**3专享】安装SSH、XFTP、XShell、ARM Linux
linux·arm开发·ssh
nfgo1 小时前
快速体验Linux发行版:DistroSea详解与操作指南
linux·ubuntu·centos