靜態路由協議
交換機 :負責本網段內直接轉發
路由器 :在不一樣網段內間接轉發
靜態路由 :手動輸入到路由表,不佔用網絡帶寬。不會隨着網絡的拓撲變化而變化,缺乏靈活性
動態路由 :動態學習獲得的路由,佔用網絡帶寬和資源,會隨着網絡的拓撲變化而變化,很是靈活
個人簡單實驗拓撲圖
其中ru1 爲DTE段 配置時鐘頻率
Ru1 的s0/0鏈接ru2 的 s0/0 口
Ru1的f0/0 鏈接 pc1的快速以太網 接口
Ru2 的f0/0 鏈接 pc2的快速以太網接口
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int s0/0
Router(config-if)#ip add 192.168.1.1 255.255.255.0
Router(config-if)#clock rate 64000
Router(config-if)#no shut
%LINK-5-CHANGED: Interface Serial0/0, changed state to down
Router(config-if)#exit
Router(config)#int f0/0
Router(config-if)#ip add 172.16.1.1 255.255.255.0
Router(config-if)#no shut
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router(config-if)#host ru1
ru1(config)#
ru1 上的基本配置
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host ru2
ru2(config)#int s0/0
ru2(config-if)#ip add 192.168.1.2 255.255.255.0
ru2(config-if)#no shut
%LINK-5-CHANGED: Interface Serial0/0, changed state to up
ru2(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
ru2(config-if)#exit
ru2(config)#int f0/0
ru2(config-if)#ip add 172.16.2.1 255.255.255.0
ru2(config-if)#no shut
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
ru2(config-if)#exit
ru2(config)#
ru2上的基本配置
ru1(config)#ip route 172.16.2.0 255.255.255.0 192.168.1.2
#ru1 上配置靜態路由
# 命令爲ip route 目標網段 目標網段的子網掩碼 下一跳ip
若是不用下一跳ip也能夠用接口來表示
ru1(config)#exit
%SYS-5-CONFIG_I: Configured from console by console
ru1#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, 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
172.16.0.0/24 is subnetted, 2 subnets
C 172.16.1.0 is directly connected, FastEthernet0/0
S 172.16.2.0 [1/0] via 192.168.1.2
C 192.168.1.0/24 is directly connected, Serial0/0
ru1#
ru2 上做配置以下
ru2(config)#ip route 172.16.1.0 255.255.255.0 192.168.1.1
ru2(config)#exit
%SYS-5-CONFIG_I: Configured from console by console
ru2#sh ip route
# 這裏咱們能夠用 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, 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
172.16.0.0/24 is subnetted, 2 subnets
S 172.16.1.0 [1/0] via 192.168.1.1
C 172.16.2.0 is directly connected, FastEthernet0/0
C 192.168.1.0/24 is directly connected, Serial0/0
ru2#
# 表中顯示S 爲學到的路由信息 C爲直鏈網段
下面咱們 用ping命令測試一下連通性如何
ru2#ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 31/34/47 ms
# 咱們ping ru1 的s0/0 接口
# 五個歎號顯示是通的 五個…..的意思是不通
ru2#ping 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 31/34/47 ms
ru2#
咱們在pc2上配好ip 以後ipconfig 顯示一下
Ping一下 pc1的ip 172..16.1.2 看看連通性如何
選擇ip配置
Packet Tracer PC Command Line 1.0
PC>ipconfig
IP Address......................: 172.16.2.2
Subnet Mask.....................: 255.255.0.0
Default Gateway.................: 172.16.2.1
PC>ping 172.16.1.2
Pinging 172.16.1.2 with 32 bytes of data:
Request timed out.
Reply from 172.16.1.2: bytes=32 time=125ms TTL=126
Reply from 172.16.1.2: bytes=32 time=94ms TTL=126
Reply from 172.16.1.2: bytes=32 time=93ms TTL=126
Ping statistics for 172.16.1.2:
Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
Minimum = 93ms, Maximum = 125ms, Average = 104ms
PC>
結果顯示良好 全通
接下來咱們考慮一個問題就是若是新增長一個路由的話路由表裏面咱們應該是如何進行配置
ru2>en
ru2#conft
Translating "conft"...domain server (255.255.255.255) % Name lookup aborted
ru2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
ru2(config)#int s0/1
ru2(config-if)#ip add 192.168.2.1 255.255.255.0
ru2(config-if)#clock rate 64000
ru2(config-if)#no shut
%LINK-5-CHANGED: Interface Serial0/1, changed state to up
ru2(config-if)#exit
ru2(config)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1, changed state to up
ru2(config)#
ru3 上的配置
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host ru3
ru3(config)#int s0/0
ru3(config-if)#ip add 192.168.2.2 255.255.255.0
ru3(config-if)#no shut
%LINK-5-CHANGED: Interface Serial0/0, changed state to down
ru3(config-if)#exit
ru3(config)#
ru3(config)#int f0/0
ru3(config-if)#ip add 172.16.3.1 255.255.255.0
ru3(config-if)#no shut
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
ru3(config-if)#exit
ru3(config)#
以上是ru3 上的基本配置
ru1>en
ru1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
ru1(config)#ip route 172.16.3.0 255.255.255.0 192.168.1.2
ru1(config)#ip route 192.168.2.0 255.255.255.0 192.168.1.2
ru1(config)#
ru1(config)#exit
%SYS-5-CONFIG_I: Configured from console by console
ru1#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, 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
172.16.0.0/24 is subnetted, 3 subnets
C 172.16.1.0 is directly connected, FastEthernet0/0
S 172.16.2.0 [1/0] via 192.168.1.2
S 172.16.3.0 [1/0] via 192.168.1.2
C 192.168.1.0/24 is directly connected, Serial0/0
S 192.168.2.0/24 [1/0] via 192.168.1.2
ru1#
ru2>
ru2>en
ru2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
ru2(config)#ip route 172.16.3.0 255.255.255.0 192.168.2.2
ru2(config)#exit
%SYS-5-CONFIG_I: Configured from console by console
ru2#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, 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
172.16.0.0/24 is subnetted, 3 subnets
S 172.16.1.0 [1/0] via 192.168.1.1
C 172.16.2.0 is directly connected, FastEthernet0/0
S 172.16.3.0 [1/0] via 192.168.2.2
C 192.168.1.0/24 is directly connected, Serial0/0
C 192.168.2.0/24 is directly connected, Serial0/1
ru2#
以上是ru2新添加的步驟
ru3>
ru3>
ru3>en
ru3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
ru3(config)#ip route 172.16.2.0 255.255.255.0 192.168.2.1
ru3(config)#ip route 172.16.1.0 255.255.255.0 192.168.2.1
ru3(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
ru3(config)#exit
%SYS-5-CONFIG_I: Configured from console by console
ru3#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, 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
172.16.0.0/24 is subnetted, 3 subnets
S 172.16.1.0 [1/0] via 192.168.2.1
S 172.16.2.0 [1/0] via 192.168.2.1
C 172.16.3.0 is directly connected, FastEthernet0/0
S 192.168.1.0/24 [1/0] via 192.168.2.1
C 192.168.2.0/24 is directly connected, Serial0/0
ru3#
ru3 上的具體配置
Packet Tracer PC Command Line 1.0
PC>ipconfig
IP Address......................: 172.16.3.2
Subnet Mask.....................: 255.255.0.0
Default Gateway.................: 172.16.3.1
PC>ping 172.16.2.2
Pinging 172.16.2.2 with 32 bytes of data:
Request timed out.
Reply from 172.16.2.2: bytes=32 time=109ms TTL=126
Reply from 172.16.2.2: bytes=32 time=63ms TTL=126
Reply from 172.16.2.2: bytes=32 time=47ms TTL=126
Ping statistics for 172.16.2.2:
Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
Minimum = 47ms, Maximum = 109ms, Average = 73ms
PC>ping 172.16.1.2
Pinging 172.16.1.2 with 32 bytes of data:
Reply from 172.16.1.2: bytes=32 time=188ms TTL=125
Reply from 172.16.1.2: bytes=32 time=125ms TTL=125
Reply from 172.16.1.2: bytes=32 time=110ms TTL=125
Reply from 172.16.1.2: bytes=32 time=125ms TTL=125
Ping statistics for 172.16.1.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 110ms, Maximum = 188ms, Average = 137ms
PC>
我在pc3 上ping其餘兩個pc的連通狀況 結果都是通的
這裏簡單的說一下一個包爲何會超時 設計一個icmp協議與arp解析的問題 就是說咱們一個包出去一個包回來 第一個出去的時候對方的相應時間很是短 因此返回的時候就會顯示time out 即超時
靜態路由就簡單得介紹到這裏