視頻教程:https://edu.csdn.net/cour/detail/30858
視頻教程:https://edu.csdn.net/cour/detail/31400
文章每日實時更新
實驗?zāi)康?/p>
鞏固 Cisco IOS 的基本配置;
掌握靜態(tài)路由原理和配置命令;
掌握默認路由原理和配置命令。
拓撲及需求:
關(guān)鍵知識點
4. 基礎(chǔ)知識
本實驗主要考察靜態(tài)路由的概念及實現(xiàn)。對于 PC1 來說,如需訪問 192.168.1.0/24 以外的網(wǎng)
絡(luò),則要將數(shù)據(jù)先發(fā)向網(wǎng)關(guān) R1(因為 PC1 將網(wǎng)關(guān)地址設(shè)置為 192.168.1.254,也就是 R1 的
FE1/0 接口地址),因此 R1 要有到達遠端網(wǎng)絡(luò)的路由。在完成基本的 IP 配置后,R1 僅知曉
192.168.1.0/24 及 192.168.12.0/24 網(wǎng) 絡(luò) (直連路由),而對于 192.168.23.0/24 及
192.168.2.0/24 網(wǎng)絡(luò)卻并不知曉,因此需為其配置靜態(tài)路由。同理,R2、R3 也是一樣,這里
務(wù)必要考慮數(shù)據(jù)的雙向性,數(shù)據(jù)包有去得有回。
5. 關(guān)鍵命令
靜態(tài)路由的配置命令如下:
router(config)# ip route 目的網(wǎng)絡(luò) 網(wǎng)絡(luò)掩碼 下一跳地址/出接口
默認路由的配置命令如下:
router(config)# ip route 0.0.0.0 0.0.0.0 下一跳地址/出接口
配置及實現(xiàn)
完成基本配置、接口 IP 配置
搭建如圖所是的拓撲,完成各設(shè)備預(yù)配、接口 IP 地址的配置并進行相關(guān)測試。
R1 的配置如下:
Router> enable
Router# configure terminal
Router(config)# hostname R1
R1(config)# interface rial 0/0
R1(config-if)# ip address 192.168.12.1 255.255.255.0
R1(config-if)# no shutdown
R1(config-if)# interface fastethernet 1/0
R1(config-if)# ip address 192.168.1.254 255.255.255.0
R1(config-if)# no shutdown
R2 的配置如下:
Router> enable
Router# configure terminal
Router(config)# hostname R2
R2(config)# interface rial 0/0
R2(config-if)# clock rate 64000
R2(config-if)# ip address 192.168.12.2 255.255.255.0
R2(config-if)# no shutdown
R2(config-if)# interface rial 0/1
R2(config-if)# clock rate 64000
R2(config-if)# ip address 192.168.23.2 255.255.255.0
R2(config-if)# no shutdown
注意,R2 的 S0/0 及 S0/1 接口都是 DCE 端,因此要配置時鐘頻率(clock rate)。一條串行
鏈路兩端的接口誰是 DCE 誰是 DTE,在實驗室環(huán)境中取決于線纜,線纜的 DCE 頭接著哪端,
它就是 DCE 端。當然在實際的項目中,DCE 端往往是運營商那頭。
如果使用 GNS 模擬器做實驗,那么可以不用配置 clock rate,但是真機環(huán)境下,必須配置。
R3 的配置如下
Router> enable
Router# configure terminal
Router(config)# hostname R3
R3(config)# interface rial 0/0
R3(config-if)# ip address 192.168.23.3 255.255.255.0
R3(config-if)# no shutdown
R3(config-if)# interface fastethernet 1/0
R3(config-if)# ip address 192.168.2.254 255.255.255.0
R3(config-if)# no shutdown
對于 PC,我們是采用路由器來模擬,需要對其做以下配置
PC1(使用路由器來模擬):
Router> enable
Router# configure terminal
Router(config)# hostname PC1
PC1(config)# no ip routing !! 將路由器模擬成 PC 機,關(guān)閉路由功能
PC1(config)# ip default-gateway 192.168.1.254 !! 為 PC 機指定網(wǎng)關(guān)
PC1(config)#interface fastethernet 0/0
PC1(config-if)# ip address 192.168.1.1 255.255.255.0 !! 為 PC 配置 IP 地址
PC1(config-if)# no shutdown
注意:一旦配置no ip routing后,路由器就失去了路由功能了,因此必須使用 ip default-gateway
的方式為其設(shè)置默認網(wǎng)關(guān),而不能使用默認路由(ip route 0.0.0.0 0.0.0.0)的方式。
PC2 的配置如下:
Router> enable
Router# configure terminal
Router(config)# hostname PC2
PC2(config)# no ip routing
PC2(config)# ip default-gateway 192.168.2.254
PC2(config)# interface fastethernet 0/0
PC2(config-if)# ip address 192.168.2.1 255.255.255.0
PC2(config-if)# no shutdown
在完成上述配置后,PC 與各自的網(wǎng)關(guān)、路由器與各直連接口都能夠 ping 通。
測試 1:查看各設(shè)備直連接口狀態(tài)。
PC1# show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.1.1 YES manual up up
PC2#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.2.1 YES manual up up
R1#show ip interface brief
Interface IP-Address OK? Method Status Protocol
rial0/0 192.168.12.1 YES manual up up
FastEthernet1/0 192.168.1.254 YES manual up up
R2#show ip interface brief
Interface IP-Address OK? Method Status Protocol
rial0/0 192.168.12.2 YES manual up up
rial0/1 192.168.23.2 YES manual up up
R3#show ip interface brief
Interface IP-Address OK? Method Status Protocol
rial0/0 192.168.23.3 YES manual up up
FastEthernet1/0 192.168.2.254 YES manual up up
測試 1 結(jié)論:各設(shè)備通過命令 show ip intereface brief 檢測到各接口狀態(tài)和協(xié)議雙 up。
思考:若某接口的 Status up,Protocol down 是為什么?
測試 2:查看路由器直連網(wǎng)段是否能 ping 通。
R1# ping 192.168.1.1
Type escape quence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 conds:
!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/24/72 ms
R1#ping 192.168.12.2
Type escape quence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.12.2, timeout is 2 conds:
!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/29/56 ms
在 Cisco IOS 設(shè)備上使用 ping 命令來探測遠端節(jié)點的可達性時,如果看到一坨“!”,則表示
目的地可達。
R2 及 R3 的測試同理:
R2#ping 192.168.12.1
R2#ping 192.168.23.3
R3#ping 192.168.23.2
R3#ping 192.168.2.1
測試 2 結(jié)論:直連網(wǎng)段都能 ping 通。
測試 3:測試 PC1 和 PC2 能否正常通信。
PC1# ping 192.168.2.1
Type escape quence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 conds:
U.U.U !! ping 返回 U 表示目的主機不可達
Success rate is 0 percent (0/5)
思考:為什么 PC1 與 PC2 無法正常通信?查看相關(guān)路由表,首先從 PC1 開始查起:
PC1#show ip route
Default gateway is 192.168.1.254
Host Gateway Last U Total Us Interface
ICMP redirect cache is empty
PC1 已經(jīng)設(shè)置了缺省網(wǎng)關(guān) 192.168.1.254,因此當它發(fā)送數(shù)據(jù)到本地網(wǎng)段外的節(jié)點時,數(shù)據(jù)包
會被送到網(wǎng)關(guān),所以我們接著去它的網(wǎng)關(guān)也就是 R1 上看看。
R1# show ip route
192.168.1.0/24 is subnetted, 1 subnets
C 192.168.1.0 is directly connected, FastEthernet1/0
192.168.12.0/24 is subnetted, 1 subnets
C 192.168.12.0 is directly connected, rial 0/0
PC1 機可以 ping 通網(wǎng)關(guān),但無法與 PC2 通信,因為沿途路由器沒有相應(yīng)的路由條目,R1 的
路由表里并沒有到達 192.168.2.0/24 網(wǎng)絡(luò)的路由。
配置靜態(tài)路由,使 PC 之間可以互相通信
R1 配置去往 192.168.23.0/24 及 192.168.2.0/24 網(wǎng)段的路由
R1(config)# ip route 192.168.2.0 255.255.255.0 192.168.12.2
R1(config)# ip route 192.168.23.0 255.255.255.0 192.168.12.2
完成配置后查看路由表,可以看到我們剛才配置的靜態(tài)路由條目。
R1#show ip route
C 192.168.12.0/24 is directly connected, Serial0/0
S 192.168.23.0/24 [1/0] via 192.168.12.2
C 192.168.1.0/24 is directly connected, FastEthernet1/0
S 192.168.2.0/24 [1/0] via 192.168.12.2
以上輸出的就是 R1 的路由表了:
? 從路由表中可以看到,一共有四個條目,也就是四條路由,其中兩條路由標記為“C”,
也就是 Connected,意思是直連網(wǎng)段的路由。另外還有兩條標記為“S”,也就是 Static 靜
態(tài)路由,正是我們?yōu)?R1 配置的兩條靜態(tài)路由。
? 路由條目中的 [1/0] 意思是路由的 [管理距離/度量值]。
? 路由條目中的 via 192.168.12.2,是下一跳 IP 地址。
接著為 R2 配置去往 192.168.1.0/24 及 192.168.2.0/24 網(wǎng)段的路由:
R2(config)# ip route 192.168.2.0 255.255.255.0 192.168.23.3
!! R2 配置去往 PC2 所在網(wǎng)段的靜態(tài)路由
R2(config)# ip route 192.168.1.0 255.255.255.0 192.168.12.1
!! R2 配置去往 PC1 所在網(wǎng)段的靜態(tài)路由
R3 配置去往 192.168.1.0/24 及 192.168.12.0/24 網(wǎng)段的路由:
R3(config)# ip route 192.168.1.0 255.255.255.0 192.168.23.2
R3(config)# ip route 192.168.12.0 255.255.255.0 192.168.23.2
測試 4:查看兩臺 PC1 是否能夠 ping 通 PC2。
PC1#ping 192.168.2.1
Type escape quence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 conds:
!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 56/91/124 ms
測試 5:查看 PC1 能否 ping 通 192.168.23.0/24 網(wǎng)段
PC1#ping 192.168.23.3
Type escape quence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.23.3, timeout is 2 conds:
!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 56/91/124 ms
將 R1、R3 的靜態(tài)路由 no 掉,改為默認路由
R1 的配置如下:
R1(config)# no ip route 192.168.2.0 255.255.255.0 192.168.12.2
R1(config)# no ip route 192.168.23.0 255.255.255.0 192.168.12.2
R1(config)# ip route 0.0.0.0 0.0.0.0 192.168.12.2
去掉之前靜態(tài)路由的配置,配置默認路由。默認路由可以匹配任何目的地,通常用在網(wǎng)絡(luò)的出
口設(shè)備上,完成配置后查看路由表:
R1#show ip route
C 192.168.12.0/24 is directly connected, Serial0/0
C 192.168.1.0/24 is directly connected, FastEthernet1/0
S* 0.0.0.0/0 [1/0] via 192.168.12.2
R3 的配置如下:
R3(config)# no ip route 192.168.1.0 255.255.255.0 192.168.23.2
R3(config)# no ip route 192.168.12.0 255.255.255.0 192.168.23.2
R3(config)# ip route 0.0.0.0 0.0.0.0 192.168.23.2
測試 6:查看兩臺 PC 機能否通信
PC1#ping 192.168.2.1
Type escape quence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 conds:
!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 36/100/276 ms
提示 2:注意默認路由使用的場合以及在什么樣的情況下才會選擇默認路由轉(zhuǎn)發(fā)數(shù)據(jù)。
視頻教程:https://edu.csdn.net/cour/detail/30858
視頻教程:https://edu.csdn.net/cour/detail/31400
本文發(fā)布于:2023-02-28 20:14:00,感謝您對本站的認可!
本文鏈接:http://m.newhan.cn/zhishi/a/167766510079674.html
版權(quán)聲明:本站內(nèi)容均來自互聯(lián)網(wǎng),僅供演示用,請勿用于商業(yè)和其他非法用途。如果侵犯了您的權(quán)益請與我們聯(lián)系,我們將在24小時內(nèi)刪除。
本文word下載地址:靜態(tài)路由(靜態(tài)路由和動態(tài)路由的區(qū)別).doc
本文 PDF 下載地址:靜態(tài)路由(靜態(tài)路由和動態(tài)路由的區(qū)別).pdf
| 留言與評論(共有 0 條評論) |