验证RedHat6是否能够联网:
# ping 8.8.8.8
# ping 8.8.4.4
下载www.baidu.com首页并且显示下载信息:
# wget -d http://www.baidu.com
能成功下载百度首页index.html文件,但不一定能ping http://www.baidu.com
# ping 180.76.76.76
# ping 23.5.5.5
# ping http://www.baidu.com
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NETMASK=255.255.255.0
IPADDR=192.168.3.56
HWADDR=00:0C:29:C1:D6:8A
TYPE=Ethernet
#UUID=6a73447a-4baa-4ad4-bdca-73d3a654583f
ONBOOT=yes
#NM_CONTROLLED=yes
BOOTPROTO=static
GATEWAY=192.168.3.1
NETWORKING=yes
#DEFROUTE=yes
#DNS1=8.8.8.8
#DNS2=8.8.4.4
#DNS1=202.96.209.5
#DNS2=202.96.209.133
DNS1=180.76.76.76
DNS2=23.5.5.5
如果还是不能连接外网,可以用route -n查看一下路由情况:
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 [color=red]192.168.10.2[/color] 0.0.0.0 UG 0 0 0 ens33
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 ens33
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 ens33
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
# ping 8.8.8.8
# ping 8.8.4.4
下载www.baidu.com首页并且显示下载信息:
# wget -d http://www.baidu.com
能成功下载百度首页index.html文件,但不一定能ping http://www.baidu.com
# ping 180.76.76.76
# ping 23.5.5.5
# ping http://www.baidu.com
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NETMASK=255.255.255.0
IPADDR=192.168.3.56
HWADDR=00:0C:29:C1:D6:8A
TYPE=Ethernet
#UUID=6a73447a-4baa-4ad4-bdca-73d3a654583f
ONBOOT=yes
#NM_CONTROLLED=yes
BOOTPROTO=static
GATEWAY=192.168.3.1
NETWORKING=yes
#DEFROUTE=yes
#DNS1=8.8.8.8
#DNS2=8.8.4.4
#DNS1=202.96.209.5
#DNS2=202.96.209.133
DNS1=180.76.76.76
DNS2=23.5.5.5
如果还是不能连接外网,可以用route -n查看一下路由情况:
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 [color=red]192.168.10.2[/color] 0.0.0.0 UG 0 0 0 ens33
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 ens33
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 ens33
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0