1.在R3-R5-R6-R7上配置缺省指向公网R4
ip route-static 0.0.0.0 0.0.0.0 34.0.0.2
ip route-static 0.0.0.0 0.0.0.0 45.0.0.1
ip route-static 0.0.0.0 0.0.0.0 46.0.0.1
ip route-static 0.0.0.0 0.0.0.0 47.0.0.1
2..配置MGRE R3作为中心站点 R5-R6-R7作为分支站点
中心站点:
R3
interface Tunnel0/0/0
ip address 172.16.6.1 255.255.255.0
tunnel-protocol gre p2mp
source 34.0.0.1
ospf network-type broadcast
nhrp entry multicast dynamic
nhrp network-id 100
分支站点:
R5
interface Tunnel0/0/0
ip address 172.16.6.2 255.255.255.0
tunnel-protocol gre p2mp
source Serial4/0/0
ospf network-type broadcast
ospf dr-priority 0
nhrp network-id 100
nhrp entry 172.16.6.1 34.0.0.1 register
R6
interface Tunnel0/0/0
ip address 172.16.6.3 255.255.255.0
tunnel-protocol gre p2mp
source Serial4/0/0
ospf network-type broadcast
ospf dr-priority 0
nhrp network-id 100
nhrp entry 172.16.6.1 34.0.0.1 register
R7
interface Tunnel0/0/0
ip address 172.16.6.4 255.255.255.0
tunnel-protocol gre p2mp
source GigabitEthernet0/0/0
ospf network-type broadcast
ospf dr-priority 0
nhrp network-id 100
nhrp entry 172.16.6.1 34.0.0.1 register
3.启用OSPF协议并优化路由
R1
ospf 1 router-id 1.1.1.1
area 0.0.0.1
network 172.16.0.0 0.0.255.255
stub
R2
ospf 1 router-id 2.2.2.2
area 0.0.0.1
network 172.16.0.0 0.0.255.255
stub
R3
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 172.16.6.0 0.0.0.255
area 0.0.0.1
abr-summary 172.16.32.0 255.255.224.0
network 172.16.33.0 0.0.0.7
network 172.16.36.0 0.0.0.255
stub no-summary
R5
ospf 1 router-id 5.5.5.5
area 0.0.0.0
network 172.16.0.0 0.0.255.255
R6
ospf 1 router-id 6.6.6.6
area 0.0.0.0
network 172.16.4.0 0.0.0.255
network 172.16.6.0 0.0.0.255
area 0.0.0.2
abr-summary 172.16.64.0 255.255.224.0
network 172.16.65.0 0.0.0.3
nssa no-summary
R7
ospf 1 router-id 7.7.7.7
area 0.0.0.0
network 172.16.5.0 0.0.0.255
network 172.16.6.0 0.0.0.255
area 0.0.0.3
abr-summary 172.16.96.0 255.255.224.0
network 172.16.97.0 0.0.0.3
nssa no-summary
R8
ospf 1 router-id 8.8.8.8
area 0.0.0.3
network 172.16.0.0 0.0.255.255
nssa
R9
ospf 1 router-id 9.9.9.9
asbr-summary 172.16.128.0 255.255.224.0
import-route ospf 2
area 0.0.0.3
network 172.16.97.4 0.0.0.3
nssa
area 0.0.0.4
ospf 2 default-route-advertise
area 0.0.0.4
network 172.16.129.0 0.0.0.3
network 172.16.130.0 0.0.0.255
R10
ospf 1 router-id 10.10.10.10
area 0.0.0.4
network 172.16.0.0 0.0.255.255
R11
ospf 1 router-id 11.11.11.11
area 0.0.0.2
network 172.16.0.0 0.0.255.255
nssa
R12
ospf 1 router-id 12.12.12.12
asbr-summary 172.16.160.0 255.255.224.0
import-route rip 1
area 0.0.0.2
network 172.16.65.4 0.0.0.3
nssa
更改接口模式和邻居关系(R-3-5-6-7都更改)
interface Serial4/0/0
link-protocol ppp
[R3-Serial4/0/0]ospf dr-priority 0
4.R3-R6-R7在公网接口加nat
R3
interface Serial4/0/0
link-protocol ppp
ip address 46.0.0.2 255.255.255.0
nat outbound 2000
[R3-Serial4/0/0]dis acl 2000
Basic ACL 2000, 1 rule
Acl's step is 5
rule 5 permit source 172.16.0.0 0.0.255.255
R5
interface Serial4/0/0
link-protocol ppp
ip address 46.0.0.2 255.255.255.0
nat outbound 2000
[R5-Serial4/0/0]dis acl 2000
Basic ACL 2000, 1 rule
Acl's step is 5
rule 5 permit source 172.16.0.0 0.0.255.255
R6
interface Serial4/0/0
link-protocol ppp
ip address 46.0.0.2 255.255.255.0
nat outbound 2000
[R6-Serial4/0/0]dis acl 2000
Basic ACL 2000, 1 rule
Acl's step is 5
rule 5 permit source 172.16.0.0 0.0.255.255
R7
interface GigabitEthernet0/0/0
ip address 47.0.0.2 255.255.255.0
nat outbound 2000
[R7]dis acl 2000
Basic ACL 2000, 1 rule
Acl's step is 5
rule 5 permit source 172.16.0.0 0.0.255.255
5.配置汇总后空接口防环(R-3-6-7-9-12都配)
ip route-static 172.16.96.0 255.255.224.0 NULL0
查看nhrp邻居表,ping通测试确保无误
R5的ospf路由表:
查看area1的lsdb表:
查看路由表:
查看area2的lsdb表:
查看area3的lsdb表:
查看路由表:
ping测试