目录
配置环境:ensp
AR1:
g0/0/0: 67.67.67.1/24
AR2:
g0/0/0: 67.67.67.2/24
g0/0/1: 16.16.16.1/24
AR3:
g0/0/0: 16.16.16.2/24
g0/0/1: 13.13.13.2/24
g2/0/0: 12.12.12.1/24
g2/0/1: 14.14.14.1/24
AR4:
g0/0/0: 12.12.12.2/24
LoopBack0:2.2.2.2/32
LoopBack1:22.1.1.1/32(area1)
LoopBack2:22.2.2.2/32(area1)
LoopBack3:22.3.3.3/32(area1)
AR5:
g0/0/0: 13.13.13.1/24
LoopBack0:3.3.3.3/32
LoopBack1:33.1.1.1/32(不宣告ospf)
LoopBack2:33.2.2.2/32(不宣告ospf)
LoopBack3:33.3.3.3/32(不宣告ospf)
AR6:
g0/0/0: 14.14.14.2/24
g0/0/1: 45.45.45.1/24
AR7:
g0/0/0: 45.45.45.2/24
LoopBack0:5.5.5.5/32
LoopBack1:55.55.55.55/32(不宣告ospf)
AR1:
[R1]ospf
[R1-ospf-1]area 2
[R1-ospf-1-area-0.0.0.2]network 67.67.67.0 0.0.0.255
[R1-ospf-1-area-0.0.0.2]stub
[R1-ospf-1-area-0.0.0.2]dis th
[V200R003C00]
#
area 0.0.0.2
network 67.67.67.0 0.0.0.255
stub
#
return
AR2:
[R2]ospf
[R2-ospf-1]area 2
[R2-ospf-1-area-0.0.0.2]network 67.67.67.0 0.0.0.255
[R2-ospf-1-area-0.0.0.2]stub
[R2-ospf-1-area-0.0.0.2]dis th
[V200R003C00]
#
area 0.0.0.2
network 67.67.67.0 0.0.0.255
stub
#
return
[R2-ospf-1-area-0.0.0.2]q
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 16.16.16.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]dis th
[V200R003C00]
#
area 0.0.0.0
network 16.16.16.0 0.0.0.255
#
return
AR3:
[R3]ospf
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 13.13.13.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 14.14.14.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 16.16.16.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]dis th
[V200R003C00]
#
area 0.0.0.0
network 13.13.13.0 0.0.0.255
network 14.14.14.0 0.0.0.255
network 16.16.16.0 0.0.0.255
#
return
[R3-ospf-1-area-0.0.0.0]q
[R3-ospf-1]area 1
[R3-ospf-1-area-0.0.0.1]network 12.12.12.0 0.0.0.255
[R3-ospf-1-area-0.0.0.1]dis th
[V200R003C00]
#
area 0.0.0.1
network 12.12.12.0 0.0.0.255
#
return
AR4:
# LoopBack口IP地址要提前配置好
[R4]ospf
[R4-ospf-1]area 1
[R4-ospf-1-area-0.0.0.1]network 12.12.12.0 0.0.0.255
[R4-ospf-1-area-0.0.0.1]network 2.2.2.2 0.0.0.0
[R4-ospf-1-area-0.0.0.1]network 22.1.1.1 0.0.0.0
[R4-ospf-1-area-0.0.0.1]network 22.2.2.2 0.0.0.0
[R4-ospf-1-area-0.0.0.1]network 22.3.3.3 0.0.0.0
[R4-ospf-1-area-0.0.0.1]dis th
[V200R003C00]
#
area 0.0.0.1
network 2.2.2.2 0.0.0.0
network 12.12.12.0 0.0.0.255
network 22.1.1.1 0.0.0.0
network 22.2.2.2 0.0.0.0
network 22.3.3.3 0.0.0.0
#
return
AR5:
# LoopBack口IP地址要提前配置好
[R5]ospf
[R5-ospf-1]area 0
[R5-ospf-1-area-0.0.0.0]network 13.13.13.0 0.0.0.255
[R5-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[R5-ospf-1-area-0.0.0.0]dis th
[V200R003C00]
#
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 13.13.13.0 0.0.0.255
#
return
AR6:
[R6]ospf
[R6-ospf-1]area 0
[R6-ospf-1-area-0.0.0.0]network 14.14.14.0 0.0.0.255
[R6-ospf-1-area-0.0.0.0]dis th
[V200R003C00]
#
area 0.0.0.0
network 14.14.14.0 0.0.0.255
#
return
[R6-ospf-1-area-0.0.0.0]q
[R6-ospf-1]area 3
[R6-ospf-1-area-0.0.0.3]network 45.45.45.0 0.0.0.255
[R6-ospf-1-area-0.0.0.3]nssa
[R6-ospf-1-area-0.0.0.3]dis th
[V200R003C00]
#
area 0.0.0.3
network 45.45.45.0 0.0.0.255
nssa
#
return
AR7:
# LoopBack口IP地址要提前配置好
[R7]ospf
[R7-ospf-1]area 3
[R7-ospf-1-area-0.0.0.3]network 45.45.45.0 0.0.0.255
[R7-ospf-1-area-0.0.0.3]network 5.5.5.5 0.0.0.0
[R7-ospf-1-area-0.0.0.3]nssa
[R7-ospf-1-area-0.0.0.3]dis th
[V200R003C00]
#
area 0.0.0.3
network 5.5.5.5 0.0.0.0
network 45.45.45.0 0.0.0.255
nssa
#
return
到现在为止所有区域的ospf都已经配置完毕,先测试路由器之间的连通性,然后再配置策略。
用AR1 ping 12.12.12.0网段IP、45.45.45.0网段IP、13.13.13.0网段IP。
用AR1 分别pingAR5、AR4和AR7的回环口(LoopBack口)
AR5:
# 可以用ACL或IP prefix-list。这里建议ACL,比较简单;而IP prefix-list略显复杂。
[R5]acl 2000
[R5-acl-basic-2000]rule permit source 33.1.1.1 0
[R5-acl-basic-2000]rule permit source 33.2.2.2 0
[R5-acl-basic-2000]rule permit source 33.3.3.3 0
[R5-acl-basic-2000]dis th
[V200R003C00]
#
acl number 2000
rule 5 permit source 33.1.1.1 0
rule 10 permit source 33.2.2.2 0
rule 15 permit source 33.3.3.3 0
#
return
[R5-acl-basic-2000]q
[R5]route-policy ospf permit node 10
Info: New Sequence of this List.
[R5-route-policy]if-match acl 2000
[R5-route-policy]apply cost 10
[R5-route-policy]apply cost-type type-1
[R5-route-policy]dis th
[V200R003C00]
#
route-policy ospf permit node 10
if-match acl 2000
apply cost 10
apply cost-type type-1
#
return
[R5-route-policy]q
[R5]ospf
[R5-ospf-1]import-route direct route-policy ospf
[R5-ospf-1]dis th
[V200R003C00]
#
ospf 1
import-route direct route-policy ospf
area 0.0.0.0
#
return
AR4:
[R4]ip ip-prefix 10 deny 33.3.3.3 32
[R4]ospf
[R4-ospf-1]filter-policy ip-prefix 10 import
到目前为止,已经全部按照要求配置完毕,现在测试。
测试流程为:
1、找AR1来ping AR5的所有回环口,都可以ping通
2、AR4来ping AR5的回环口(除了33.3.3.3以外都能ping通)
AR4:
AR5: