CentOS7虚拟机配置内外两张网卡,只有外网不通

外网eth0:10.0.0.0   内网eth1:172.16.1

报错截图

1
2
[root@slb-5 ~]#ping www.baidu.com
ping: www.baidu.com: Name or service not known

尝试方法:ping 10.0.0.254网关,宿主机ping外网,ping172.16.1网段IP,都是通的

但是:

内网配置错了,多了网关和DNS

1
2
3
4
5
6
7
8
9
10
[root@CentOS7-Template ~]#cat  /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=none
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=10.0.0.100
PREFIX=24
GATEWAY=10.0.0.254
DNS1=223.5.5.5

  解决办法,删除内网网关,DNS,重启网络

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@CentOS7-Template ~]#cat  /etc/sysconfig/network-scripts/ifcfg-eth1
TYPE=Ethernet
BOOTPROTO=none
NAME=eth1
DEVICE=eth1
ONBOOT=yes
IPADDR=172.16.1.100
PREFIX=24
[root@CentOS7-Template ~]#systemctl restart network
[root@CentOS7-Template ~]#ping baidu.com
PING baidu.com (110.242.68.66) 56(84) bytes of data.
64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=1 ttl=128 time=66.6 ms
64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=2 ttl=128 time=87.4 ms
64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=3 ttl=128 time=99.9 ms

  

posted @   yun^-^  阅读(217)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
点击右上角即可分享
微信分享提示