解决centos5.1不能上网的问题

来源:岁月联盟 编辑:exp 时间:2012-03-24

说明:1.使用的电脑安装的是双系统:xp和centos5.12.在xp下可以上网,但是在centos5.1下就是不能上网3.centos5.1中,不能ping通网关。4.xp中网卡设置为:ip:192.168.1.57掩码:255.255.255.0网关:192.168.1.10DNS:192.168.1.10在centos5.1中查看网卡信息为:[root@localhost ~]# ifconfig -aeth0      Link encap:Ethernet  HWaddr 00:E0:4C:2A:2E:0C            inet addr:192.168.1.57  Bcast:192.168.1.255  Mask:255.255.255.0          inet6 addr: fe80::2e0:4cff:fe2a:2e0c/64 Scope:Link          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1          RX packets:1511 errors:0 dropped:0 overruns:0 frame:0          TX packets:304 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0           RX bytes:139496 (136.2 KiB)  TX bytes:32922 (32.1 KiB)查看网关:[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0# Realtek Semiconductor Co., Ltd. RTL8101E PCI Express Fast Ethernet controllerDEVICE=eth0ONBOOT=yesBOOTPROTO=noneHWADDR=00:e0:4c:2a:2e:0cTYPE=EthernetNETMASK=255.255.255.0IPADDR=192.168.1.57GATEWAY=192.168.1.1USERCTL=noIPV6INIT=noPEERDNS=yes 查看DNS:[root@localhost ~]# cat /etc/resolv.confsearch localdomain 可以发现,原来网关和DNS不对,更改后重启网络服务:[root@localhost ~]# service network restartShutting down interface eth0:                              [  OK  ]Shutting down loopback interface:                          [  OK  ]Disabling IPv4 packet forwarding:  net.ipv4.ip_forward = 0                                                           [  OK  ]Bringing up loopback interface:                            [  OK  ]Bringing up interface eth0:                                [  OK  ] [root@localhost ~]# ping 192.168.1.10PING 192.168.1.10 (192.168.1.10) 56(84) bytes of data.64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=0.475 ms64 bytes from 192.168.1.10: icmp_seq=2 ttl=64 time=0.324 ms --- 192.168.1.10 ping statistics ---2 packets transmitted, 2 received, 0% packet loss, time 999msrtt min/avg/max/mdev = 0.324/0.399/0.475/0.078 ms[root@localhost ~]# ping www.baidu.comPING www.a.shifen.com (119.75.217.56) 56(84) bytes of data.64 bytes from 119.75.217.56: icmp_seq=1 ttl=54 time=22.8 ms64 bytes from 119.75.217.56: icmp_seq=2 ttl=54 time=25.3 ms64 bytes from 119.75.217.56: icmp_seq=3 ttl=54 time=25.2 ms --- www.a.shifen.com ping statistics ---3 packets transmitted, 3 received, 0% packet loss, time 1998msrtt min/avg/max/mdev = 22.829/24.474/25.332/1.170 ms   作者 xiangbei1573