华三静态路由、路由负载分担、路由备份与BFD联动

拓扑如下:

参数配置

设备接口IP地址子网掩码默认网关
R1G0/0192.168.1.1255.255.255.0N/A
S1/0192.168.12.1255.255.255.0N/A
R2S1/0192.168.12.2255.255.255.0N/A
S2/0192.168.23.2255.255.255.0N/A
S1/0192.168.23.3255.255.255.0N/A
R3Loopback0172.16.0.3255.255.255.0N/A
Loopback1172.16.1.3255.255.255.0N/A
Loopback2172.16.2.3255.255.255.0N/A
Loopback3172.16.3.3255.255.255.0N/A
PC1G0/1192.168.1.100255.255.255.0192.168.1.1

 一、带下一跳的静态路由

配置:

AR1配置

[AR1]interface GigabitEthernet 0/0

[AR1-GigabitEthernet0/0]ip address 192.168.1.1 24

[AR1-GigabitEthernet0/0]undo shutdown 

[AR1]interface Serial 1/0

[AR1-Serial1/0]ip address 192.168.12.1 24

[AR1-Serial1/0]undo  shutdown 

配置带下一跳地址的静态路由
[AR1]ip route-static 172.16.0.0 24 192.168.12.2

[AR1]ip route-static 172.16.1.0 24 192.168.12.2

[AR1]ip route-static 172.16.2.0 24 192.168.12.2

[AR1]ip route-static 172.16.3.0 24 192.168.12.2

[AR1]ip route-static 172.16.23.0 24 192.168.12.2
AR2配置

[AR2]interface Serial 1/0

[AR2-Serial1/0]ip address 192.168.12.2 24

[AR2-Serial1/0]undo  shutdown  

[AR2]interface Serial 2/0

[AR2-Serial2/0]ip address 192.168.23.2 24

[AR2-Serial2/0]undo  shutdown 

以下配置带下一跳地址的静态路由

[AR2]ip route-static 172.16.0.0 24 192.168.23.3

[AR2]ip route-static 172.16.1.0 24 192.168.23.3

[AR2]ip route-static 172.16.2.0 24 192.168.23.3

[AR2]ip route-static 172.16.3.0 24 192.168.23.3

[AR2]ip route-static 192.168.1.0 24 192.168.12.1
AR3配置

[AR3]interface LoopBack 0

[AR3-LoopBack0]ip address 172.16.0.3 24

[AR3]interface LoopBack 1

[AR3-LoopBack1]ip address 172.16.1.3 24

[AR3]interface LoopBack 2

[AR3-LoopBack2]ip address 172.16.2.3 24

[AR3]interface LoopBack 3

[AR3-LoopBack3]ip address 172.16.3.3 24

[AR3]interface Serial 1/0

[AR3-Serial1/0]ip address 192.168.23.3 24

[AR3-Serial1/0]undo shutdown 

[AR3]ip route-static 192.168.1.0 24 192.168.23.2

[AR3]ip route-static 192.168.12.0 24 192.168.23.2
查看AR1路由表

[AR1]display  ip routing-table 

Destinations : 18       Routes : 18

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0
127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0
127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
172.16.0.0/24      Static  60  0           192.168.12.2    Ser1/0
172.16.1.0/24      Static  60  0           192.168.12.2    Ser1/0
172.16.2.0/24      Static  60  0           192.168.12.2    Ser1/0
172.16.3.0/24      Static  60  0           192.168.12.2    Ser1/0
172.16.23.0/24     Static  60  0           192.168.12.2    Ser1/0
192.168.12.0/24    Direct  0   0           192.168.12.1    Ser1/0
192.168.12.0/32    Direct  0   0           192.168.12.1    Ser1/0
192.168.12.1/32    Direct  0   0           127.0.0.1       InLoop0
192.168.12.2/32    Direct  0   0           192.168.12.2    Ser1/0
192.168.12.255/32  Direct  0   0           192.168.12.1    Ser1/0
224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0
224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0
255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
查看AR2路由表

[AR2]display  ip routing-table  

Destinations : 23       Routes : 23

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0
127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0
127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
172.16.0.0/24      Static  60  0           192.168.23.3    Ser2/0
172.16.1.0/24      Static  60  0           192.168.23.3    Ser2/0
172.16.2.0/24      Static  60  0           192.168.23.3    Ser2/0
172.16.3.0/24      Static  60  0           192.168.23.3    Ser2/0
192.168.1.0/24     Static  60  0           192.168.12.1    Ser1/0
192.168.12.0/24    Direct  0   0           192.168.12.2    Ser1/0
192.168.12.0/32    Direct  0   0           192.168.12.2    Ser1/0
192.168.12.1/32    Direct  0   0           192.168.12.1    Ser1/0
192.168.12.2/32    Direct  0   0           127.0.0.1       InLoop0
192.168.12.255/32  Direct  0   0           192.168.12.2    Ser1/0
192.168.23.0/24    Direct  0   0           192.168.23.2    Ser2/0
192.168.23.0/32    Direct  0   0           192.168.23.2    Ser2/0
192.168.23.2/32    Direct  0   0           127.0.0.1       InLoop0
192.168.23.3/32    Direct  0   0           192.168.23.3    Ser2/0
192.168.23.255/32  Direct  0   0           192.168.23.2    Ser2/0
224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0
224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0
255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
查看AR3路由表

[AR3]display  ip routing-table  

Destinations : 31       Routes : 31

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0
127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0
127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
172.16.0.0/24      Direct  0   0           172.16.0.3      Loop0
172.16.0.0/32      Direct  0   0           172.16.0.3      Loop0
172.16.0.3/32      Direct  0   0           127.0.0.1       InLoop0
172.16.0.255/32    Direct  0   0           172.16.0.3      Loop0
172.16.1.0/24      Direct  0   0           172.16.1.3      Loop1
172.16.1.0/32      Direct  0   0           172.16.1.3      Loop1
172.16.1.3/32      Direct  0   0           127.0.0.1       InLoop0
172.16.1.255/32    Direct  0   0           172.16.1.3      Loop1
172.16.2.0/24      Direct  0   0           172.16.2.3      Loop2
172.16.2.0/32      Direct  0   0           172.16.2.3      Loop2
172.16.2.3/32      Direct  0   0           127.0.0.1       InLoop0
172.16.2.255/32    Direct  0   0           172.16.2.3      Loop2
172.16.3.0/24      Direct  0   0           172.16.3.3      Loop3
172.16.3.0/32      Direct  0   0           172.16.3.3      Loop3
172.16.3.3/32      Direct  0   0           127.0.0.1       InLoop0
172.16.3.255/32    Direct  0   0           172.16.3.3      Loop3
192.168.1.0/24     Static  60  0           192.168.23.2    Ser1/0
192.168.12.0/24    Static  60  0           192.168.23.2    Ser1/0
192.168.23.0/24    Direct  0   0           192.168.23.3    Ser1/0
192.168.23.0/32    Direct  0   0           192.168.23.3    Ser1/0
192.168.23.2/32    Direct  0   0           192.168.23.2    Ser1/0
192.168.23.3/32    Direct  0   0           127.0.0.1       InLoop0
192.168.23.255/32  Direct  0   0           192.168.23.3    Ser1/0
224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0
224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0
255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0

配置PC机

 测试:

 以上就是带下一跳地址的静态路由

二、带送出接口的静态路由

需要先将原来配置的静态路由删除掉只需要在前面加上undo就可以了

AR1带出接口的静态路由配置

ip route-static 172.16.0.0 24 s1/0

ip route-static 172.16.1.0 24 s1/0

ip route-static 172.16.2.0 24 s1/0

ip route-static 172.16.3.0 24 s1/0

ip route-static 172.16.23.0 24 s1/0
AR2带出接口的静态路由配置

ip route-static 172.16.0.0 24  s2/0

ip route-static 172.16.1.0 24  s2/0

ip route-static 172.16.2.0 24  s2/0

ip route-static 172.16.3.0 24 s2/0

ip route-static 192.168.1.0 24 s1/0
AR3带出接口的静态路由配置

ip route-static 192.168.1.0 24 s2/0

ip route-static 192.168.12.0 24 s2/0

查看路由表

AR1路由表

[AR1]display  ip routing-table  protocol static 

Summary count : 5

Static Routing table status : <Active>
Summary count : 5

Destination/Mask   Proto   Pre Cost        NextHop         Interface
172.16.0.0/24      Static  60  0           0.0.0.0         Ser1/0
172.16.1.0/24      Static  60  0           0.0.0.0         Ser1/0
172.16.2.0/24      Static  60  0           0.0.0.0         Ser1/0
172.16.3.0/24      Static  60  0           0.0.0.0         Ser1/0
172.16.23.0/24     Static  60  0           0.0.0.0         Ser1/0
AR2路由表

[AR2]display  ip routing-table  protocol static 

Summary count : 5

Static Routing table status : <Active>
Summary count : 5

Destination/Mask   Proto   Pre Cost        NextHop         Interface
172.16.0.0/24      Static  60  0           0.0.0.0         Ser1/0
172.16.1.0/24      Static  60  0           0.0.0.0         Ser1/0
172.16.2.0/24      Static  60  0           0.0.0.0         Ser1/0
172.16.3.0/24      Static  60  0           0.0.0.0         Ser1/0
192.168.1.0/24     Static  60  0           0.0.0.0         Ser1/0
AR3路由表

[AR3]display ip routing-table  protocol static  

Summary count : 2

Static Routing table status : <Active>
Summary count : 2

Destination/Mask   Proto   Pre Cost        NextHop         Interface
192.168.1.0/24     Static  60  0           0.0.0.0         Ser2/0
192.168.12.0/24    Static  60  0           0.0.0.0         Ser2/0

测试:

 三、汇总静态路由与默认路由

拓扑如下:

 配置信息:

设备接口IP地址子网掩码默认网关
AR1Loopback 010.10.10.10 255.255.255.0N/A
S1/0172.16.12.1   255.255.255.0N/A

AR2

S1/0172.16.12.2255.255.255.0N/A
Loopback0192.168.12.2255.255.255.0N/A
Loopback1192.168.13.2   255.255.255.0N/A
Loopback2192.168.14.2255.255.255.0N/A
Loopback3192.168.15.2255.255.255.0N/A

一、汇总路由配置

AR1配置

[AR1]interface LoopBack 0

[AR1-LoopBack0]ip address 10.10.10.10 24

[AR1-Serial1/0]ip address 172.16.12.1 24

[AR1-Serial1/0]un shutdown  

[AR1]ip route-static 192.168.12.0 22 s1/0 //配置静态汇总路由,使用聚合地址

AR2配置

[AR2]interface LoopBack  0

[AR2-LoopBack0]ip address 192.168.12.2 24 

[AR2]interface LoopBack  1

[AR2-LoopBack1]ip address 192.168.13.2 24 

[AR2]interface LoopBack  2

[AR2-LoopBack2]ip address 192.168.14.2 24 

[AR2]interface LoopBack  3

[AR2-LoopBack3]ip address 192.168.15.2 24 

[AR2]ip route-static 10.10.10.0 24 s1/0

测试:带源去ping

[AR1]ping -a 10.10.10.10 192.168.12.2
Ping 192.168.12.2 (192.168.12.2) from 10.10.10.10: 56 data bytes, press CTRL_C to break
56 bytes from 192.168.12.2: icmp_seq=0 ttl=255 time=1.000 ms
56 bytes from 192.168.12.2: icmp_seq=1 ttl=255 time=1.000 ms
56 bytes from 192.168.12.2: icmp_seq=2 ttl=255 time=2.000 ms
56 bytes from 192.168.12.2: icmp_seq=3 ttl=255 time=2.000 ms
56 bytes from 192.168.12.2: icmp_seq=4 ttl=255 time=2.000 ms

--- Ping statistics for 192.168.12.2 ---
5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
round-trip min/avg/max/std-dev = 1.000/1.600/2.000/0.490 ms
[AR1]%May 16 15:49:15:645 2022 AR1 PING/6/PING_STATISTICS: Ping statistics for 192.168.12.2: 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss, round-trip min/avg/max/std-dev = 1.000/1.600/2.000/0.490 ms.

默认路由配置

[AR1]ip route-static 0.0.0.0 0 Serial 1/0  //配置静态默认路由,网络地址与子网掩码都为0,在没有精准的匹配时,此条路由条目能与所有网络匹配

