实验要求
![在这里插入图片描述](https://img-blog.csdnimg.cn/524afbbde7214fa1b7dd4ffb736f4793.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5YKy54S2Kg==,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center)
- R4为ISP,其只能配置IP地址;R4与其他所有直连设备间均使用公有IP;
- R3-R5/6/7为MGRE环境,R3为中心站点;
- 整个OSPF环境IP基于172.16.0.0/16划分;
- 所有设备均可访问R4的环回;
- 减少LSA的更新量,加快收敛,保障更新安全;
- 全网可达
实验思路
IP地址规划
- 公网IP随便配置,这里我R3-R4的网段为34.1.1.0/24, R5-R4的网段为54.1.1.0/24,其他同此
- 私网基于172.16.0.0/16划分,首先整个私网运行了两个路由协议,所以先将172.16.0.0/16划分为172.16.0.0/17和172.16.128.0/17两个网段,其中172.16.0.0/16给ospf,172.16.128.0/17给rip
- 整个OSPF域基于172.16.0.0/16划分,这里我们给每个OSPF区域掩码为24的网段,area 0为172.16.0.0/24;area 1为172.16.1.0/24;area 2为172.16.2.0/24,其他同此。
- OSPF单个区域内部IP根据网段数进行划分
- RIP域只有两个接口,分别配置为172.16.128.1/24和172.16.128.129.1/24
![在这里插入图片描述](https://img-blog.csdnimg.cn/afcaa4fdb56b44a297ec1b9a2c18fb33.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5YKy54S2Kg==,size_20,color_FFFFFF,t_70,g_se,x_16)
路由
- 边界路由器配置一条指向ISP的静态缺省
- 搭建MGRE环境,tunnel口IP为OSPFarea 0的IP。
- 私网设备启动OSPF和RIP,OSPF不规则区域都使用重发布解决,并配置OSPF特殊区域,非骨干区域都会自动下发缺省指向骨干区域,在R9上将域外路由汇总为0.0.0.0导入到area 4中
- 在边界路由器还需要配置空接口,防止路由黑洞
- 在边界路由器上配置NAT
实验配置
R1上配置
interface GigabitEthernet0/0/0
ip address 172.16.1.65 255.255.255.192
interface LoopBack0
ip address 172.16.1.1 255.255.255.192
ospf 1 router-id 1.1.1.1
area 0.0.0.1
network 172.16.1.0 0.0.0.255
stub
R2上配置
interface GigabitEthernet0/0/0
ip address 172.16.1.66 255.255.255.192
interface LoopBack0
ip address 172.16.128.1 255.255.252.0
ospf 1 router-id 2.2.2.2
area 0.0.0.1
network 172.16.1.0 0.0.0.255
stub
R3上配置
acl number 2000
rule 5 permit source 172.16.1.0 0.0.0.255
interface Serial4/0/0
link-protocol ppp
ip address 34.1.1.1 255.255.255.0
nat outbound 2000 -- 一对多NAT配置
interface GigabitEthernet0/0/0
ip address 172.16.1.67 255.255.255.192
interface LoopBack0
ip address 172.16.1.193 255.255.255.192
interface Tunnel0/0/0
ip address 172.16.0.1 255.255.255.192
tunnel-protocol gre p2mp
source 34.1.1.1
ospf network-type p2mp --- 更改tunnel口的接口网络类型为p2mp,该类型不需要进行DR/BDR选举,且可以建立多个邻居
nhrp entry multicast dynamic
nhrp network-id 100
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 172.16.0.0 0.0.0.255
area 0.0.0.1
abr-summary 172.16.1.0 255.255.255.0 ---- 将该区域的路由进行汇总就传递给其他区域
network 172.16.1.0 0.0.0.255
stub no-summary
ip route-static 0.0.0.0 0.0.0.0 34.1.1.2
ip route-static 172.16.1.0 255.255.255.0 null0
R4上配置
interface Serial2/0/0
link-protocol ppp
ip address 34.1.1.2 255.255.255.0
interface Serial2/0/1
link-protocol ppp
ip address 54.1.1.2 255.255.255.0
interface Serial3/0/0
link-protocol ppp
ip address 64.1.1.2 255.255.255.0
interface GigabitEthernet0/0/0
ip address 74.1.1.2 255.255.255.0
interface LoopBack0
ip address 8.8.8.8 255.255.255.0
R5上配置
interface Serial4/0/0
link-protocol ppp
ip address 54.1.1.1 255.255.255.0
interface LoopBack0
ip address 172.16.0.65 255.255.255.192
interface Tunnel0/0/0
ip address 172.16.0.2 255.255.255.192
tunnel-protocol gre p2mp
source Serial4/0/0
ospf network-type p2mp --- 更改接口类型为OSPF,因为p2mp模式的hello时间为30s,如果hello时间不同,无法建立邻居关系
nhrp network-id 100
nhrp entry 172.16.0.1 34.1.1.1 register
ospf 1 router-id 5.5.5.5
area 0.0.0.0
network 172.16.0.0 0.0.0.255
ip route-static 0.0.0.0 0.0.0.0 54.1.1.2
R6上配置
acl number 2000
rule 5 permit source 172.16.0.0 0.0.255.255
interface Serial4/0/0
link-protocol ppp
ip address 64.1.1.1 255.255.255.0
nat outbound 2000 --- 一对多NAT配置
interface GigabitEthernet0/0/0
ip address 172.16.2.1 255.255.255.192
interface LoopBack0
ip address 172.16.0.129 255.255.255.192
interface Tunnel0/0/0
ip address 172.16.0.3 255.255.255.192
tunnel-protocol gre p2mp
source Serial4/0/0
ospf network-type p2mp
nhrp network-id 100
nhrp entry 172.16.0.1 34.1.1.1 register
ospf 1 router-id 6.6.6.6
area 0.0.0.0
network 172.16.0.0 0.0.0.255
area 0.0.0.2
abr-summary 172.16.2.0 255.255.255.0 --- 将该区域的路由进行汇总就传递给其他区域
network 172.16.2.0 0.0.0.255
nssa no-summary --- 配置该区域为完全的末梢区域
ip route-static 0.0.0.0 0.0.0.0 64.1.1.2
ip route-static 172.16.2.0 255.255.255.0 null0
R7上配置
acl number 2000
rule 5 permit source 172.16.0.0 0.0.255.255
interface GigabitEthernet0/0/0
ip address 74.1.1.1 255.255.255.0
nat outbound 2000 --- 一对多NAT配置
interface GigabitEthernet0/0/1
ip address 172.16.3.1 255.255.255.192
interface LoopBack0
ip address 172.16.0.193 255.255.255.192
interface Tunnel0/0/0
ip address 172.16.0.4 255.255.255.192
tunnel-protocol gre p2mp
source GigabitEthernet0/0/0
ospf network-type p2mp
nhrp network-id 100
nhrp entry 172.16.0.1 34.1.1.1 register
ospf 1 router-id 7.7.7.7
area 0.0.0.0
network 172.16.0.0 0.0.0.255
area 0.0.0.3
abr-summary 172.16.3.0 255.255.255.0 ---- 将该区域的路由进行汇总就传递给其他区域
network 172.16.3.0 0.0.0.255
nssa no-summary --- 配置该区域为完全的非完全末梢区域
ip route-static 0.0.0.0 0.0.0.0 74.1.1.2
ip route-static 172.16.3.0 255.255.255.0 null0
R8上配置
interface GigabitEthernet0/0/0
ip address 172.16.3.2 255.255.255.192
interface GigabitEthernet0/0/1
ip address 172.16.3.129 255.255.255.192
interface GigabitEthernet0/0/2
interface NULL0
interface LoopBack0
ip address 172.16.3.65 255.255.255.192
ospf 1 router-id 8.8.8.8
area 0.0.0.3
network 172.16.3.0 0.0.0.255
nssa --- 配置该区域为NSSA
R9上配置
interface GigabitEthernet0/0/0
ip address 172.16.3.130 255.255.255.192
interface GigabitEthernet0/0/1
ip address 172.16.4.65 255.255.255.192
interface LoopBack0
ip address 172.16.4.1 255.255.255.192
ospf 1 router-id 9.9.9.9
asbr-summary 172.16.4.0 255.255.255.0 --- 将域外路由进行汇总
import-route ospf 2 --- 将OSPF进程2的路由导入
area 0.0.0.3
network 172.16.3.0 0.0.0.255
nssa --- 配置该区域为NSSA
ospf 2 router-id 9.9.9.9
asbr-summary 0.0.0.0 0.0.0.0 --- 将导入的路由汇总为0.0.0.0,即所有路由,相当于下发一条缺省路由
import-route ospf 1 --- 导入ospf进程1的路由
area 0.0.0.4
network 172.16.4.0 0.0.0.255
R10上配置
interface GigabitEthernet0/0/0
ip address 172.16.4.66 255.255.255.192
interface LoopBack0
ip address 172.16.4.129 255.255.255.192
ospf 1 router-id 10.10.10.10
area 0.0.0.4
network 172.16.4.0 0.0.0.255
R11上配置
interface GigabitEthernet0/0/0
ip address 172.16.2.2 255.255.255.192
interface GigabitEthernet0/0/1
ip address 172.16.2.129 255.255.255.192
interface LoopBack0
ip address 172.16.2.65 255.255.255.192
ospf 1 router-id 11.11.11.11
area 0.0.0.2
network 172.16.2.0 0.0.0.255
nssa --- 配置该区域为NSSA
R12上配置
interface GigabitEthernet0/0/0
ip address 172.16.2.130 255.255.255.192
interface LoopBack1
ip address 172.16.128.1 255.255.255.0
interface LoopBack2
ip address 172.16.129.1 255.255.255.0
ospf 1 router-id 12.12.12.12
asbr-summary 172.16.128.0 255.255.192.0 ---将导入的路由进行汇总
import-route rip 1 --- 导入RIP进程的路由
area 0.0.0.2
network 172.16.2.0 0.0.0.255
nssa --- 配置该区域为NSSA
rip 1
undo summary
version 2
network 172.16.0.0
import-route ospf 1
实验测试
R10pingR4的环回
![在这里插入图片描述](https://img-blog.csdnimg.cn/c6c8974bae45406b97841722bfa9ef1e.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5YKy54S2Kg==,size_20,color_FFFFFF,t_70,g_se,x_16)
R10pingR12的环回
![在这里插入图片描述](https://img-blog.csdnimg.cn/9f687274031e4b9ca95e665730cb3544.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5YKy54S2Kg==,size_20,color_FFFFFF,t_70,g_se,x_16)
R10pingR1
![在这里插入图片描述](https://img-blog.csdnimg.cn/fb4208ff5e6e49f2a1fa4fac91bb3716.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5YKy54S2Kg==,size_20,color_FFFFFF,t_70,g_se,x_16)