由题目可知,我们可以将整张拓扑图非为6大块,所有可以将母网的子网掩码向主机位借三位,每个区域再根据区域的实际情况再进行划分,这样有助于汇总
172.16.0.0/16
172.16.0.0/19 a0
172.16.0.0/25(点到点骨干) 172.16.0.0/30
172.16.0.128/25(MA骨干) 172.16.0.128/29
172.16.1.0/25 --- 172.16.31.128/25(用户)
172.16.32.0/19 a1
172.16.32.0/25(点到点骨干) 172.16.32.0/30
172.16.32.128/25(MA骨干) 172.16.32.128/29
172.16.33.0/25 --- 172.16.63.128/25(用户)
172.16.64.0/19 a2
172.16.64.0/25(点到点骨干) 172.16.64.0/30
172.16.64.128/25(MA骨干) 172.16.64.128/29
172.16.65.0/25 --- 172.16.95.128/25(用户)
172.16.96.0/19 a3
172.16.96.0/25(点到点骨干) 172.16.96.0/30
172.16.96.128/25(MA骨干) 172.16.96.128/29
172.16.97.0/25 --- 172.16.127.128/25(用户)
172.16.128.0/19 a4
172.16.128.0/25(点到点骨干) 172.16.128.0/30
172.16.128.128/25(MA骨干) 172.16.128.128/29
172.16.129.0/25 --- 172.16.159.128/25(用户)
172.16.160.0/19 RIP 172.16.160.0/20 172.16.176.0/20
172.16.192.0/24
172.16.224.0/24
公网IP地址的配置
[Huawei]sysname r4
[r4]interface Serial 4/0/0
[r4-Serial4/0/0]ip add 34.1.1.2 24
[r4-Serial4/0/0]int s4/0/1
[r4-Serial4/0/1]ip add 45.1.1.2 24
[r4-Serial4/0/0]int s3/0/0
[r4-Serial3/0/0]ip add 46.1.1.2 24
[r4-Serial3/0/0]int s3/0/1
[r4-Serial3/0/1]ip add 47.1.1.2 24
[r3]int s3/0/0
[r3-Serial3/0/0]ip add 34.1.1.1 24
[Huawei]sysname r5
[r5]int s4/0/0
[r5-Serial4/0/0]ip add 45.1.1.1 24
[Huawei]sysname r6
[r6]int s4/0/0
[r6-Serial4/0/0]ip add 46.1.1.1 24
[Huawei]sysname r7
[r7]int s4/0/0
[r7-Serial4/0/0]ip add 47.1.1.1 24
配置静态路由,使公网全网可达
[r3]ip route-static 0.0.0.0 0 34.1.1.2
[r5]ip route-static 0.0.0.0 0 45.1.1.2
[r6]ip route-static 0.0.0.0 0 46.1.1.2
[r7]ip route-static 0.0.0.0 0 47.1.1.2
area0
[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
[r3-Tunnel0/0/0]nhrp network-id 100
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add 172.16.32.131 29
[r3-GigabitEthernet0/0/0]int l0
[r3-LoopBack0]ip add 172.16.34.1 25
[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.3.255
[r3-ospf-1-area-0.0.0.1]q
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0]network 172.16.0.129 0.0.0.0
[r5]int 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 45.1.1.1
[r5-Tunnel0/0/0]nhrp network-id 100
[r5-Tunnel0/0/0]nhrp entry 172.16.0.129 34.1.1.1 register
[r5]int l0
[r5-LoopBack0]ip add 172.16.1.129 25
[r5-LoopBack0]q
[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]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 46.1.1.1
[r6-Tunnel0/0/0]nhrp entry 172.16.0.129 34.1.1.1 register
[r6-Tunnel0/0/0]nhrp network-id 100
[r6]int l0
[r6-LoopBack0]ip add 172.16.2.1 25
[r6-LoopBack0]int g0/0/0
[r6-GigabitEthernet0/0/0]ip add 172.16.64.1 30
[r6]ospf 1 router-id 6.6.6.6
[r6-ospf-1]area 0
[r6-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.3.255
[r6-ospf-1-area-0.0.0.0]q
[r6-ospf-1]area 2
[r6-ospf-1-area-0.0.0.2]network 172.16.64.1 0.0.0.255
[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 47.1.1.1
[r7-Tunnel0/0/0]nhrp entry 172.16.0.129 34.1.1.1 register
[r7-Tunnel0/0/0]nhrp network-id 100
[r7]int l0
[r7-LoopBack0]ip add 172.16.2.129 25
[r7-LoopBack0]int g0/0/0
[r7-GigabitEthernet0/0/0]ip add 172.16.96.1 30
[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-0.0.0.0]q
[r7-ospf-1]area 3
[r7-ospf-1-area-0.0.0.3]network 172.16.96.1 0.0.0.0
因为MGRE环境默认是点到点网络类型,只能成立一个邻接关系,这样显然是不行的,所以要将R3/5/6/7的网络类型全部修改为广播类型,并让R5/6/7路由器档期选举,让R3成为DR
代码如下:
[r3]int Tunnel 0/0/0
[r3-Tunnel0/0/0]ospf network-type broadcast
[r5]int t0/0/0
[r5-Tunnel0/0/0]ospf network-type broadcast
[r5-Tunnel0/0/0]ospf dr-priority 0
[r6-Serial4/0/0]int t0/0/0
[r6-Tunnel0/0/0]ospf network-type broadcast
[r6-Tunnel0/0/0]ospf dr-priority 0
[r7]int Tunnel 0/0/0
[r7-Tunnel0/0/0]ospf network-type broadcast
[r7-Tunnel0/0/0]ospf dr-priority 0
area 1
[Huawei]sysname r1
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 172.16.32.129 29
[r1-GigabitEthernet0/0/0]int l0
[r1-LoopBack0]ip add 172.16.33.1 25
[r1]ospf 1 router-id 1.1.1.1
[r1-ospf-1]are
[r1-ospf-1]area 1
[r1-ospf-1-area-0.0.0.1]net
[r1-ospf-1-area-0.0.0.1]network 172.16.0.0 0.0.255.255
[Huawei]sysname r2
[r2]interface GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]ip add 172.16.32.130 29
[r2-GigabitEthernet0/0/0]int l0
[r2-LoopBack0]ip add 172.16.33.129 25
[r2-LoopBack0]q
[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
area 2
[Huawei]sysname r11
[r11]int g0/0/0
[r11-GigabitEthernet0/0/0]ip add 172.16.64.2 30
[r11-GigabitEthernet0/0/0]int l0
[r11-LoopBack0]ip add 172.16.65.1 25
[r11-LoopBack0]q
[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
[Huawei]sysname r12
[r12]int g0/0/0
[r12-GigabitEthernet0/0/0]ip add 172.16.64.6 30
[r12-GigabitEthernet0/0/0]int l0
[r12-LoopBack0]ip add 172.16.160.1 20
[r12-LoopBack0]int l1
[r12-LoopBack1]ip add 172.16.176.1 20
[r12-LoopBack1]q
[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.64.6 0.0.0.0
rip协议配置
[r12-ospf-1-area-0.0.0.2]q
[r12-ospf-1]q
[r12]rip 1
[r12-rip-1]version 2
[r12-rip-1]network 172.16.0.0
area 3
[Huawei]sysname r8
[r8]interface GigabitEthernet 0/0/0
[r8-GigabitEthernet0/0/0]ip add 172.16.96.2 30
[r8-GigabitEthernet0/0/0]int g0/0/1
[r8-GigabitEthernet0/0/1]ip add 172.16.96.5 30
[r8-GigabitEthernet0/0/1]int l0
[r8-LoopBack0]ip add 172.16.97.1 25
[r8-LoopBack0]q
[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
[Huawei]sysname r9
[r9]int g0/0/0
[r9-GigabitEthernet0/0/0]ip add 172.16.96.6 30
[r9-GigabitEthernet0/0/0]int g0/0/1
[r9-GigabitEthernet0/0/1]ip add 172.16.128.1 30
[r9-GigabitEthernet0/0/1]int l0
[r9-LoopBack0]ip add 172.16.129.1 25
[r9-LoopBack0]q
[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
area 4
因为区域4没有与骨干区域直连,所以将区域4划分到进程2中,这样方便后期利用重发布的知识将两个进程互通。
[r9-ospf-1-area-0.0.0.3]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
[Huawei]sysname r10
[r10]int g0/0/0
[r10-GigabitEthernet0/0/0]ip add 172.16.128.2 30
[r10-GigabitEthernet0/0/0]int l0
[r10-LoopBack0]ip add 172.16.129.129 25
[r10]ospf 2 router-id 10.10.10.10
[r10-ospf-2]area 4
[r10-ospf-2-area-0.0.0.4]network 172.16.0.0 0.0.255.255
利用重发布知识,将区域4与rip区域的路由重发布到ospf1中,并将ospf1中的路由重发布到区域4和rip区域中
[r9]ospf 1
[r9-ospf-1]import-route ospf 2
[r9-ospf-1]q
[r9]ospf 2
[r9-ospf-2]import-route ospf 1
[r12]ospf 1
[r12-ospf-1]import-route rip
[r12-ospf-1]q
[r12]rip 1
[r12-rip-1]import-route ospf 1
查看部分路由表的路由
汇总
area1汇总
[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
area 2汇总
[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
area 3 汇总
[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
area4与rip为域外汇总
area4汇总
[r9]ospf 1
[r9-ospf-1]asbr-summary 172.16.128.0 255.255.224.0
rip汇总
[r12]ospf 1
[r12-ospf-1]asbr-summary 172.16.160.0 255.255.224.0
配置完全末梢与完全NSSA来优化其他区域
将area1配置为完全末梢
[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
将area2与area3配置为NSSA区域
[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
区域4的优化
关闭AR9上OSPF2指向OSPF1上的重发布,在AR9上写一条缺省路由,让AR10的缺省指向AR9
[r9-ospf-2]undo import-route ospf 1
[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]q
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]int s3/0/0
[r3-Serial3/0/0]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]q
[r6]int s4/0/0
[r6-Serial4/0/0]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]q
[r7]int s4/0/0
[r7-Serial4/0/0]nat outbound 2000
测试
AR4路由器的环回地址为172.16.1.1
防止产生黑洞,在接口上设置空接口
[r3]ip route-static 172.16.32.0 19 NULL 0
[r6]ip route-static 172.16.64.0 19 NULL 0
[r7]ip route-static 172.16.96.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