路由负载分担

拓扑如下:

 

接口参数配置:

设备接口IP地址子网掩码网关
AR1Loopback010.10.10.10255.255.255.0N/A
G0/0192.168.1.1255.255.255.0N/A
G0/1192.168.2.1255.255.255.0N/A
AR2Loopback020.20.20.20255.255.255.0N/A
G0/0192.168.1.2255.255.255.0N/A
G0/1192.168.2.2255.255.255.0N/A

 配置:

AR1配置

[AR1]interface LoopBack  0

[AR1-LoopBack0]ip address 10.10.10.10 24

[AR1]interface GigabitEthernet 0/0

[AR1-GigabitEthernet0/0]ip address 192.168.1.1 24

[AR1-GigabitEthernet0/0]undo shutdown 

[AR1]interface GigabitEthernet 0/1

[AR1-GigabitEthernet0/1]ip address 192.168.2.1 24

[AR1-GigabitEthernet0/1]undo shutdown

[AR1]ip route-static 20.20.20.0 24 192.168.1.2 

[AR1]ip route-static 20.20.20.0 24 192.168.2.2

查看路由表

可以看到去往20.20.20.0网段的也有两条路由,静态路由的优先级都是60代价是0数据会根据路由表条目,一半流量走192.168.1.2一半流量走192.168.2.2


[AR1]display  ip routing-table  

Destinations : 21       Routes : 22

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
10.10.10.255/32    Direct  0   0           10.10.10.10     Loop0
20.20.20.0/24      Static  60  0           192.168.1.2     GE0/0
                                           192.168.2.2     GE0/1
AR2配置

[AR2]interface LoopBack  0

[AR2-LoopBack0]ip address 20.20.20.20 24

[AR2]interface GigabitEthernet 0/0

[AR2-GigabitEthernet0/0]ip address 192.168.1.2 24

[AR2-GigabitEthernet0/0]undo shutdown

[AR2]interface GigabitEthernet 0/1

[AR2-GigabitEthernet0/1]ip address 192.168.2.2 24 

[AR2-GigabitEthernet0/1]undo shutdown

[AR2]ip route-static 10.10.10.0 24 192.168.1.1

[AR2]ip route-static 10.10.10.0 24 192.168.2.1


查看路由表

可以看到去往10.10.10.0网段的下一跳有两个因为静态路由的优先级都是60代价是0数据会根据路由表条目
一半流量走192.168.1.1一半流量走192.168.2.1

[AR2]display  ip routing-table  

Destinations : 21       Routes : 22

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
10.10.10.0/24      Static  60  0           192.168.1.1     GE0/0
                                           192.168.2.1     GE0/1
20.20.20.0/24      Direct  0   0           20.20.20.20     Loop0
20.20.20.0/32      Direct  0   0           20.20.20.20     Loop0

路由备份

 这里将第二条路由改成了100,现在流量默认从优先级为60的走

AR1配置

[AR1]undo  ip route-static 20.20.20.0 24 192.168.2.2  //删除一条路由

[AR1]ip route-static 202.20.20.0 24 192.168.2.2 preference 100  //添加一条路由并设置优先级

查看路由表

可以看到去往20.20.20.0网段的地址现在就只有一个了

[AR1]display  ip routing-table  

Destinations : 22       Routes : 22

Destination/Mask   Proto   Pre Cost        NextHop         Interface
20.20.20.0/24      Static  60  0           192.168.1.2     GE0/0
127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
AR2配置

[AR2]undo ip route-static 10.10.10.0 24 192.168.2.1 //删除第二条路由

[AR2]ip route-static 10.10.10.0 24 192.168.2.1 preference 100 //添加路有并且将优先级调到100

查看路由表
可以看到去往10.10.10.0网段的也只有一条了
[AR2]display  ip routing-table  

Destinations : 21       Routes : 21

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
10.10.10.0/24      Static  60  0           192.168.1.1     GE0/0
20.20.20.0/24      Direct  0   0           20.20.20.20     Loop0

下面测试:

 这里是没问题的,下面我们将60这条线路断开,看一下备份线路会不会上线

AR1配置

[AR1]interface GigabitEthernet 0/0

