CCNA考點(diǎn)精析---IP路由表分析

字號:

當(dāng)frame到達(dá)路由器的接口后,路由器檢查frame中的目標(biāo)地址字段,如果目標(biāo)地址為路由器接口的地址或者廣播地址的時候,路由器把packet從frame中剝離出來,傳遞給network layer,然后packet中的目標(biāo)地址將被檢查,接下來還要檢查protocol字段,最后再發(fā)送給合適的進(jìn)程,如果packet是可路由的,路由器會查找自己路由表中尋找相應(yīng)的路由條目,路由條目至少包含兩個要素:
    1、目標(biāo)地址,這個地址是路由器必須能夠到達(dá)的地址;
    2、到達(dá)目標(biāo)地址的指針,這個指針也就是我們平時在路由表中看到的Via.或者是平時聽說的next-hop(下一跳)
    路由器根據(jù)packet中的目標(biāo)地址字段,在路由表中執(zhí)行查詢,查詢的精確程度按如下順序遞減:
    1、主機(jī)地址
    2、 子網(wǎng)地址
    3、匯總網(wǎng)絡(luò)號
    4、 主類網(wǎng)絡(luò)號
    5、 超網(wǎng)號(super net)
    6、 默認(rèn)路由
    如果在執(zhí)行完所有的表查詢后,還沒有找到匹配的條目,則丟棄packet,并回送一個(Destinnation Unreachable)ICMP不可達(dá)的報文給發(fā)送方
    在CISCO路由器上要查看路由表,可以使用特權(quán)命令:show ip route
    R1#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, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
     ia - IS-IS inter area, * - candidate default, U - per-user static route
     o - ODR, P - periodic downloaded static route
    Gateway of last resort is not set
    C 192.168.123.0/24 is directly connected, FastEthernet0/0
     1.0.0.0/24 is subnetted, 3 subnets
    C 1.1.1.0 is directly connected, Loopback0
    C 1.1.2.0 is directly connected, Loopback1
    C 1.1.3.0 is directly connected, Loopback2
    C 192.168.14.0/24 is directly connected, Serial1/2
    如果你只想檢查靜態(tài)的路由條目,則可以在show ip route命令后加上static參數(shù),依此類推……
    Configuration static routes
    配置靜態(tài)路由的步驟
    1、 首先確定好每條鏈路的地址
    2、 為每臺路由器找出非直連的鏈路
    3、 為每臺路由器的非直連鏈路寫出靜態(tài)條目(直連沒有必要寫)
    注:把未知交給已知
    R1(config)#ip route 2.2.1.2 255.255.255.0 192.168.12.2
    R1(config)#ip route 2.2.2.2 255.255.255.0 192.168.12.2
    R1(config)#ip route 2.2.3.2 255.255.255.0 192.168.12.2
    誰是自己的未知?——所有非直連的鏈路
    誰是自己的已知?——直連鏈路
    在直連鏈路上有兩種選擇:下一跳(next-hop)和出接口(interface)
    分別看一下兩者的區(qū)別
    下一跳是和自己直連路由器的接口地址,而出接口則是自己本身的接口名稱
    就好象一條隧道的入口和出口:出口就是下一跳,入口是出接口
    R1和R2通過FA0/0——FA0/0,S1/1——S1/0
    FA0/0口的IP分別為192.168.123.1/192.168.123.2
    S1/1的IP為:192.168.12.1
    S1/0的IP為:192.168.12.2
    它們各自有三條直連網(wǎng)段:
    1.1.1.1
    1.1.2.1
    1.1.3.1和
    2.2.1.2
    2.2.2.2
    2.2.3.2
    分析:
    對于R1來說,它的已知是:
    192.168.123.0/24
    192.168.12.0/24
    1.1.1.0/24
    1.1.2.0/24
    1.1.3.0/24
    對于R2來說,它的已知是:
    192.168.123.0/24
    192.168.12.0/24
    2.2.1.0/24
    2.2.2.0/24
    除已知條目外,其余全是它們各自的未知,此時我們可以用兩種辦法來配置靜態(tài)路由
    一、使用下一跳next-hop:
    R2(config)#ip route 1.1.1.0 255.255.255.0 192.168.123.1
    R2(config)#ip route 1.1.2.0 255.255.255.0 192.168.123.1
    R2(config)#ip route 1.1.3.0 255.255.255.0 192.168.123.1
    紅字標(biāo)識的即為next-hop
    看一下路由表:
    R2#sh ip route static
    1.0.0.0/24 is subnetted, 3 subnets
    S 1.1.1.0 [1/0] via 192.168.123.1
    S 1.1.2.0 [1/0] via 192.168.123.1
    S 1.1.3.0 [1/0] via 192.168.123.1
    到達(dá)三個未知的地方全部都交給了 via 192.168.123.1 ,注意[]里的數(shù)字[1/0]
    二、使用出接口interface:
    R1(config)#ip route 2.2.1.0 255.255.255.0 serial 1/1
    R1(config)#ip route 2.2.2.0 255.255.255.0 serial 1/1
    R1(config)#ip route 2.2.3.0 255.255.255.0 serial 1/1
    紅字標(biāo)識的地方即為出接口
    看一下路由表:
    R1#sh ip route static
    2.0.0.0/24 is subnetted, 3 subnets
    S 2.2.1.0 is directly connected, Serial1/1
    S 2.2.2.0 is directly connected, Serial1/1
    S 2.2.3.0 is directly connected, Serial1/1
    這里已經(jīng)沒有[]了。取而代之的是directly connected,說明路由器R1認(rèn)為這些條目都是自己直連的條目。
    路由器在路由選擇的過程中會比較哪條路是更好的路
    這時候如果用第一種方法給它配上相同的路由條目,看一下會出現(xiàn)什么情況:
    R1(config)#ip route 2.2.1.0 255.255.255.0 192.168.12.2
    R1(config)#ip route 2.2.2.0 255.255.255.0 192.168.12.2
    R1(config)#ip route 2.2.3.0 255.255.255.0 192.168.12.2
    R1#sh ip route sta
    R1#sh ip route static
    2.0.0.0/24 is subnetted, 3 subnets
    S 2.2.1.0 is directly connected, Serial1/1
    [1/0] via 192.168.12.2
    S 2.2.2.0 is directly connected, Serial1/1
    [1/0] via 192.168.12.2
    S 2.2.3.0 is directly connected, Serial1/1
    [1/0] via 192.168.12.2
    R1認(rèn)為現(xiàn)在R1到達(dá)R2后面的直連網(wǎng)絡(luò)可以有兩條路走了,其實(shí)只有這一條通道,卻被R1認(rèn)為是兩條不同的路??梢?,這兩種方法需要根據(jù)情況使用,否則可能會出現(xiàn)路由選擇的問題。
    Floating Static Routes
    設(shè)置一條管理距離稍大于正常使用的一條靜態(tài)路由,這樣一來,當(dāng)正常鏈路DOWN后,這條稍大的路由條目馬上可以UP起來替代正常路由條目工作。
    (1)Router(config)#ip route 1.1.1.0 255.255.255.0 192.168.123.2
    (2)Router(config)#ip route 1.1.1.0 255.255.255.0 192.168.12.2 50
    如上,當(dāng)(1)down后,(2)會自動地up,頂替(1)
    以下為例題:
    1、Users on the 172.17.22.0 network cannot reach the server located on the 172.31.5.0 network. The network administrator connected to router Coffee via the console port, issued the show ip route command, and was able to ping the server. Based on the output of the show ip route command and the topology shown in the graphic, what is the cause of the failure?
    A: The network has not fully converged.
    B: IP routing is not enabled.
    C: A static route is configured incorrectly.
    D: The FastEthernet interface on Coffee is disabled.
    E: The neighbor relationship table is not correctly updated.
    F: The routing table on Coffee has not updated .
    Correct Answers: C
    該題中,172.18.22.0網(wǎng)段的用戶無法訪問到172.31.5.0的服器,管理員通過show ip route命令看到了如下的路由表記錄,試分析哪些說法是正確的。
    首先比較以下兩條直連路由條目,正常;下面的一條靜態(tài)默認(rèn)路由的下一跳地址卻有問題,因?yàn)榫W(wǎng)絡(luò)中并沒有172.19.22.2這個地址。假設(shè)現(xiàn)在從 172.17.22.0有主機(jī)A向172.31.5.0中的SERVER發(fā)送信息,數(shù)據(jù)報文進(jìn)入Coffee后,Coffee經(jīng)過查表得知,該路由條目并未存在于路由表中,所以被匹配默認(rèn)路由,交給下一跳172.19.22.2,但是Coffee卻發(fā)現(xiàn)并不知道 172.19.22.2應(yīng)該怎么走,所以該數(shù)據(jù)包被丟棄。