1. 程式人生 > >靜態路由及實驗配置

靜態路由及實驗配置

靜態路由

靜態路由是指由用戶或者網絡管理員手動配置的路由信息。當網絡的拓撲結構或者鏈路的狀態發生變化時,網絡管理員需要手工修改路由表中相關的靜態路由信息。靜態路由信息在缺省情況下是私有的,不會傳遞給其他的路由器。一般來說,靜態路由用於網絡規模較小、拓撲結構相對固定的網絡中。

靜態路由的特點

  1. 允許對路由的行為進行精確的控制。由於靜態路由是手工配置的,因此管理員可以通過靜態路由來控制數據包在網絡中的流動。
  2. 靜態路由是單向的。也就是說如果希望實現雙向的通信,必須在通信雙方配置雙向的靜態路由。
  3. 靜態路由的不足之處是缺乏靈活性。靜態路由雖然能夠對包通過路由器的路徑對數據包進行精確控制,但同時也限制了它的靈活性。

實驗環境

GNS 3 模擬器

實驗拓撲圖

技術分享圖片

配置命令

路由器R1

R1>en
R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#int f0/0
R1(config-if)#ip add 192.168.2.1 255.255.255.0                #配置接口IP地址
R1(config-if)#no shut                    #開啟接口
R1(config-if)#ex
*Mar  1 00:06:18.167: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:06:19.167: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config)#int f0/1
R1(config-if)#ip add 192.168.1.1 255.255.255.0                #配置接口IP地址
R1(config-if)#no shut                    #開啟接口
R1(config-if)#ex
*Mar  1 00:06:36.879: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:06:37.879: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2     #添加路由
R1(config)#ip route 192.168.4.0 255.255.255.0 192.168.2.2     #添加路由
R1(config)#do show ip route
Codes: C - connected, S - static, 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
       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

S    192.168.4.0/24 [1/0] via 192.168.2.2
C    192.168.1.0/24 is directly connected, FastEthernet0/1
C    192.168.2.0/24 is directly connected, FastEthernet0/0
S    192.168.3.0/24 [1/0] via 192.168.2.2
R1(config)#

路由器R2

R2>en
R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#int f0/0
R2(config-if)#ip add 192.168.2.2 255.255.255.0                #配置接口IP地址
R2(config-if)#no shut                      #開啟接口
R2(config-if)#ex
R2(config)#int f0/
*Mar  1 00:08:49.555: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:08:50.555: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R2(config)#int f0/1
R2(config-if)#ip add 192.168.3.1 255.255.255.0                #配置接口IP地址
R2(config-if)#no shut                    #開啟接口
R2(config-if)#ex
R2(config)#ip route
*Mar  1 00:09:09.459: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:09:10.459: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1     #添加路由
R2(config)#ip route 192.168.4.0 255.255.255.0 192.168.3.2     #添加路由
R2(config)#do show ip route
Codes: C - connected, S - static, 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
       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

S    192.168.4.0/24 [1/0] via 192.168.3.2
S    192.168.1.0/24 [1/0] via 192.168.2.1
C    192.168.2.0/24 is directly connected, FastEthernet0/0
C    192.168.3.0/24 is directly connected, FastEthernet0/1
R2(config)#

路由器R3

R3>en
R3#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#int f0/0
R3(config-if)#ip add 192.168.3.2 255.255.255.0                #配置接口IP地址
R3(config-if)#no shut                    #開啟接口
R3(config-if)#ex
R3(config)#int f0
*Mar  1 00:06:18.167: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:06:19.167: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R3(config)#int f0/1
R3(config-if)#ip add 192.168.4.1 255.255.255.0                #配置接口IP地址
R3(config-if)#no shut                    #開啟接口
R3(config-if)#ex
R3(config)#ip
*Mar  1 00:06:36.879: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:06:37.879: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R3(config)#ip route 192.168.2.0 255.255.255.0 192.168.3.1     #添加路由
R3(config)#ip route 192.168.1.0 255.255.255.0 192.168.3.1     #添加路由
R3(config)#do show ip route
Codes: C - connected, S - static, 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
       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.4.0/24 is directly connected, FastEthernet0/1
S    192.168.1.0/24 [1/0] via 192.168.3.1
S    192.168.2.0/24 [1/0] via 192.168.3.1
C    192.168.3.0/24 is directly connected, FastEthernet0/0
R3(config)#

實驗結果

技術分享圖片

靜態路由及實驗配置