[AR1-GigabitEthernet0/0]shutdown 

查看路由表

可以看到去往20.20.20.0网段的也更新了

[AR1]display  ip routing-table  

Destinations : 17       Routes : 17

Destination/Mask   Proto   Pre Cost        NextHop         Interface

192.168.2.1/32     Direct  0   0           127.0.0.1       InLoop0
192.168.2.255/32   Direct  0   0           192.168.2.1     GE0/1
202.20.20.0/24     Static  100 0           192.168.2.2     GE0/1
AR2配置

[AR2]interface GigabitEthernet 0/0

[AR2-GigabitEthernet0/0]shutdown 

查看路由表
这里可以看到60断开后,优先级为100的就替换上来了

[AR2]display ip routing-table  

Destinations : 17       Routes : 17

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
10.10.10.0/24      Static  100 0           192.168.2.1     GE0/1
20.20.20.0/24      Direct  0   0           20.20.20.20     Loop0

下面测试

可以看到互相通信了,这里静态路由备份就完成了

静态路由与BFD联动

BFD(双向转发检测)协议提供一种轻负担,快速检测两台邻居路由器之间转发路径联通状态的方法。加快启用备份转发路径,大大减少整个网络的收敛时间,提升现有网络的性能

AR1配置

删除两条静态路由

[AR1]undo  ip route-static 20.20.20.0 24 192.168.1.2 

[AR1]undo  ip route-static 20.20.20.0 24 192.168.2.2 preference 100


在接口G0/0配置BFD协议

[AR1]interface GigabitEthernet 0/0

[AR1-GigabitEthernet0/0]bfd min-transmit-interval 500

[AR1-GigabitEthernet0/0]bfd min-receive-interval 500

[AR1-GigabitEthernet0/0]bfd detect-multiplier 9

在AR1上配置bfd与备份路由

[AR1]ip route-static 20.20.20.0 24 g0/0 192.168.1.2 bfd control-packet 

[AR1]ip route-static 20.20.20.0 24 g0/1 192.168.2.2 preference  100

查看配置结果

[AR1]display bfd session
 
 Total Session Num: 1     Up Session Num: 1     Init Mode: Active

 IPv4 session working in control packet mode:

 LD/RD            SourceAddr      DestAddr        State  Holdtime    Interface
 2049/2049        192.168.1.1     192.168.1.2     Up     4247ms      GE0/0      
AR2配置

删除两条路由

[AR2]undo  ip route-static 10.10.10.0 24 192.168.1.1

[AR2]undo  ip route-static 10.10.10.0 24 192.168.2.1 preference  100

在接口G0/0配置bfd协议

[AR2-GigabitEthernet0/0]bfd min-transmit-interval 500

[AR2-GigabitEthernet0/0]bfd  min-receive-interval 500

[AR2-GigabitEthernet0/0]bfd detect-multiplier 9

配置bfd与备份路由

[AR2]ip route-static 10.10.10.0 24 G0/0 192.168.1.1 bfd control-packet 

[AR2]ip route-static 10.10.10.0 24 g0/1 192.168.2.1 preference 100

查看配置结果

 [AR2]display bfd session 

 Total Session Num: 1     Up Session Num: 1     Init Mode: Active

 IPv4 session working in control packet mode:

 LD/RD            SourceAddr      DestAddr        State  Holdtime    Interface
 2049/2049        192.168.1.2     192.168.1.1     Up     4123ms      GE0/0      

测试

AR1配置

开启bfd功能调试信息开关

<AR1>debugging bfd event 

<AR1>debugging bfd scm 

<AR1>terminal debugging 

AR2配置

关闭G0/0接口

[AR2]interface GigabitEthernet 0/0

[AR2-GigabitEthernet0/0]shutdown
AR1配置

查看静态路由

这里启动了备份路由

[AR1]display ip routing-table  protocol static 

Summary count : 1

Static Routing table status : <Active>
Summary count : 1

Destination/Mask   Proto   Pre Cost        NextHop         Interface
20.20.20.0/24      Static  100 0           192.168.2.2     GE0/1

Static Routing table status : <Inactive>

以上就是静态路由所有信息,如有问题请留言如有错误欢迎提出

  • 3
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小肥溜了猪

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值