静态路由
静态路由是指手工配置的路由信息。
拓扑
基础配置
R1
interface Ethernet0/0/0
ip address 192.168.10.1 255.255.255.0
interface Serial0/0/0
link-protocol ppp
ip address 10.0.12.1 255.255.255.0
R2
interface Serial0/0/0
link-protocol ppp
ip address 10.0.23.2 255.255.255.0
interface Serial0/0/1
link-protocol ppp
ip address 10.0.12.2 255.255.255.0
R3
interface Ethernet0/0/0
ip address 192.168.20.1 255.255.255.0
interface Serial0/0/1
link-protocol ppp
ip address 10.0.23.1 255.255.255.0
配置静态路由
[r1]ip route-static 192.168.20.0 255.255.255.0 10.0.12.2
[r2]ip route-static 192.168.20.0 255.255.255.0 10.0.23.1
[r1]ip route-static 10.0.23.0 24 Serial 0/0/0
[r2]ip route-static 192.168.10.0 24 10.0.12.1
[r3]ip route-static 192.168.10.0 255.255.255.0 10.0.23.2
[r3]ip route-static 10.0.12.0 24 Serial 0/0/1
在任意路由上查看路由表
[r1]dis 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.0.12.0/24 Direct 0 0 D 10.0.12.1 Serial0/0/0
10.0.12.1/32 Direct 0 0 D 127.0.0.1 Serial0/0/0
10.0.12.2/32 Direct 0 0 D 10.0.12.2 Serial0/0/0
10.0.23.0/24 Static 60 0 D 10.0.12.1 Serial0/0/0
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.10.0/24 Direct 0 0 D 192.168.10.1 Ethernet0/0/0
192.168.10.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0
192.168.20.0/24 Static 60 0 RD 10.0.12.2 Serial0/0/0
浮动静态路由
浮动静态路由(Floating Static Route)是一种特殊的静态路由,通过配置去往相同的目的网段,但优先级不同的静态路由,以保证网络中优先级较高的路由,即主路由失效的情况下, 提供备份路由。正常情况下,备份路由不会出现在路由表中。
基础配置
R1
interface Serial0/0/0
link-protocol ppp
ip address 10.0.10.1 255.255.255.0
interface Serial0/0/1
link-protocol ppp
ip address 10.0.12.1 255.255.255.0
interface GigabitEthernet0/0/0
ip address 192.168.10.1 255.255.255.0
R2
interface Serial0/0/0
link-protocol ppp
ip address 10.0.10.2 255.255.255.0
interface Serial0/0/3
link-protocol ppp
ip address 10.0.11.2 255.255.255.0
R3
interface Serial0/0/1
link-protocol ppp
ip address 10.0.12.2 255.255.255.0
interface Serial0/0/2
link-protocol ppp
ip address 10.0.11.1 255.255.255.0
interface GigabitEthernet0/0/0
ip address 192.168.20.1 255.255.255.0
配置静态路由
[r1]ip route-static 192.168.20.0 24 Serial 0/0/1
[r2]ip route-static 192.168.10.0 24 Serial 0/0/0
[r2]ip route-static 192.168.20.0 24 Serial 0/0/1
[r3]ip route-static 192.168.10.0 24 Serial 0/0/1
配置浮动静态路由
[r1]ip route-static 192.168.20.0 24 10.0.10.2 preference 100
[r3]ip route-static 192.168.10.0 24 10.0.11.2 preference 100
在r1上查看配置好的备份链路
[r1]dis ip routing-table protocol static
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : Static
Destinations : 1 Routes : 2 Configured Routes : 2
Static routing table status : <Active>
Destinations : 1 Routes : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface
192.168.20.0/24 Static 60 0 D 10.0.12.1 Serial0/0/1
Static routing table status : <Inactive>
Destinations : 1 Routes : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface
192.168.20.0/24 Static 100 0 R 10.0.10.2 Serial0/0/0
负载均衡
负载均衡(Load sharing)能实现链路冗余,数据分流,减轻单链路负载过重;通过配置优先级和开销来实现
配置负载均衡
[r1]ip route-static 192.168.20.0 24 Serial 0/0/0
[r3]ip route-static 192.168.10.0 24 Serial 0/0/2
R1上查看负载均衡
[r1]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 11 Routes : 12
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.0.10.0/24 Direct 0 0 D 10.0.10.1 Serial0/0/0
10.0.10.1/32 Direct 0 0 D 127.0.0.1 Serial0/0/0
10.0.10.2/32 Direct 0 0 D 10.0.10.2 Serial0/0/0
10.0.12.0/24 Direct 0 0 D 10.0.12.1 Serial0/0/1
10.0.12.1/32 Direct 0 0 D 127.0.0.1 Serial0/0/1
10.0.12.2/32 Direct 0 0 D 10.0.12.2 Serial0/0/1
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.10.0/24 Direct 0 0 D 192.168.10.1 GigabitEthernet
0/0/0
192.168.10.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.20.0/24 Static 60 0 D 10.0.12.1 Serial0/0/1
Static 60 0 D 10.0.10.1 Serial0/0/0
参考HCNA网络技术实验指南