組網圖形網絡
靜態路由簡介oop
組網需求性能
配置思路ui
操做步驟spa
# 配置SwitchA。SwitchB、SwitchC和SwitchD的配置與SwitchA相似,再也不贅述。blog
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] vlan batch 10 100 400 [SwitchA] interface gigabitethernet 0/0/1 [SwitchA-GigabitEthernet0/0/1] port link-type access [SwitchA-GigabitEthernet0/0/1] port default vlan 10 [SwitchA-GigabitEthernet0/0/1] quit [SwitchA] interface gigabitethernet 0/0/2 [SwitchA-GigabitEthernet0/0/2] port link-type trunk [SwitchA-GigabitEthernet0/0/2] port trunk allow-pass vlan 100 [SwitchA-GigabitEthernet0/0/2] quit [SwitchA] interface gigabitethernet 0/0/3 [SwitchA-GigabitEthernet0/0/3] port link-type trunk [SwitchA-GigabitEthernet0/0/3] port trunk allow-pass vlan 400 [SwitchA-GigabitEthernet0/0/3] quit
# 配置SwitchA。SwitchB、SwitchC和SwitchD的配置與SwitchA相似,再也不贅述。接口
[SwitchA] interface vlanif 10 [SwitchA-Vlanif10] ip address 10.1.1.1 24 [SwitchA-Vlanif10] quit [SwitchA] interface vlanif 100 [SwitchA-Vlanif100] ip address 192.168.12.1 24 [SwitchA-Vlanif100] quit [SwitchA] interface vlanif 400 [SwitchA-Vlanif400] ip address 192.168.14.1 24 [SwitchA-Vlanif400] quit
# 配置SwitchA,配置兩條優先級不一樣的靜態路由,下一跳分別指向SwitchB和SwitchD,實現數據流優先發往SwitchB,當去往SwitchB的鏈路發生故障的時候流量自動切換至SwitchD。ip
[SwitchA] ip route-static 10.1.2.0 24 192.168.12.2 [SwitchA] ip route-static 10.1.2.0 24 192.168.14.2 preference 70
# 配置SwitchB。資源
[SwitchB] ip route-static 10.1.2.0 24 192.168.23.2
# 配置SwitchD。路由
[SwitchD] ip route-static 10.1.2.0 24 192.168.34.1
# 配置SwitchC,配置兩條優先級不一樣的靜態路由,下一跳分別指向SwitchB和SwitchD,實現數據流優先發往SwitchB,當去往SwitchB的鏈路發生故障的時候流量自動切換至SwitchD。
[SwitchC] ip route-static 10.1.1.0 24 192.168.23.1 [SwitchC] ip route-static 10.1.1.0 24 192.168.34.2 preference 70
# 配置SwitchB。
[SwitchB] ip route-static 10.1.1.0 24 192.168.12.1
# 配置SwitchD。
[SwitchD] ip route-static 10.1.1.0 24 192.168.14.1
配置主機PC1的IP地址爲10.1.1.2/24,默認網關爲10.1.1.1;配置主機PC2的IP地址爲10.1.2.2/24,默認網關爲10.1.2.1。
#查看SwitchA的IP路由表。
[SwitchA] display ip routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 9 Routes : 9 Destination/Mask Proto Pre Cost Flags NextHop Interface 10.1.1.0/24 Direct 0 0 D 10.1.1.1 Vlanif10 10.1.1.1/32 Direct 0 0 D 127.0.0.1 Vlanif10 10.1.2.0/24 Static 60 0 RD 192.168.12.2 Vlanif100 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.12.0/24 Direct 0 0 D 192.168.12.1 Vlanif100 192.168.12.1/32 Direct 0 0 D 127.0.0.1 Vlanif100 192.168.14.0/24 Direct 0 0 D 192.168.14.1 Vlanif400 192.168.14.1/32 Direct 0 0 D 127.0.0.1 Vlanif400
#查看SwitchA的IP路由表詳細信息。
[SwitchA] display ip routing-table 10.1.2.0 24 verbose Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Table : Public Summary Count : 2 Destination: 10.1.2.0/24 Protocol: Static Process ID: 0 Preference: 60 Cost: 0 NextHop: 192.168.12.2 Neighbour: 0.0.0.0 State: Active Adv Relied Age: 00h13m13s Tag: 0 Priority: medium Label: NULL QoSInfo: 0x0 IndirectID: 0x80000001 RelayNextHop: 0.0.0.0 Interface: Vlanif100 TunnelID: 0x0 Flags: RD Destination: 10.1.2.0/24 Protocol: Static Process ID: 0 Preference: 70 Cost: 0 NextHop: 192.168.14.2 Neighbour: 0.0.0.0 State: Inactive Adv Relied Age: 00h00m45s Tag: 0 Priority: medium Label: NULL QoSInfo: 0x0 IndirectID: 0x80000002 RelayNextHop: 0.0.0.0 Interface: Vlanif400 TunnelID: 0x0 Flags: R
從SwitchA的IP路由表中能夠看出,到達10.1.2.0/24這個網段僅有一條活躍的路由,鏈路正常狀況下從PC1發往PC2的數據流會優先算則走通過SwitchB的這條路徑。從SwitchA的IP路由表詳細信能夠看出,到達10.1.2.0/24這個網段除了有一條狀態爲Active的路由,還有一條狀態爲Inactive的路由,當主用鏈路故障的時候狀態爲Inactive的路由就會從新生效,這樣流量就能切換到通過SwitchD的這條路徑上。這樣就能經過靜態路由實現路由的主備備份。