路由器A通过S0端口与路由器B的S0端口连接
路由器A配置如下:
interface Loopback0
ip address 10.1.1.1 255.255.255.0
!
interface Loopback1
ip address 10.2.1.1 255.255.255.0
!
interface Loopback2
ip address 10.3.1.1 255.255.255.0
!
interface Serial0
ip address 192.168.0.1 255.255.255.0
!
ip route 0.0.0.0 0.0.0.0 192.168.0.2
!
debug ip packet,
show ip route显示路由器A的路由如下:
Gateway of last resort is 192.168.0.2 to network 0.0.0.0
10.0.0.0/24 is subnetted, 3 subnets
C 10.3.1.0 is directly connected, Loopback2
C 10.2.1.0 is directly connected, Loopback1
C 10.1.1.0 is directly connected, Loopback0
C 192.168.0.0/24 is directly connected, Serial0
S* 0.0.0.0/0 [1/0] via 192.168.0.2
路由器B配置如下:
interface Loopback0
ip address 10.4.1.1 255.255.255.0
!
interface Loopback1
ip address 11.4.1.1 255.255.255.0
!
interface Serial0
ip address 192.168.0.2 255.255.255.0
一 在路由器A上配置no ip classless,ping 10.4.1.1结果如下:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.4.1.1, timeout is 2
seconds:
.....
Success rate is 0 percent (0/5)
Router#
02:56:09: IP: s=10.1.1.1 (local), d=10.4.1.1, len 100,
unroutable
02:56:11: IP: s=10.1.1.1 (local), d=10.4.1.1, len 100,
unroutable
02:56:13: IP: s=10.1.1.1 (local), d=10.4.1.1, len 100,
unroutable
02:56:15: IP: s=10.1.1.1 (local), d=10.4.1.1, len 100,
unroutable
02:56:17: IP: s=10.1.1.1 (local), d=10.4.1.1, len 100,
unroutable
解释:主类(10.0.0.0)存在,但子网(10.4.0.0)不匹配,则路由器认为路由
不存在,也不会再使用默认路由.
二 在路由器A上配置no ip classless,启用debug ip packet,ping
11.4.1.1结果如下:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 11.4.1.1, timeout is 2
seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max =
16/16/16 ms
Router#
03:09:31: IP: s=192.168.0.1 (local), d=11.4.1.1 (Serial0), len
100, sending
03:09:31: IP: s=11.4.1.1 (Serial0), d=192.168.0.1 (Serial0), len
100, rcvd 3
03:09:31: IP: s=192.168.0.1 (local), d=11.4.1.1 (Serial0), len
100, sending
03:09:31: IP: s=11.4.1.1 (Serial0), d=192.168.0.1 (Serial0), len
100, rcvd 3
03:09:31: IP: s=192.168.0.1 (local), d=11.4.1.1 (Serial0), len
100, sending
03:09:31: IP: s=11.4.1.1 (Serial0), d=192.168.0.1 (Serial0), len
100, rcvd 3
03:09:31: IP: s=192.168.0.1 (local), d=11.4.1.1 (Serial0), len
100, sending
03:09:31: IP: s=11.4.1.1 (Serial0), d=192.168.0.1 (Serial0), len
100, rcvd 3
03:09:31: IP: s=192.168.0.1 (local), d=11.4.1.1 (Serial0)
Router#, len 100, sending
03:09:31: IP: s=11.4.1.1 (Serial0), d=192.168.0.1 (Serial0), len
100, rcvd 3
解释:如主类(11.0.0.0)不存在,则路由器还会使用默认路由.
三 在路由器A配置ip classless
ping 10.4.1.1结果如下:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.4.1.1, timeout is 2
seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max =
16/16/16 ms
Router#
03:01:41: IP: s=192.168.0.1 (local), d=10.4.1.1 (Serial0), len
100, sending
03:01:41: IP: s=10.4.1.1 (Serial0), d=192.168.0.1 (Serial0), len
100, rcvd 3
03:01:41: IP: s=192.168.0.1 (local), d=10.4.1.1 (Serial0), len
100, sending
03:01:41: IP: s=10.4.1.1 (Serial0), d=192.168.0.1 (Serial0), len
100, rcvd 3
03:01:41: IP: s=192.168.0.1 (local), d=10.4.1.1 (Serial0), len
100, sending
03:01:41: IP: s=10.4.1.1 (Serial0), d=192.168.0.1 (Serial0), len
100, rcvd 3
03:01:41: IP: s=192.168.0.1 (local), d=10.4.1.1 (Serial0), len
100, sending
03:01:41: IP: s=10.4.1.1 (Serial0), d=192.168.0.1 (Serial0), len
100, rcvd 3
03:01:41: IP: s=192.168.0.1 (local), d=10.4.1.1 (Serial0)
Router#, len 100, sending
03:01:41: IP: s=10.4.1.1 (Serial0), d=192.168.0.1 (Serial0), len
100, rcvd 3
ping 11.4.1.1结果如下:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 11.4.1.1, timeout is 2
seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max =
12/12/16 ms
Router#
03:19:40: IP: s=192.168.0.1 (local), d=11.4.1.1 (Serial0), len
100, sending
03:19:40: IP: s=11.4.1.1 (Serial0), d=192.168.0.1 (Serial0), len
100, rcvd 3
03:19:40: IP: s=192.168.0.1 (local), d=11.4.1.1 (Serial0), len
100, sending
03:19:40: IP: s=11.4.1.1 (Serial0), d=192.168.0.1 (Serial0), len
100, rcvd 3
03:19:40: IP: s=192.168.0.1 (local), d=11.4.1.1 (Serial0), len
100, sending
03:19:40: IP: s=11.4.1.1 (Serial0), d=192.168.0.1 (Serial0), len
100, rcvd 3
03:19:40: IP: s=192.168.0.1 (local), d=11.4.1.1 (Serial0), len
100, sending
03:19:40: IP: s=11.4.1.1 (Serial0), d=192.168.0.1 (Serial0), len
100, rcvd 3
03:19:40: IP: s=192.168.0.1 (local), d=11.4.1.1 (Serial0)
Router#, len 100, sending
03:19:40: IP: s=11.4.1.1 (Serial0), d=192.168.0.1 (Serial0), len
100, rcvd 3
解释:可以看到不论所查询路由的主类是否存在,路由器均使用了默认路由