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



说明:
1.使用的电脑安装的是双系统:xp和centos5.1
2.在xp下可以上网,但是在centos5.1下就是不能上网
3.centos5.1中,不能ping通网关。
4.xp中网卡设置为:
ip:192.168.1.57
掩码:255.255.255.0
网关:192.168.1.10
DNS:192.168.1.10
在centos5.1中查看网卡信息为:
[root@localhost ~]# ifconfig -a
eth0      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 controller
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
HWADDR=00:e0:4c:2a:2e:0c
TYPE=Ethernet
NETMASK=255.255.255.0
IPADDR=192.168.1.57
GATEWAY=192.168.1.1
USERCTL=no
IPV6INIT=no
PEERDNS=yes
 
查看DNS:
[root@localhost ~]# cat /etc/resolv.conf
search localdomain
 
可以发现,原来网关和DNS不对,更改后重启网络服务:
[root@localhost ~]# service network restart
Shutting 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.10
PING 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 ms
64 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 999ms
rtt min/avg/max/mdev = 0.324/0.399/0.475/0.078 ms
[root@localhost ~]# ping www.baidu.com
PING 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 ms
64 bytes from 119.75.217.56: icmp_seq=2 ttl=54 time=25.3 ms
64 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 1998ms
rtt min/avg/max/mdev = 22.829/24.474/25.332/1.170 ms
 
 
 
作者 xiangbei1573

相关内容

    暂无相关文章