首先用命令ifconfig
Last login: Wed Apr 16 10:49:21 2014 from 192.168.1.110[root@cognoswithdb2 ~]# service network restartShutting down interface eth0: Device state: 3 (disconnected)[ OK ]Shutting down loopback interface: [ OK ]Bringing up loopback interface: [ OK ]Bringing up interface eth0: Active connection state: activatingActive connection path: /org/freedesktop/NetworkManager/ActiveConnection/5state: activatedConnection activated[ OK ][root@cognoswithdb2 ~]# ifconfigeth0 Link encap:Ethernet HWaddr 00:0C:29:3F:6B:0A inet addr:192.168.0.102 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe3f:6b0a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:344 errors:0 dropped:0 overruns:0 frame:0 TX packets:353 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:100679 (98.3 KiB) TX bytes:34693 (33.8 KiB)lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:24 errors:0 dropped:0 overruns:0 frame:0 TX packets:24 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1600 (1.5 KiB) TX bytes:1600 (1.5 KiB)[root@cognoswithdb2 ~]#
命名添加一个虚拟网卡eth0:0
先看下我本机的IP
C:\Users\wenchao>ipconfigWindows IP 配置无线局域网适配器 无线网络连接: 连接特定的 DNS 后缀 . . . . . . . : local 本地链接 IPv6 地址. . . . . . . . : fe80::d04:38b4:bcdc:dfb1%12 IPv4 地址 . . . . . . . . . . . . : 192.168.0.101 子网掩码 . . . . . . . . . . . . : 255.255.255.0 默认网关. . . . . . . . . . . . . : 192.168.0.1以太网适配器 本地连接: 连接特定的 DNS 后缀 . . . . . . . : 本地链接 IPv6 地址. . . . . . . . : fe80::8419:c73d:d90c:1ab0%11 IPv4 地址 . . . . . . . . . . . . : 216.16.18.222 子网掩码 . . . . . . . . . . . . : 255.255.255.0 默认网关. . . . . . . . . . . . . : 216.16.18.254以太网适配器 VMware Network Adapter VMnet1: 连接特定的 DNS 后缀 . . . . . . . : 本地链接 IPv6 地址. . . . . . . . : fe80::cc81:2094:5506:15d3%14 IPv4 地址 . . . . . . . . . . . . : 192.168.231.1 子网掩码 . . . . . . . . . . . . : 255.255.255.0 默认网关. . . . . . . . . . . . . :以太网适配器 VMware Network Adapter VMnet8: 连接特定的 DNS 后缀 . . . . . . . : 本地链接 IPv6 地址. . . . . . . . : fe80::595a:714b:9cf:8df0%16 IPv4 地址 . . . . . . . . . . . . : 192.168.233.1 子网掩码 . . . . . . . . . . . . : 255.255.255.0 默认网关. . . . . . . . . . . . . :隧道适配器 isatap.{32E96D33-F3C4-4535-8A53-1CE1223E92E5}: 媒体状态 . . . . . . . . . . . . : 媒体已断开 连接特定的 DNS 后缀 . . . . . . . :隧道适配器 isatap.{5DDB227E-EDCB-46C8-B201-426A50848C9E}: 媒体状态 . . . . . . . . . . . . : 媒体已断开 连接特定的 DNS 后缀 . . . . . . . :隧道适配器 isatap.{F3431018-9927-4A9F-862F-0844D18E057C}: 媒体状态 . . . . . . . . . . . . : 媒体已断开 连接特定的 DNS 后缀 . . . . . . . :隧道适配器 本地连接* 3: 媒体状态 . . . . . . . . . . . . : 媒体已断开 连接特定的 DNS 后缀 . . . . . . . :C:\Users\wenchao>
这么多IP,我一下搞不明白,先弄清楚吧
首先第一个192.168.0.101,这是我的无线网络的IP,使用这个IP,我可以连接到外网
第二个,这是我公司局域网的IP
第三个,VMNET1和VMNET8是vmware 使用的IP
--
我在本机插上网线之后,在虚拟机上是ping不通局域网内的IP的
[root@cognoswithdb2 ~]# ping 216.16.18.222PING 216.16.18.222 (216.16.18.222) 56(84) bytes of data.^C--- 216.16.18.222 ping statistics ---5 packets transmitted, 0 received, 100% packet loss, time 4313ms[root@cognoswithdb2 ~]#
我用ifconfi添加一个虚拟网卡试试
[root@cognoswithdb2 ~]# ifconfig eth0:0 216.16.18.137[root@cognoswithdb2 ~]# ifconfigeth0 Link encap:Ethernet HWaddr 00:0C:29:3F:6B:0A inet addr:192.168.0.102 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe3f:6b0a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:666 errors:0 dropped:0 overruns:0 frame:0 TX packets:582 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:138889 (135.6 KiB) TX bytes:60800 (59.3 KiB)eth0:0 Link encap:Ethernet HWaddr 00:0C:29:3F:6B:0A inet addr:216.16.18.137 Bcast:216.16.18.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:27 errors:0 dropped:0 overruns:0 frame:0 TX packets:27 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1936 (1.8 KiB) TX bytes:1936 (1.8 KiB)[root@cognoswithdb2 ~]# ping 216.16.18.222PING 216.16.18.222 (216.16.18.222) 56(84) bytes of data.From 216.16.18.137 icmp_seq=2 Destination Host UnreachableFrom 216.16.18.137 icmp_seq=3 Destination Host UnreachableFrom 216.16.18.137 icmp_seq=4 Destination Host UnreachableFrom 216.16.18.137 icmp_seq=6 Destination Host UnreachableFrom 216.16.18.137 icmp_seq=7 Destination Host UnreachableFrom 216.16.18.137 icmp_seq=8 Destination Host Unreachable^C--- 216.16.18.222 ping statistics ---9 packets transmitted, 0 received, +6 errors, 100% packet loss, time 8297mspipe 3[root@cognoswithdb2 ~]#
难道是网关的问题,我再添加一个网关
[root@cognoswithdb2 ~]# ifconfig eth0:0 216.16.18.137 gateway 216.16.18.254[root@cognoswithdb2 ~]# ifconfigeth0 Link encap:Ethernet HWaddr 00:0C:29:3F:6B:0A inet addr:192.168.0.102 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe3f:6b0a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:862 errors:0 dropped:0 overruns:0 frame:0 TX packets:737 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:164683 (160.8 KiB) TX bytes:79411 (77.5 KiB)eth0:0 Link encap:Ethernet HWaddr 00:0C:29:3F:6B:0A inet addr:216.16.18.254 Bcast:216.16.18.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:34 errors:0 dropped:0 overruns:0 frame:0 TX packets:34 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2720 (2.6 KiB) TX bytes:2720 (2.6 KiB)[root@cognoswithdb2 ~]# ping 216.16.18.222PING 216.16.18.222 (216.16.18.222) 56(84) bytes of data.From 216.16.18.254 icmp_seq=2 Destination Host UnreachableFrom 216.16.18.254 icmp_seq=3 Destination Host UnreachableFrom 216.16.18.254 icmp_seq=4 Destination Host Unreachable^C--- 216.16.18.222 ping statistics ---7 packets transmitted, 0 received, +3 errors, 100% packet loss, time 6560mspipe 3
再试一下这样的
[root@cognoswithdb2 ~]# ifconfig eth0:0 216.16.18.221 netmask 255.255.255.0[root@cognoswithdb2 ~]# ifconfigeth0 Link encap:Ethernet HWaddr 00:0C:29:3F:6B:0A inet addr:192.168.0.102 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe3f:6b0a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1233 errors:0 dropped:0 overruns:0 frame:0 TX packets:1104 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:208348 (203.4 KiB) TX bytes:118816 (116.0 KiB)eth0:0 Link encap:Ethernet HWaddr 00:0C:29:3F:6B:0A inet addr:216.16.18.221 Bcast:216.16.18.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:40 errors:0 dropped:0 overruns:0 frame:0 TX packets:40 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3392 (3.3 KiB) TX bytes:3392 (3.3 KiB)[root@cognoswithdb2 ~]# ping 216.16.18.221PING 216.16.18.221 (216.16.18.221) 56(84) bytes of data.64 bytes from 216.16.18.221: icmp_seq=1 ttl=64 time=0.167 ms64 bytes from 216.16.18.221: icmp_seq=2 ttl=64 time=0.088 ms64 bytes from 216.16.18.221: icmp_seq=3 ttl=64 time=0.087 ms^C--- 216.16.18.221 ping statistics ---3 packets transmitted, 3 received, 0% packet loss, time 2281msrtt min/avg/max/mdev = 0.087/0.114/0.167/0.037 ms[root@cognoswithdb2 ~]# ping 216.16.18.222PING 216.16.18.222 (216.16.18.222) 56(84) bytes of data.From 216.16.18.221 icmp_seq=1 Destination Host UnreachableFrom 216.16.18.221 icmp_seq=2 Destination Host UnreachableFrom 216.16.18.221 icmp_seq=3 Destination Host UnreachableFrom 216.16.18.221 icmp_seq=5 Destination Host UnreachableFrom 216.16.18.221 icmp_seq=6 Destination Host UnreachableFrom 216.16.18.221 icmp_seq=7 Destination Host UnreachableFrom 216.16.18.221 icmp_seq=9 Destination Host UnreachableFrom 216.16.18.221 icmp_seq=10 Destination Host UnreachableFrom 216.16.18.221 icmp_seq=11 Destination Host Unreachable^C--- 216.16.18.222 ping statistics ---12 packets transmitted, 0 received, +9 errors, 100% packet loss, time 11568mspipe 3[root@cognoswithdb2 ~]#
为什么一直ping不同,我想一定是网关的问题
[root@cognoswithdb2 ~]# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface192.168.0.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0216.16.18.0 0.0.0.0 255.255.255.0 U 0 0 0 eth00.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0[root@cognoswithdb2 ~]# route add defaule gw 216.16.18.254[root@cognoswithdb2 ~]# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface123.129.254.12 216.16.18.254 255.255.255.255 UGH 0 0 0 eth0192.168.0.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0216.16.18.0 0.0.0.0 255.255.255.0 U 0 0 0 eth00.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0[root@cognoswithdb2 ~]# ping 216.16.18.222PING 216.16.18.222 (216.16.18.222) 56(84) bytes of data.From 216.16.18.221 icmp_seq=2 Destination Host UnreachableFrom 216.16.18.221 icmp_seq=3 Destination Host UnreachableFrom 216.16.18.221 icmp_seq=4 Destination Host Unreachable^C--- 216.16.18.222 ping statistics ---5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4808mspipe 3
[root@cognoswithdb2 ~]# ip route show123.129.254.12 via 216.16.18.254 dev eth0192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.102 metric 1216.16.18.0/24 dev eth0 proto kernel scope link src 216.16.18.221default via 192.168.0.1 dev eth0 proto static
--
[root@cognoswithdb2 network-scripts]# route add default gw 216.16.18.254 dev eth0:0[root@cognoswithdb2 network-scripts]# ifconfigeth0 Link encap:Ethernet HWaddr 00:0C:29:3F:6B:0A inet addr:192.168.0.102 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe3f:6b0a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3574 errors:0 dropped:0 overruns:0 frame:0 TX packets:2774 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:465950 (455.0 KiB) TX bytes:329172 (321.4 KiB)eth0:0 Link encap:Ethernet HWaddr 00:0C:29:3F:6B:0A inet addr:216.16.18.237 Bcast:216.16.18.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:68 errors:0 dropped:0 overruns:0 frame:0 TX packets:68 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:6360 (6.2 KiB) TX bytes:6360 (6.2 KiB)[root@cognoswithdb2 network-scripts]# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface192.168.0.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0216.16.18.0 0.0.0.0 255.255.255.0 U 0 0 0 eth00.0.0.0 216.16.18.254 0.0.0.0 UG 0 0 0 eth00.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0[root@cognoswithdb2 network-scripts]# ping 216.16.18.222PING 216.16.18.222 (216.16.18.222) 56(84) bytes of data.From 216.16.18.237 icmp_seq=2 Destination Host UnreachableFrom 216.16.18.237 icmp_seq=3 Destination Host UnreachableFrom 216.16.18.237 icmp_seq=4 Destination Host Unreachable^C--- 216.16.18.222 ping statistics ---6 packets transmitted, 0 received, +3 errors, 100% packet loss, time 5587mspipe 3
算了,没办法了。暂时先放着吧!!!
---一段时间后
重启虚拟机,修改ifcfg-eth0文件
[root@cognoswithdb2 ~]# cd /etc/sysconfig/network-scripts/[root@cognoswithdb2 network-scripts]# more ifcfg-eth0DEVICE=eth0BOOTPROTO=static IPADDR=216.16.18.235NETMASK=255.255.255.0 ONBOOT=yes TYPE=Ethernet GATEWAY=216.16.18.254[root@cognoswithdb2 network-scripts]#
重启service network restart
[root@cognoswithdb2 network-scripts]# ifconfigeth0 Link encap:Ethernet HWaddr 00:0C:29:3F:6B:0A inet addr:216.16.18.235 Bcast:216.16.18.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe3f:6b0a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:293207 errors:0 dropped:0 overruns:0 frame:0 TX packets:280 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:88680772 (84.5 MiB) TX bytes:25525 (24.9 KiB)lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:32 errors:0 dropped:0 overruns:0 frame:0 TX packets:32 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2648 (2.5 KiB) TX bytes:2648 (2.5 KiB)[root@cognoswithdb2 network-scripts]#
ping一下局域网内的IP及本机IP
[root@cognoswithdb2 network-scripts]# ping 216.16.16.234PING 216.16.16.234 (216.16.16.234) 56(84) bytes of data.64 bytes from 216.16.16.234: icmp_seq=1 ttl=251 time=3.20 ms64 bytes from 216.16.16.234: icmp_seq=2 ttl=251 time=1.94 ms^C--- 216.16.16.234 ping statistics ---2 packets transmitted, 2 received, 0% packet loss, time 1708msrtt min/avg/max/mdev = 1.947/2.573/3.200/0.628 ms[root@cognoswithdb2 network-scripts]# ping 216.16.18.254PING 216.16.18.254 (216.16.18.254) 56(84) bytes of data.64 bytes from 216.16.18.254: icmp_seq=1 ttl=255 time=13.6 ms64 bytes from 216.16.18.254: icmp_seq=2 ttl=255 time=1.28 ms64 bytes from 216.16.18.254: icmp_seq=3 ttl=255 time=3.05 ms^C--- 216.16.18.254 ping statistics ---3 packets transmitted, 3 received, 0% packet loss, time 2412msrtt min/avg/max/mdev = 1.286/6.004/13.673/5.470 ms[root@cognoswithdb2 network-scripts]# ping 216.16.18.222PING 216.16.18.222 (216.16.18.222) 56(84) bytes of data.64 bytes from 216.16.18.222: icmp_seq=1 ttl=64 time=0.709 ms64 bytes from 216.16.18.222: icmp_seq=2 ttl=64 time=0.602 ms64 bytes from 216.16.18.222: icmp_seq=3 ttl=64 time=0.594 ms^C--- 216.16.18.222 ping statistics ---3 packets transmitted, 3 received, 0% packet loss, time 2037msrtt min/avg/max/mdev = 0.594/0.635/0.709/0.052 ms[root@cognoswithdb2 network-scripts]#
看下路由
[root@cognoswithdb2 network-scripts]# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface216.16.18.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth00.0.0.0 216.16.18.254 0.0.0.0 UG 0 0 0 eth0[root@cognoswithdb2 network-scripts]#
ping一下外网
[root@cognoswithdb2 network-scripts]# ping 121.197.8.155PING 121.197.8.155 (121.197.8.155) 56(84) bytes of data.From 216.16.18.254 icmp_seq=1 Destination Host UnreachableFrom 216.16.18.254 icmp_seq=2 Destination Host UnreachableFrom 216.16.18.254 icmp_seq=3 Destination Host UnreachableFrom 216.16.18.254 icmp_seq=4 Destination Host UnreachableFrom 216.16.18.254 icmp_seq=5 Destination Host UnreachableFrom 216.16.18.254 icmp_seq=6 Destination Host Unreachable^C--- 121.197.8.155 ping statistics ---6 packets transmitted, 0 received, +6 errors, 100% packet loss, time 5821ms
在这样设置看下
[root@cognoswithdb2 ~]# ifconfig eth0:0 192.168.0.99 up[root@cognoswithdb2 ~]# ifconfigeth0 Link encap:Ethernet HWaddr 00:0C:29:3F:6B:0A inet addr:216.16.18.235 Bcast:216.16.18.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe3f:6b0a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:317792 errors:0 dropped:0 overruns:0 frame:0 TX packets:788 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:96112673 (91.6 MiB) TX bytes:84756 (82.7 KiB)eth0:0 Link encap:Ethernet HWaddr 00:0C:29:3F:6B:0A inet addr:192.168.0.99 Bcast:192.168.0.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:44 errors:0 dropped:0 overruns:0 frame:0 TX packets:44 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3784 (3.6 KiB) TX bytes:3784 (3.6 KiB)[root@cognoswithdb2 ~]# routeKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface192.168.0.0 * 255.255.255.0 U 0 0 0 eth0216.16.18.0 * 255.255.255.0 U 0 0 0 eth0link-local * 255.255.0.0 U 1002 0 0 eth0default 216.16.18.254 0.0.0.0 UG 0 0 0 eth0[root@cognoswithdb2 ~]# ping 192.168.0.101PING 192.168.0.101 (192.168.0.101) 56(84) bytes of data.From 192.168.0.99 icmp_seq=1 Destination Host UnreachableFrom 192.168.0.99 icmp_seq=2 Destination Host UnreachableFrom 192.168.0.99 icmp_seq=3 Destination Host Unreachable^C--- 192.168.0.101 ping statistics ---4 packets transmitted, 0 received, +3 errors, 100% packet loss, time 3560mspipe 3[root@cognoswithdb2 ~]# route add default gw 192.168.0.1[root@cognoswithdb2 ~]# ping 192.168.0.101PING 192.168.0.101 (192.168.0.101) 56(84) bytes of data.From 192.168.0.99 icmp_seq=1 Destination Host UnreachableFrom 192.168.0.99 icmp_seq=2 Destination Host UnreachableFrom 192.168.0.99 icmp_seq=3 Destination Host Unreachable^C--- 192.168.0.101 ping statistics ---5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4224mspipe 3[root@cognoswithdb2 ~]# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0216.16.18.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth00.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth00.0.0.0 216.16.18.254 0.0.0.0 UG 0 0 0 eth0[root@cognoswithdb2 ~]#
ping 一下网关试试
[root@cognoswithdb2 ~]# ping 192.168.0.1PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=14.4 ms64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=1.32 ms64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=1.19 ms64 bytes from 192.168.0.1: icmp_seq=4 ttl=64 time=1.32 ms^C--- 192.168.0.1 ping statistics ---4 packets transmitted, 4 received, 0% packet loss, time 3612msrtt min/avg/max/mdev = 1.196/4.571/14.446/5.701 ms[root@cognoswithdb2 ~]#
为什么会这样?
然后我又这样
[root@cognoswithdb2 network-scripts]# vi ifcfg-eth0:0USERCTL=noPEERDNS=noDEVICE=eth0:0BOOTPROTO=staticIPADDR=192.168.0.88NETMASK=255.255.255.0ONBOOT=yesTYPE=EthernetGATEWAY=192.168.0.1[root@cognoswithdb2 network-scripts]# service network restart[root@cognoswithdb2 network-scripts]# ifconfigeth0 Link encap:Ethernet HWaddr 00:0C:29:3F:6B:0A inet addr:216.16.18.235 Bcast:216.16.18.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe3f:6b0a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:382264 errors:0 dropped:0 overruns:0 frame:0 TX packets:1435 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:115653692 (110.2 MiB) TX bytes:160790 (157.0 KiB)eth0:0 Link encap:Ethernet HWaddr 00:0C:29:3F:6B:0A inet addr:192.168.0.88 Bcast:192.168.0.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:62 errors:0 dropped:0 overruns:0 frame:0 TX packets:62 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:5696 (5.5 KiB) TX bytes:5696 (5.5 KiB)[root@cognoswithdb2 network-scripts]# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0216.16.18.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth00.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth00.0.0.0 216.16.18.254 0.0.0.0 UG 0 0 0 eth0[root@cognoswithdb2 network-scripts]#[root@cognoswithdb2 network-scripts]# ping 192.168.0.101PING 192.168.0.101 (192.168.0.101) 56(84) bytes of data.From 192.168.0.88 icmp_seq=2 Destination Host UnreachableFrom 192.168.0.88 icmp_seq=3 Destination Host UnreachableFrom 192.168.0.88 icmp_seq=4 Destination Host Unreachable^C--- 192.168.0.101 ping statistics ---5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4557mspipe 3[root@cognoswithdb2 network-scripts]# ping 192.168.0.1PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=12.9 ms64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=1.77 ms64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=1.37 ms64 bytes from 192.168.0.1: icmp_seq=4 ttl=64 time=1.36 ms^C--- 192.168.0.1 ping statistics ---4 packets transmitted, 4 received, 0% packet loss, time 3282msrtt min/avg/max/mdev = 1.364/4.356/12.909/4.940 ms[root@cognoswithdb2 network-scripts]# ping 121.197.8.155PING 121.197.8.155 (121.197.8.155) 56(84) bytes of data.^C--- 121.197.8.155 ping statistics ---6 packets transmitted, 0 received, 100% packet loss, time 5546ms
http://blog.csdn.net/jiedushi/article/details/6117010
http://codingstandards.iteye.com/blog/1130135http://codingstandards.iteye.com/blog/1130135