目标:
1、首先进行基于172.16.0.0/16的ip地址规划
首先题中有5个区域和一个RIP共需要5个网段
可以借3位划分为8个网段
172.16.0.0/19 area 0
然后将172.16.0.0/19再借6位分为172.16.0.0/25---172.16.31.128 25作为其中前一个骨干ip网段 172.16.0.0/25在用于只有两个接口的网段中可以再进一步划分为仅有两个ip地址的172.16.0.0/30
再拿出一个172.16.128.0/25 再分为每个网段有多个ip的骨干网段中的 172.16.0.128/29,然后将剩下的60个网段用于用户
172.16.32.0/19 area 1
172.16.64.0/19 area 2
172.16.96.0/19 area 3
172.16.128.0/19 area 4
172.16.160.0/19 RIP
172.16.192.0/19(保留)
172.16.224.0/19(保留)
2、首先将ISP(r4)所在的公网环境完成
r3:
[R3]interface GigabitEthernet 0/0/1
[R3-GigabitEthernet0/0/1]ip add 34.1.1.1 24
r5:
[r5]interface GigabitEthernet 0/0/0
[r5-GigabitEthernet0/0/0]ip ad 45.1.1.1 24
r6:
[r6]interface gi
[r6]interface GigabitEthernet 0/0/0
[r6-GigabitEthernet0/0/0]ip add 46.1.1.1 24
r7:
[r7]interface GigabitEthernet 0/0/0
[r7-GigabitEthernet0/0/0]ip add 47.1.1.1 24
r4:
[r4]interface GigabitEthernet 0/0/0
[r4-GigabitEthernet0/0/0]ip add 34.1.1.2 24
[r4-GigabitEthernet0/0/0]int gi 0/0/1
[r4-GigabitEthernet0/0/1]ip add 45.1.1.2 24
[r4-GigabitEthernet0/0/1]int gi 0/0/2
[r4-GigabitEthernet0/0/2]ip add 46.1.1.2 24
[r4-GigabitEthernet0/0/2]int gi 1/0/0
[r4-GigabitEthernet1/0/0]ip add 47.1.1.2 24
[r4-GigabitEthernet1/0/0]int lo0
[r4-LoopBack0]ip add 4.4.4.4 24
下面需要让公网的其他接口可以知道除ISP以外的ip需要配置一条指向r4的缺省路由
r3:
[R3]ip route-static 0.0.0.0 0 34.1.1.2
r5:
[r5]ip route-static 0.0.0.0 0 45.1.1.2
r6:
[r6]ip route-static 0.0.0.0 0 46.1.1.2
r7:
[r7]ip route-static 0.0.0.0 0 47.1.1.2
测试:r3pingr7
2、在公网中配置MGRE创造私网环境
使用172.16.0.128 29网段
r3:
[R3]interface Tunnel 0/0/0
[R3-Tunnel0/0/0]ip add 172.16.0.129 29
[R3-Tunnel0/0/0]tunnel-protocol gre p2mp
[R3-Tunnel0/0/0]source 34.1.1.1
[R3-Tunnel0/0/0]nhrp entry multicast dynamic
r5:
[r5]interface Tunnel 0/0/0
[r5-Tunnel0/0/0]ip add 172.16.0.130 29
[r5-Tunnel0/0/0]tunnel-protocol gre p2mp
[r5-Tunnel0/0/0]source GigabitEthernet 0/0/0
[r5-Tunnel0/0/0]nhrp entry 172.16.0.129 34.1.1.1 register
r6:
[r6]interface Tunnel 0/0/0
[r6-Tunnel0/0/0]ip add 172.16.0.131 29
[r6-Tunnel0/0/0]tunnel-protocol gre p2mp
[r6-Tunnel0/0/0]source GigabitEthernet 0/0/0
[r6-Tunnel0/0/0]nhrp entry 172.16.0.129 34.1.1.1 register
r7:
[r7]interface Tunnel 0/0/0
[r7-Tunnel0/0/0]ip add 172.16.0.132 29
[r7-Tunnel0/0/0]tunnel-protocol gre p2mp
[r7-Tunnel0/0/0]source GigabitEthernet 0/0/0
[r7-Tunnel0/0/0]nhrp entry 172.16.0.129 34.1.1.1 register
检测:
为:r5、r6、r7配置环回:
[r5]interface lo0
[r5-LoopBack0]ip add 172.16.1.1 25
[r6]interface lo0
[r6-LoopBack0]ip add 172.16.1.129 25
[r7]interface lo0
[r7-LoopBack0]ip add 172.16.2.1 25
这时区域0(r3、r4、r5、r6)的ip就配置完成了
3、配置其他区域的各个ip地址
区域1(r1、r2、r3)
r1:
[r1]interface LoopBack 0
[r1-LoopBack0]ip add 172.16.33.1 25
[r1]interface GigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]ip add 172.16.32.129 29
r2:
[r2]interface lo0
[r2-LoopBack0]ip add 172.16.33.129 25
[r2]interface GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]ip add 172.16.32.130 29
r3:
[R3]interface lo0
[R3-LoopBack0]ip add 172.16.34.1 25
[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ip add 172.16.32.131 29
区域2(r6、r11、r12)
r6:
[r6]interface GigabitEthernet 0/0/1
[r6-GigabitEthernet0/0/1]ip add 172.16.64.1 30
r11:
[r11]interface lo0
[r11-LoopBack0]ip add 172.16.65.1 25
[r11]interface GigabitEthernet 0/0/0
[r11-GigabitEthernet0/0/0]ip add 172.16.64.2 30
[r11-GigabitEthernet0/0/0]int gi 0/0/1
[r11-GigabitEthernet0/0/1]ip add 172.16.64.5 30
r12:
[r12]interface GigabitEthernet 0/0/0
[r12-GigabitEthernet0/0/0]ip add 172.16.64.6 30
区域3(r7、r8、r9)
r7:
[r7]interface GigabitEthernet 0/0/1
[r7-GigabitEthernet0/0/1]ip add 172.16.96.1 30
r8:
[r8]interface LoopBack 0
[r8-LoopBack0]ip add 172.16.97.1 25
[r8]interface GigabitEthernet 0/0/0
[r8-GigabitEthernet0/0/0]ip add 172.16.96.2 30
[r8-GigabitEthernet0/0/0]int gi 0/0/1
[r8-GigabitEthernet0/0/1]ip add 172.16.96.5 30
r9:
[r9]interface GigabitEthernet 0/0/0
[r9-GigabitEthernet0/0/0]ip add 172.16.96.6 30
区域4(r9、r10)
r9:
[r9]int lo0
[r9-LoopBack0]ip add 172.16.129.1 25
[r9-LoopBack0]int gi 0/0/1
[r9-GigabitEthernet0/0/1]ip add 172.16.128.1 30
r10:
[r10]interface GigabitEthernet 0/0/0
[r10-GigabitEthernet0/0/0]ip add 172.16.128.2 30
[r10-GigabitEthernet0/0/0]int lo0
[r10-LoopBack0]ip add 172.16.129.129 25
下面配置r12下的两个环回
172.16.160.0 /20
172.16.176.0/20
[r12-LoopBack0]int lo1
[r12-LoopBack1]ip add 172.16.176.1 20
[r12-LoopBack1]int lo0
[r12-LoopBack0]ip add 172.16.160.1 20
4、现在就可以在每个区域的各个路由器上宣告各自的区域OSPF了
[r1]ospf 1 router-id 1.1.1.1
[r1-ospf-1]area 1
[r1-ospf-1-area-0.0.0.1]network 172.16.0.0 0.0.255.255
[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 1
[r2-ospf-1-area-0.0.0.1]network 172.16.0.0 0.0.255.255
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 1
[R3-ospf-1-area-0.0.0.1]network 172.16.32.0 0.0.31.255
[R3]ospf 1
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 172.16.0.129 0.0.0.0
[r5]ospf 1 router-id 5.5.5.5
[r5-ospf-1]area 0
[r5-ospf-1-area-0.0.0.0]network 45.1.1.1 0.0.0.0
[r5-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
[r6-ospf-1]area 0
[r6-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.1.255
[r6]ospf 1 rou
[r6]ospf 1 router-id 6.6.6.6
[r6-ospf-1]area 2
[r6-ospf-1-area-0.0.0.2]network 172.16.64.0 0.0.0.255
[r7]ospf 1 router-id 7.7.7.7
[r7-ospf-1]area 0
[r7-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.3.255
[r7-ospf-1]area 3
[r7-ospf-1-area-0.0.0.3]network 172.16.96.0 0.0.0.255
[r8]ospf 1 router-id 8.8.8.8
[r8-ospf-1]ar
[r8-ospf-1]area 3
[r8-ospf-1-area-0.0.0.3]ne
[r8-ospf-1-area-0.0.0.3]network 172.16.0.0 0.0.255.255
[r9]ospf 1 router-id 9.9.9.9
[r9-ospf-1]area 3
[r9-ospf-1-area-0.0.0.3]network 172.16.96.0 0.0.0.255
[r9-ospf-1]area 4
[r9-ospf-1-area-0.0.0.4]network 172.16.128.0 0.0.1.255
[r10]ospf 1 router-id 10.10.10.10
[r10-ospf-1]area 4
[r10-ospf-1-area-0.0.0.4]network 172.16.0.0 0.0.255.255
[r11]ospf 1 router-id 11.11.11.11
[r11-ospf-1]area 2
[r11-ospf-1-area-0.0.0.2]network 172.16.0.0 0.0.255.255
[r12]ospf 1 router-id 12.12.12.12
[r12-ospf-1]area 2
[r12-ospf-1-area-0.0.0.2]network 172.16.65.6 0.0.0.0
[r12]rip 1
[r12-rip-1]version 2
[r12-rip-1]network 172.16.0.0
现在配置已经结束但是因为MGRE环境的缘故需要修改接口类型
[r3]interface Tunnel 0/0/0
[r3-Tunnel0/0/0]ospf network-type broadcast
[r5]interface Tunnel 0/0/0
[r5-Tunnel0/0/0]ospf network-type broadcast
[r6]interface Tunnel 0/0/0
[r6-Tunnel0/0/0]ospf network-type broadcast
[r7]interface Tunnel 0/0/0
[r7-Tunnel0/0/0]ospf network-type broadcast
这里再进行DR/BDR选举时会出现问题所以将除了r4位DR不要BDR将其他优先级全部修改为0
[r5-Tunnel0/0/0]ospf dr-priority 0
[r6-Tunnel0/0/0]ospf dr-priority 0
[r7-Tunnel0/0/0]ospf dr-priority 0
这时全部的邻居关系已经全部建立完成了
因为区域4时远离了骨干的区域无法通过OSPF学习到
还有r12的环回属于RIP也无法通过OSPF学习到
这里需要使用重发布让RIP进入到OSPF
[r12]ospf 1
[r12-ospf-1]import-route rip
然后也无法学习到r10的路由信息所以这里使用多进程重发布方式
先在r9的OSPF中删除r9到r10的网段
[r9-ospf-1]area 4
[r9-ospf-1-area-0.0.0.4]undo network 172.16.128.0 0.0.1.255
再创建一个进程2声明该网段
[r9]ospf 2
[r9-ospf-2]area 4
[r9-ospf-2-area-0.0.0.4]network 172.16.128.0 0.0.1.255
最后通过双向重发布将r9-r10网段发布到区域3中
[r9]ospf 1
[r9-ospf-1]import-route ospf 2
[r9]ospf 2
[r9-ospf-2]import-route ospf 1
测试:
5、实现第五个要求:减少LSA的更新量,加快收敛,保障更新安全
先优化非骨干区域:
将r1/2修改为完全末梢
[r1]ospf 1
[r1-ospf-1]area 1
[r1-ospf-1-area-0.0.0.1]stub
[r2]ospf 1
[r2-ospf-1]area 1
[r2-ospf-1-area-0.0.0.1]stub
[r3]ospf 1
[r3-ospf-1]area 1
[r3-ospf-1-area-0.0.0.1]stub no-summary
区域2的优化使用NSSA
[r11]ospf 1
[r11-ospf-1]area 2
[r11-ospf-1-area-0.0.0.2]nssa
[r12]ospf 1
[r12-ospf-1]area 2
[r12-ospf-1-area-0.0.0.2]nssa
[r6]ospf 1
[r6-ospf-1]area 2
[r6-ospf-1-area-0.0.0.2]nssa no-summary
下面优化r10的路由使用NSAA
[r8]ospf 1
[r8-ospf-1]area 3
[r8-ospf-1-area-0.0.0.3]nssa
[r9]ospf 1
[r9-ospf-1]area 3
[r9-ospf-1-area-0.0.0.3]nssa
[r7]ospf 1
[r7-ospf-1]area 3
[r7-ospf-1-area-0.0.0.3]nssa no-summary
在r2的OSPF 2进程中关闭ospf的双向重发布
[r9]ospf 2
[r9-ospf-2]undo import-route ospf 1
再用r9给r10发一条缺省
[r9-ospf-2]default-route-advertise
测试:
下面优化骨干区域
[r3]ospf 1
[r3-ospf-1]area 1
[r3-ospf-1-area-0.0.0.1]abr-summary 172.16.32.0 255.255.224.0
[r6]ospf 1
[r6-ospf-1]area 2
[r6-ospf-1-area-0.0.0.2]abr-summary 172.16.64.0 255.255.224.0
[r7]ospf 1
[r7-ospf-1]area 3
[r7-ospf-1-area-0.0.0.3]abr-summary 172.16.96.0 255.255.224.0
[r12]ospf 1
[r12-ospf-1]asbr-summary 172.16.160.0 255.255.224.0
[r9]ospf 1
[r9-ospf-1]asbr-summary 172.16.128.0 255.255.224.0
防环:
[r3]ip route-static 172.16.32.0 19 NULL 0
[r6]ip route-static 172.16.64.0 19 NULL 0
[r9]ip route-static 172.16.128.0 19 NULL 0
[r12]ip route-static 172.16.160.0 19 NULL 0
6、实现最后一个目标:所有设备均可访问R4的环回
使用nat实现公网和私网的互联
[r3]acl 2000
[r3-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[r3]interface GigabitEthernet 0/0/1
[r3-GigabitEthernet0/0/1]nat outbound 2000
[r6]acl 2000
[r6-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[r6-acl-basic-2000]int gi0/0/1
[r6-GigabitEthernet0/0/1]nat outbound 2000
[r7]acl 2000
[r7-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[r7]interface GigabitEthernet 0/0/1
[r7-GigabitEthernet0/0/1]nat outbound 2000
测试: