測試連通性 打開其余兩臺路由器,按上述方法進行配置,然后就可以檢查它們之間是否連通了。 測試線路連通性的方法有三種,ping、traceroute和telnet。ping可以檢測目的地是否可達;trace不僅檢測連通性,還給出到達目的地所經過的路徑;telnet測試應用層軟件的連通性,如下所示。 testBJ#ping 172.16.4.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 172.16.4.2, timeout is 2 seconds: !!!!! SUCcess rate is 100 percent (5/5), round-trip min/avg/max = 24/25/28 ms testBJ#traceroute 172.16.4.2 Type escape sequence to abort. Tracing the route to 172.16.4.2 1 172.16.2.2 16 msec 16 msec * testBJ#telnet 172.16.4.2 Trying 172.16.4.2 ... Open User Access Verification Password: testTJ> 172.16.4.2是路由器testTJ上的一個端口,我們在testBJ上運行上述三個命令,得知它運行正常。
顯示當前狀態 為了使網絡治理員能夠方便地了解路由器的狀態,CISCO路由器提供了豐富的show命令。我們在這里介紹最簡單的幾個,如下所示。 show version命令顯示路由器的硬軟件版本號及配置信息。 show flash:命令相當于DOS的dir命令,顯示flash中包含的文件信息。 show interface命令顯示網絡接口的狀態。 配置路由器的過程中,最重要的一個show命令莫過于查看配置文件的內容,可以用show命令查看running-config或startup-config,如下所示。 show running-config show startup-config 配置文件是一個文本文件,其中包含著你鍵入的每一條配置命令。可以將配置文件下載到計算機上,用文本編輯器修改之后,再傳回路由器。
三、RIP要配什么
IP地址配置 我們可以使用interface命令進入局部配置模式,然后利用ip address設置接口的IP地址。如下所示。 testBJ#conf t Enter configuration commands, one per line. End with CNTL/Z. testBJ(config)#interface e0/1 testBJ(config-if)#ip address 172.16.1.2 255.255.255.0 testBJ(config-if)# 為了便于配置和記憶,你還可以給每個端口添加一些描述信息。如下所示,在端口局部配置模式下使用description命令。 testBJ(config-if)#description connect to testSH testBJ(config-if)#end testBJ# 有些網絡是NBMA(Non-Broadcast MultiAccess,非廣播多路訪問)的,即網絡上不答應廣播傳送數據。對于這種網絡,RIP就不能依靠廣播傳遞路由表了。解決方法有很多,最簡單的是指定鄰居(neighbor),即指定將路由表發送給某一臺特定的路由器。 有些網絡是NBMA(Non-Broadcast MultiAccess,非廣播多路訪問)的,即網絡上不答應廣播傳送數據。對于這種網絡,RIP就不能依靠廣播傳遞路由表了。解決方法有很多,最簡單的是指定鄰居(neighbor),即指定將路由表發送給某一臺特定的路由器。
測試配置正確性 配置RIP之后,要檢查數據是否可以被正確路由。除了可以使用上面提到的連通性測試工具之外,還有以下幾個命令: ? sh ip route用于檢測路由表; ? sh ip protocols用于檢查路由協議狀況; ? debug ip rip用于調試RIP協議信息。 使用sh ip route命令顯示各臺路由器的路由表。 testBJ#sh ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default, U - per-user static route, o - ODR Gateway of last resort is not set 172.16.0.0/24 is subnetted, 4 subnets R 172.16.4.0 [120/1] via 172.16.2.2, 00:00:12, Serial1/0 C 172.16.1.0 is directly connected, Ethernet0/1 C 172.16.2.0 is directly connected, Serial1/0 R 172.16.3.0 [120/1] via 172.16.1.3, 00:00:09, Ethernet0/1 [120/1] via 172.16.2.2, 00:00:22, Serial1/0 上面顯示的是北京路由器的路由信息。字母C開頭的是直接相連的網絡,有172.16.1.0和172.16.2.0,分別連接在e0/1和s1/0端口上。字母R開頭的是RIP協議學習到的路由,有172.16.3.0和172.16.4.0,其中,到172.16.3.0有兩條路徑供選擇,分別經由testSH和testTJ路由器。對比網絡拓撲圖,可以看出實際情況與設計的完全一致。 中括號里的內容是路由項的治理距離和度量值,RIP的缺省治理距離是120,到達3、4子網的度量值是1,即經過1個路由器可達。 同樣的命令在另外兩臺路由器上運行,結果如下。 testSH#sh ip route Gateway of last resort is not set 172.16.0.0/24 is subnetted, 4 subnets R 172.16.4.0 [120/1] via 172.16.3.2, 00:00:13, Ethernet0/0 C 172.16.1.0 is directly connected, Ethernet0/1 R 172.16.2.0 [120/1] via 172.16.1.2, 00:00:11, Ethernet0/1 [120/1] via 172.16.3.2, 00:00:13, Ethernet0/0 C 172.16.3.0 is directly connected, Ethernet0/0
testTJ#sh ip route Gateway of last resort is not set 172.16.0.0/24 is subnetted, 4 subnets C 172.16.4.0 is directly connected, Ethernet0/0 R 172.16.1.0 [120/1] via 172.16.3.3, 00:00:07, Ethernet0/1 [120/1] via 172.16.2.3, 00:00:19, Serial1/0 C 172.16.2.0 is directly connected, Serial1/0 C 172.16.3.0 is directly connected, Ethernet0/1 分析上述命令輸出時,一定要隨時參照拓撲圖,離開網絡拓撲,上面的信息就沒有任何意義。動態路由的靈活性體現在一條鏈路出現故障,路由算法會自動切換到迂回鏈路上。例如我們將testBJ和testTJ之間的串行線纜斷開,一段時間后,再檢查路由表,如下所示。 testBJ#sh ip route Gateway of last resort is not set 172.16.0.0/24 is subnetted, 3 subnets R 172.16.4.0 [120/2] via 172.16.1.3, 00:00:22, Ethernet0/1 C 172.16.1.0 is directly connected, Ethernet0/1 R 172.16.3.0 [120/1] via 172.16.1.3, 00:00:22, Ethernet0/1 我們發現串行鏈路所在的子網2斷開了,到網絡172.16.4.0網絡的數據包都將繞經testSH路由器。 sh ip protocols命令可以顯示當前路由協議的狀況,如下所示。 testBJ#sh ip protocols Routing Protocol is "rip" Sending updates every 30 seconds, next due in 19 seconds Invalid after 180 seconds, hold down 180, flushed after 240 Outgoing update filter list for all interfaces is not set Incoming update filter list for all interfaces is not set Redistributing: connected, rip Default version control: send version 1, receive any version Interface Send Recv Key-chain Ethernet0/1 1 1 2 Serial1/0 1 1 2 Routing for Networks: 172.16.0.0 Routing Information Sources: Gateway Distance Last Update 172.16.2.2 120 00:00:05 172.16.1.3 120 00:00:27 Distance: (default is 120) 從命令輸出中,可以看出RIP協議的基本配置,還可以得知與當前路由器交換信息的路由器有testTJ(172.16.2.2)和testSH(172.16.1.3)兩臺路由器,上次接收路由信息分別在5秒和27秒之前。 要了解路由器之間交換路由信息的詳情,可以使用debug ip rip命令。如下所示,輸入命令后,隔一段時間,控制臺上出現接收或者發送RIP廣播的信息。 testBJ#debug ip rip RIP protocol debugging is on testBJ# RIP: received v1 update from 172.16.2.2 on Serial1/0 172.16.4.0 in 1 hops 172.16.3.0 in 1 hops RIP: received v1 update from 172.16.1.3 on Ethernet0/1 172.16.4.0 in 2 hops 172.16.3.0 in 1 hops RIP: sending v1 update to 255.255.255.255 via Ethernet0/1 (172.16.1.2) subnet 172.16.4.0, metric 2 subnet 172.16.2.0, metric 1 RIP: sending v1 update to 255.255.255.255 via Serial1/0 (172.16.2.3) subnet 172.16.1.0, metric 1 RIP: received v1 update from 172.16.1.3 on Ethernet0/1 172.16.4.0 in 2 hops 172.16.3.0 in 1 hops RIP: received v1 update from 172.16.2.2 on Serial1/0 172.16.4.0 in 1 hops 172.16.3.0 in 1 hops testBJ#no debug all All possible debugging has been turned off testBJ# 從上述信息中可以得到RIP廣播的詳情。路由器先是從testTJ收到子網3、4的信息,然后又從testSH收到子網3、4的信息。其中,到子網4走testTJ一跳,走testSH兩跳,所以,路由表中反映出來的是經由testTJ到子網4;到子網3的距離都是一跳,所以,路由表中有兩條并列的路由。 一段時間后,當前路由器的更新計時達到30秒,于是,它在兩條鏈路上廣播自身的路由表信息。注重,廣播路由更新時,RIP采用了水平分割機制,從一個端口上學得的信息就不在這個端口上進行廣播,所以當前路由器testBJ只發送子網172.16.1.0的路由信息。 使用no debug all命令結束調試信息的顯示。需要注重的是debug命令非常消耗路由器資源,所以不要在通訊繁忙的路由器上使用,否則,路由器就會象死機一樣停止反應。