![](https://i-blog.csdnimg.cn/blog_migrate/cf03ce57e192cc0b144c62b4941ecabc.jpeg)
R1:int lo 0<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
ip add <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />1.1.1.1 255.255.255.0
no shut
exit
int lo 1
ip add 88.88.88.88 255.255.255.0
no shut
exit
int s1/1
ip add 172.16.12.1 255.255.255.0
no shut
exit
router ospf 100
log-adjacency-changes
network 1.1.1.1 0.0.0.0 area 1
network 88.88.88.88 0.0.0.0 area 1
network 172.16.12.1 0.0.0.0 area 1
R2:int f0/0
no sw
ip add 192.168.25.2 255.255.255.0
no shut
exit
int s1/0
ip add 172.16.12.2 255.255.255.0
no shut
exit
int s1/1
ip add 192.168.23.2 255.255.255.0
no shut
exit
router ospf 100
log-adjacency-changes
network 172.16.12.2 0.0.0.0 area 1
network 192.168.25.2 0.0.0.0 area 0
network 192.168.23.2 0.0.0.0 area 0
R3:int s1/0
ip add 192.168.23.3 255.255.255.0
no shut
exit
int s1/1
ip add 192.168.34.3 255.255.255.0
no shut
exit
router ospf 100
log-adjacency-changes
network 192.168.23.3 0.0.0.0 area 0
network 192.168.34.3 0.0.0.0 area 2
R4:int lo 0
ip add 4.4.4.4 255.255.255.0
no shut
exit
int s1/0
ip add 192.168.34.4 255.255.255.0
no shut
exit
int s1/2
ip add 192.168.45.4 255.255.255.0
no shut
exit
router ospf 100
log-adjacency-changes
network 4.4.4.4 0.0.0.0 area 2
network 192.168.34.4 0.0.0.0 area 2
network 192.168.45.4 0.0.0.0 area 2
R5:int s1/3
ip add 192.168.45.5 255.255.255.0
no shut
exit
int f0/0
no sw
ip add 192.168.25.5 255.255.255.0
no shut
exit
router ospf 100
log-adjacency-changes
network 192.168.45.5 0.0.0.0 area 2
network 192.168.25.5 0.0.0.0 area 0
本案例没做路由策略前路由器根据计算最佳路径区域1的流量全部走R1-R2-R5-R4
在R2配置ROUTE-MAP
access-list 1 permit 1.1.1.0 0.0.0.255
route-map 12
match ip add 1
match int s1/1
set int s1/1
exit
int s1/0
ip policy route-map 12
route-map 12
match ip add 1
match int s1/1
set int s1/1
exit
int s1/0
ip policy route-map 12
做了路由策略后1.1.1.0走R1--R2--R3--R4,88.88.88.0走R1--R2--R5--R4这样便可实现负载均衡和链路的备份。
测试结果可以用:
show ip route
show ip ospf neighbor
show ip ospf inter 接口
show ip ospf database
traceroute
转载于:https://blog.51cto.com/iverson/209096