linux网络配置正确,能够ping通内网地址,无法打开外网网页

在虚拟机里面装了linux后,发现内网能访问,外网访问不了。
首先确定网络配置没有问题,并且能够访问外网,通过以下方法进行确认:
[root@localhost ~]# more /etc/sysconfig/network-scripts/ifcfg-eth0 
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:50:56:bd:00:56
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=172.16.6.50
GATEWAY=172.16.6.1
TYPE=Ethernet
       [root@localhost ~]# ping 172.16.6.1
PING 172.16.6.1 (172.16.6.1) 56(84) bytes of data.
64 bytes from 172.16.6.1: icmp_seq=1 ttl=255 time=0.890 ms
64 bytes from 172.16.6.1: icmp_seq=2 ttl=255 time=0.841 ms
 
--- 172.16.6.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.841/0.865/0.890/0.038 ms
 
在确定网络没问题的情况下,可以通过如下步骤寻找解决办法:
 
1) 确定设置了域名服务器
 
[root@localhost ~]# more /etc/resolv.conf 
        search localdomain
        nameserver 8.8.8.8          #谷歌的免费DNS
 
2) 确定设置了网关
 
[root@localhost ~]# grep GATEWAY /etc/sysconfig/network-scripts/ifcfg*
 
-------------------------------------------------------------------
 
/etc/sysconfig/network-scripts/ifcfg-eth0:GATEWAY=172.16.6.1
 
-------------------------------------------------------------------
 
如果没有设置,可以通过如下两种方式增加网关:
 
a.
 
[root@localhost ~]# route add default gw 192.168.40.1
 
b.
 
[root@localhost ~]#vi /etc/sysconfig/network-scripts/ifcfg*
重启network服务:
[root@localhost ~]# service network restart
 
 
3) 确定可用dns解析
 
[root@localhost ~]# grep hosts /etc/nsswitch.conf
-------------------------------------------------------------------
 
hosts: files dns
-------------------------------------------------------------------
 
排除以上情况,问题基本上可以解决……
 
如果还没解决,可以 在本地机器的网络连接,将虚拟机的网卡VM开头的,以及Network Bridge禁用掉,然后再都开启,再在虚拟机里面连接网络(我安装的桌面版),
然后看是否能ping通外网地址,我就是这样弄好的。
posted @ 2015-11-15 20:40  huazhiliange  阅读(2489)  评论(0编辑  收藏  举报