组网图形
静态路由简介
组网需求
配置思路
操作步骤
# 配置SwitchA。SwitchB、SwitchC和SwitchD的配置与SwitchA类似,不再赘述。
<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。
[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的这条路径上。这样就能通过静态路由实现路由的主备备份。
原文:https://www.cnblogs.com/zhangwencheng/p/14096204.html