拓扑如下:
参数配置
设备 | 接口 | IP地址 | 子网掩码 | 默认网关 |
R1 | G0/0 | 192.168.1.1 | 255.255.255.0 | N/A |
S1/0 | 192.168.12.1 | 255.255.255.0 | N/A | |
R2 | S1/0 | 192.168.12.2 | 255.255.255.0 | N/A |
S2/0 | 192.168.23.2 | 255.255.255.0 | N/A | |
S1/0 | 192.168.23.3 | 255.255.255.0 | N/A | |
R3 | Loopback0 | 172.16.0.3 | 255.255.255.0 | N/A |
Loopback1 | 172.16.1.3 | 255.255.255.0 | N/A | |
Loopback2 | 172.16.2.3 | 255.255.255.0 | N/A | |
Loopback3 | 172.16.3.3 | 255.255.255.0 | N/A | |
PC1 | G0/1 | 192.168.1.100 | 255.255.255.0 | 192.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地址 | 子网掩码 | 默认网关 |
AR1 | Loopback 0 | 10.10.10.10 | 255.255.255.0 | N/A |
S1/0 | 172.16.12.1 | 255.255.255.0 | N/A | |
AR2 | S1/0 | 172.16.12.2 | 255.255.255.0 | N/A |
Loopback0 | 192.168.12.2 | 255.255.255.0 | N/A | |
Loopback1 | 192.168.13.2 | 255.255.255.0 | N/A | |
Loopback2 | 192.168.14.2 | 255.255.255.0 | N/A | |
Loopback3 | 192.168.15.2 | 255.255.255.0 | N/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地址 | 子网掩码 | 网关 |
AR1 | Loopback0 | 10.10.10.10 | 255.255.255.0 | N/A |
G0/0 | 192.168.1.1 | 255.255.255.0 | N/A | |
G0/1 | 192.168.2.1 | 255.255.255.0 | N/A | |
AR2 | Loopback0 | 20.20.20.20 | 255.255.255.0 | N/A |
G0/0 | 192.168.1.2 | 255.255.255.0 | N/A | |
G0/1 | 192.168.2.2 | 255.255.255.0 | N/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>
以上就是静态路由所有信息,如有问题请留言如有错误欢迎提出