实例二:
网络结构如图1.2-2所示:
Router1上增加了一个LAN的接口:
Router1(config)#interface e0/1
Router1(config-if)#ip address
Router1(config-if)#ip address 20.0.0.1 255.255.255.0结果LAN上的一台PC机能Ping通Router1,但却无法Ping通Router2,而在Router1上却能Ping通Router2。
Router1#Ping 12002
Type escape sequence to abort
Sending 5,100-byte ICMP Echos to 12002,timeout is 2 seconds:
!!!!!
Success rate is 100 percent(5/5),round-trip min/avg/max=4/7/9 ms
Route1#
5d23h:IP:s=12001(local),d=12002(Serial0/0),Len 100,sending
5d23h:IP:s=12002(Serial0/0),d=12001(Serial0/0),Len 100,rcvd 3
在路由器上使用普通Ping时,其源IP地址为路由器上Ping包所出去的接口IP地址,
在路由器上能通过使用扩展的Ping命令来更改默认的源IP地址。现在在router1上通过使用
扩展的Ping命令来模拟从LAN上发包到Router2:
Router1#Ping
Protocol [ip]:
Target IP address: 12.0.0.2
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 20.0.0.1
Type of service [0]:
Set DF bit in IP header? [no]
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Ethos to 12.0.0.2, timeout is 2 seconds:
5d23h: IP: s=20.0.0.1 (local), d=12.0.0.2 (Serial0/0), Len 100, sending.
……
Success rate is 0 percent (0/5)
从上面的信息看,当源IP地址为2000,1的时候,Router1能发包到Router2,只是无法收到Router2的响应包。解决的办法很简单,只有在Router2上增加一条路由到20000就可以了。Ping成功的基本原则就是被Ping设备也必须知道如何发送回包到发起Ping的源地址。从Router1能Ping通Router2是因为默认下是把包出口的接口的IP地址作为源地址。但由于原先Router2并不知道新的LAN,所以当源地址为新的LAN的时候,就不知道如何发送回包到新的LAN。 从以上两个实例中可以看出来,在Debug命令的帮助下,我们也能通过Ping命令来发现和解决网络中的一些比较复杂的故障,而并不只是把它简单地作为测试网络是否通的工具而已。特别是路由器中的扩展的Ping命令所具有的可以任意设定源IP地址的特性,在实际使用当中更是能给我们在判断网络故障等方面带来很多的方便。