注意:
1.ospf不以一个路由器为单位汇总,rip可以。ospf只支持区域汇总。所以地址规划需要跟着区域走。多协议时地址划分时先按协议分,ospf以区域分,rip以路由器分,因为此题rip没有邻居,所以不需要ospf汇总之后再给rip,意思是可以看成6个区域划分,但在实际项目中需要先按协议分
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip ad 172.16.32.129 29
[r1]int lo0
[r1-LoopBack0]ip ad 172.16.33.1 25
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip ad 172.16.32.130 29
[r2]int lo0
[r2-LoopBack0]ip ad 172.16.33.129 25
[r3]int g0/0/2
[r3-GigabitEthernet0/0/2]ip ad 34.1.1.1 24
[r3]int lo0
[r3-LoopBack0]ip ad 172.16.34.1 25
[r4]int g0/0/0
[r4-GigabitEthernet0/0/0]ip ad 34.1.1.2 24
[r4]int g0/0/1
[r4-GigabitEthernet0/0/1]ip ad 54.1.1.2 24
[r4]int g0/0/2
[r4-GigabitEthernet0/0/2]ip ad 64.1.1.2 24
[r4]int lo0
[r4-LoopBack0]ip ad 4.4.4.4 24
[r5]int g0/0/2
[r5-GigabitEthernet0/0/2]ip ad 54.1.1.1 24
[r5]int lo0
[r5-LoopBack0]ip ad 172.16.1.1 25
[r6]int g0/0/2
[r6-GigabitEthernet0/0/2]ip ad 64.1.1.1 24
[r6]int lo0
[r6-LoopBack0]ip ad 172.16.1.129 25
[r6]int g0/0/1
[r6-GigabitEthernet0/0/1]ip ad 172.16.64.1 30
[r7]int g0/0/2
[r7-GigabitEthernet0/0/2]ip ad 74.1.1.1 24
[r7]int lo0
[r7-LoopBack0]ip ad 172.16.2.1 25
[r8]int g0/0/0
[r8-GigabitEthernet0/0/0]ip ad 172.16.96.2 30
[r8-GigabitEthernet0/0/0]int g0/0/1
[r8-GigabitEthernet0/0/1]ip ad 172.16.96.5 30
[r8-GigabitEthernet0/0/1]int lo0
[r8-LoopBack0]ip ad 172.16.97.1 25
[r9]int g0/0/0
[r9-GigabitEthernet0/0/0]ip ad 172.16.96.6 30
[r9-GigabitEthernet0/0/0]int g0/0/1
[r9-GigabitEthernet0/0/1]ip ad 172.16.128.1 30
[r9-GigabitEthernet0/0/1]int lo0
[r9-LoopBack0]ip ad 172.16.129.1 25
[r10]int g0/0/0
[r10-GigabitEthernet0/0/0]ip ad 172.16.128.2 30
[r10-GigabitEthernet0/0/0]int lo0
[r10-LoopBack0]ip ad 172.16.129.129 25
[r11]int g0/0/0
[r11-GigabitEthernet0/0/0]ip ad 172.16.64.2 30
[r11]int lo0
[r11-LoopBack0]ip ad 172.16.65.1 25
[r12]int g0/0/0
[r12-GigabitEthernet0/0/0]ip ad 172.16.64.6 30
[r12]int lo0
[r12-LoopBack0]ip ad 172.16.160.1 20
[r12-LoopBack0]int lo1
[r12-LoopBack1]ip ad 172.16.176.1 20
[r3]ip route-static 0.0.0.0 0 34.1.1.2
[r5]ip route-static 0.0.0.0 0 54.1.1.2
[r6]ip route-static 0.0.0.0 0 64.1.1.2
[r7]ip route-static 0.0.0.0 0 74.1.1.2
[r3]int Tunnel 0/0/0
[r3-Tunnel0/0/0]ip ad 172.16.0.129 29 (MA)
[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
[r3-Tunnel0/0/0]nhrp network-id 100
[r5]int Tunnel 0/0/0
[r5-Tunnel0/0/0]ip ad 172.16.0.130 29
[r5-Tunnel0/0/0]tunnel-protocol gre p2mp
[r5-Tunnel0/0/0]source 54.1.1.1
[r5-Tunnel0/0/0]nhrp entry 172.16.0.129 34.1.1.1 register
[r5-Tunnel0/0/0]nhrp network-id 100
[r6]int Tunnel 0/0/0
[r6-Tunnel0/0/0]ip ad 172.16.0.131 29
[r6-Tunnel0/0/0]tunnel-protocol gre p2mp
[r6-Tunnel0/0/0]source GigabitEthernet 0/0/2
[r6-Tunnel0/0/0]nhrp entry 172.16.0.129 34.1.1.1 register
[r6-Tunnel0/0/0]nhrp network-id 100
[r7]int Tunnel 0/0/0
[r7-Tunnel0/0/0]ip ad 172.16.0.132 29
[r7-Tunnel0/0/0]tunnel-protocol gre p2mp
[r7-Tunnel0/0/0]source GigabitEthernet 0/0/2
[r7-Tunnel0/0/0]nhrp entry 172.16.0.129 34.1.1.1 register
[r7-Tunnel0/0/0]nhrp network-id 100
测试结果如图:
[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(把ar1的环回和接口地址都包含在内了)
[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 0
[r3-ospf-1-area-0.0.0.0]network 172.16.0.129 0.0.0.0
[r3-ospf-1]area 1
[r3-ospf-1-area-0.0.0.1]network 172.16.32.0 0.0.3.255(包含172.16.32.131 /29 172.16.34.1/25这两个,反掩码不能1和0穿插)
[r5]ospf 1 router-id 5.5.5.5
[r5-ospf-1]area 0
[r5-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
[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.1 0.0.0.0
[r6-ospf-1-area-0.0.0.2]q
[r6-ospf-1]area 0
[r6-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.1.255
(包含172.16.1.129/25 和172.16.0.131/29 有数字说明随意,0代表固定)
[r7]ospf 1 router-id 7.7.7.7
[r7-ospf-1]area 3
[r7-ospf-1-area-0.0.0.3]network 172.16.96.1 0.0.0.0
[r7-ospf-1-area-0.0.0.3]q
[r7-ospf-1]area 0
[r7-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.3.255
[r8]ospf 1 router-id 8.8.8.8
[r8-ospf-1]area 3
[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.6 0.0.0.0
[r9-ospf-1-area-0.0.0.3]q
[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]rip 1
[r12-rip-1]ver 2
[r12-rip-1]undo summary
[r12-rip-1]network 172.16.0.0(因为rip宣告的问题ar12左边的接口地址不仅被ospf宣告也被rip宣告)
由图可以看出有些邻居关系是没有建立成功的,因为公网是MGRE
[r3]int Tunnel 0/0/0
[r3-Tunnel0/0/0]ospf network-type broadcast
[r5]int Tunnel 0/0/0
[r5-Tunnel0/0/0]ospf network-type broadcast
[r6]int Tunnel 0/0/0
[r6-Tunnel0/0/0]ospf network-type broadcast
[r7]int Tunnel 0/0/0
[r7-Tunnel0/0/0]ospf network-type broadcast
[r5]int Tunnel 0/0/0
[r5-Tunnel0/0/0]ospf dr-priority 0
[r6]int Tunnel 0/0/0
[r6-Tunnel0/0/0]ospf dr-priority 0
[r7]int Tunnel 0/0/0
[r7-Tunnel0/0/0]ospf dr-priority 0
由上图可以发现区域4的172.16.128.0/19(不规则区域)以及rip部分没有出现
添加rip部分的
[r12]ospf 1
[r12-ospf-1]import-route rip(把rip的路由表共享给ospf)
由图可以看出,已经有了rip部分的了
添加区域4的172.16.128.0/19
(解决方法:多进程双向重发布)
多进程:
[r9]ospf 1
[r9-ospf-1]area 4
[r9-ospf-1-area-0.0.0.4]undo network 172.16.128.0 0.0.1.255
[r9-ospf-1-area-0.0.0.4]q
[r9-ospf-1]q
[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
由上图可以看出有两个进程,ar9和ar8建立邻居关系是进程1,ar9和ar10建立邻居关系是进程2
重发布:
易错:进程1和进程2容易搞错,所以可以把进程1看作ospf,进程2看作rip
[r9]ospf 1
[r9-ospf-1]import-route ospf 2 (把rip重发布到上面,也就是区域0-3都会学到区域4的内容,但是没有把上面的发下来,按理说需要把上面的内容发下来,但是这里可以不需要,直接写缺省路由,能够到上面就行了,为了减少LSA的更新量)
减少LSA的更新量:(汇总防环)
(1)优化区域0,即a0
a0学习了a1-4的路由和rip的部分,所以为了减少LSA更新量需要把a1-4以及rip的部分各汇成一条
查看数据库
汇总防环:
[r3]ospf
[r3-ospf-1]area 1
[r3-ospf-1-area-0.0.0.1]abr-summary 172.16.32.0 255.255.224.0
[r3]ip route-static 172.16.32.0 19 NULL 0 (防环,华为的ensp需要手写,思科的不需要,因为进行上面的汇总之后会自动产生这个防环)
[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
[r6-ospf-1-area-0.0.0.2]q
[r6-ospf-1]q
[r6]ip route-static 172.16.64.0 19 NULL 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
[r7-ospf-1-area-0.0.0.3]q
[r7-ospf-1]q
[r7]ip route-static 172.16.96.0 19 NULL 0
[r12]ospf 1
[r12-ospf-1]asbr-summary 172.16.160.0 255.255.224.0
[r12]ip route-static 172.16.160.0 19 NULL 0
[r9]ospf 1
[r9-ospf-1]asbr-summary 172.16.128.0 255.255.224.0
[r9-ospf-1]q
[r9]ip route-static 172.16.128.0 19 NULL 0
再次查看数据库
由图可以发现:已经汇成了五条,但是多了一条172.16.64.4.这里先不管。后面来解决。
[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 (完全末梢)
测试结果如下:
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210714223821660.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,t
(3)优化区域2,即a2
查看数据库
[r6]ospf 1
[r6-ospf-1]area 2
[r6-ospf-1-area-0.0.0.2]nssa no-summary
[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
测试结果如下:
在这里我们看到就没有172.16.64.4(数据库有,但是路由表没有了)
(4)优化区域3,即a3(把a4看成rip,做法和(3)一样)
[r7]ospf 1
[r7-ospf-1]area 3
[r7-ospf-1-area-0.0.0.3]nssa no-summary
[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
到这里第第五条要求就完成了
[r9]ospf 2
[r9-ospf-2]default-route-advertise (有路由表才发)
第四条要求就是要内网可以访问外网(需要缺省和nat)
[r3]acl 2000
[r3-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[r3-acl-basic-2000]int g0/0/2
[r3-GigabitEthernet0/0/2]nat outbound 2000
测试结果如图:
[r7]acl 2000
[r7-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[r7-acl-basic-2000]int g0/0/2
[r7-GigabitEthernet0/0/2]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 g0/0/2
[r6-GigabitEthernet0/0/2]nat outbound 2000
测试结果如下:
到这里这个实验就告一段了。。。。。。。。