灯火互联
管理员
管理员
  • 注册日期2011-07-27
  • 发帖数41778
  • QQ
  • 火币41290枚
  • 粉丝1086
  • 关注100
  • 终身成就奖
  • 最爱沙发
  • 忠实会员
  • 灌水天才奖
  • 贴图大师奖
  • 原创先锋奖
  • 特殊贡献奖
  • 宣传大使奖
  • 优秀斑竹奖
  • 社区明星
阅读:1913回复:0

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

楼主#
更多 发布于:2013-05-11 14:42
 linux网络配置正确,能够ping通外网地址,无法打开网页问题
 
 
 
首先确定系统的网络配置没有问题,并且能够访问外网,通过以下方法进行确认:
 
[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
 
-------------------------------------------------------------------
 
 
 
排除以上情况,问题基本上可以解决……

喜欢0 评分0
游客

返回顶部