1).首先配置DNS服务:
Google公用服务:
# cat /etc/resolv.conf
-------------------------------------------------------------------
nameserver 8.8.8.8
nameserver 8.8.4.4
2)配置IP:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
3) 确保路由表正常
[cpp]
[root@CentOS5 ~]# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.128.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
#0.0.0.0 192.168.128.2 0.0.0.0 UG 0 0 0 eth0 原来是没有这行的,在执行下面的命令之后才会有的
如果未设置, 则通过如下方式增加网关:
[cpp]
# route add default gw 192.168.128.2
再试一下,就是了ping通了