ip classless 可以改變路由選路的方式,那具體對實際的應用有什麼影響呢?網上流傳的版本挺多,但是通過自己的實驗發現其實他們說的都不是太全面,官方文檔也找不出適合的解釋,還是通過實驗找到了自己想要的答案,下面就和大家分享下我做的實驗吧
一. 實驗目的
通過實驗驗證 Ip classless 和no ip classless 對路由選路的影響
二. 實驗拓撲
三. 實驗配置
在這裏只給了主要配置,地址在圖中已經標明瞭,也不用浪費篇幅了。
R12(config)#ip route 0.0.0.0 0.0.0.0 16.16.16.1
四. 驗證結果
R12#show ip route
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 16.16.16.0/24 is directly connected, Serial0
S* 0.0.0.0/0 [1/0] via 16.16.16.1
R16#show ip route
10.0.0.0/24 is subnetted, 1 subnets
C 10.4.1.0 is directly connected, Loopback0
11.0.0.0/24 is subnetted, 1 subnets
C 11.4.1.0 is directly connected, Loopback1
C 16.16.16.0/24 is directly connected, Serial0
① 在R12上關閉ip classless
R12(config)#no ip class
R12(config)#end
R12#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)
R12#
R12#debug ip pac
IP packet debugging is on
R12#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:
00:10:37: IP: s=10.1.1.1 (local), d=10.4.1.1, len 100, unroutable.
00:10:39: IP: s=10.1.1.1 (local), d=10.4.1.1, len 100, unroutable.
00:10:41: IP: s=10.1.1.1 (local), d=10.4.1.1, len 100, unroutable.
00:10:43: IP: s=10.1.1.1 (local), d=10.4.1.1, len 100, unroutable.
00:10:45: IP: s=10.1.1.1 (local), d=10.4.1.1, len 100, unroutable.
Success rate is 0 percent (0/5)
② 在R12上開啓ip classless
R12(config)#ip class
R12(config)#end
R12#
00:11:03: %SYS-5-CONFIG_I: Configured from console by console
R12#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 = 40/40/44 ms
R12#
00:11:11: IP: s=16.16.16.2 (local), d=10.4.1.1 (Serial0), len 100, sending
00:11:12: IP: s=10.4.1.1 (Serial0), d=16.16.16.2 (Serial0), len 100, rcvd 3
00:11:12: IP: s=16.16.16.2 (local), d=10.4.1.1 (Serial0), len 100, sending
00:11:12: IP: s=10.4.1.1 (Serial0), d=16.16.16.2 (Serial0), len 100, rcvd 3
00:11:12: IP: s=16.16.16.2 (local), d=10.4.1.1 (Serial0), len 100, sending
00:11:12: IP: s=10.4.1.1 (Serial0), d=16.16.16.2 (Serial0), len 100, rcvd 3
00:11:12: IP: s=16.16.16.2 (local), d=10.4.1.1 (Serial0), len 100, sending
00:11:12: IP: s=10.4.1.1 (Serial0), d=16.16.16.2 (Serial0), len 100, rcvd 3
00:11:12: IP: s=16.16.16.2 (local), d=10.4.1.1 (Serial0), len 100, sending
00:11:12: IP: s=10.4.1.1 (Serial0), d=16.16.16.2 (Serial0), len 100, rcvd 3
五. 結論
①關閉ip classless 之後,首先路由器會在自己的路由表尋找隸屬的標準網段,如果找到自己隸屬的標準網段,就在此標準網段裏找是否有適合自己的路由條目,如果符合就轉發,不符合就會丟棄,就算配置了默認路由也不會使用。
②開啓ip classless 之後,如果路由器找不到隸屬的標準網段,就會使用默認路由進行轉發。
但是做過實驗驗證的會發現,和上面的結果不一樣,那就是IOS版本的問題了
經過我做實驗發現,在V12.3和其之前的版本:結果和上面的一致,關閉ip classless 之後不會向外發包,
但 是版本V12.4就變了,關閉 ip classless之後,數據包還往是會往外發,只不過默認ping包發送的源地址是環回接口,並不是正常的送出接口。這時候如果對端配置了回來的路由, 就依舊可以ping通。但是在對端沒有路由的情況下,關閉ip classless就不可以ping通了。這就是爲什麼對方配置了靜態路由,自己也關閉了ip classless還是可以ping通的原因!
好了,問題解決了!希望對大家有所幫助!
本文鏈接地址:http://www.free1990.com/cisco/19.html