OSPF综合实验
一、实验要求
1,R4为ISP,其上只能配置IP地址;R4与其他所有直连设备间均使用公有IP
2,R3-R5/6/7为MGRE环境,R3为中心站点;
3,整个OSPF环境IP基于172.16.0.0/16划分;
4,所有设备均可访问R4的环回;
5,减少LSA的更新量,加快收敛,保障更新安全;
6,全网可达;
二、实验拓扑
如下图所示
三、IP地址划分
详细IP地址划分如下图
四、命令配置—IP地址配置
R1
[R1]in g0/0/0
[R1-GigabitEthernet0/0/0]ip address 172.16.10.1 24
[R1-GigabitEthernet0/0/0]q
[R1]interface LoopBack 0
[R1-LoopBack0]ip address 172.16.11.1 24
R2
[R2]interface LoopBack 0
[R2-LoopBack0]ip address 172.16.12.1 24
[R2-LoopBack0]q
[R2]interface g0/0/0
[R2-GigabitEthernet0/0/0]ip address 172.16.10.2 24
R3
[R3]interface LoopBack 0
[R3-LoopBack0]ip address 172.16.13.1 24
[R3-LoopBack0]q
[R3]interface g0/0/0
[R3-GigabitEthernet0/0/0]ip address 172.16.10.3 24
[R3-GigabitEthernet0/0/0]q
[R3]interface se4/0/0
[R3-Serial4/0/0]ip address 34.0.0.1 8
R4
[ISP]interface se4/0/0
[ISP-Serial4/0/0]ip address 34.0.0.2 8
[ISP-Serial4/0/0]q
[ISP]interface se 4/0/1
[ISP-Serial4/0/1]ip address 45.0.0.2 8
[ISP-Serial4/0/1]q
[ISP]interface se3/0/0
[ISP-Serial3/0/0]ip address 46.0.0.2 8
[ISP-Serial3/0/0]q
[ISP]interface g0/0/0
[ISP-GigabitEthernet0/0/0]ip address 47.0.0.2 8
R5
[R5]interface LoopBack 0
[R5-LoopBack0]ip address 172.16.5.1 24
[R5-LoopBack0]q
[R5]interface se4/0/0
[R5-Serial4/0/0]ip address 45.0.0.1 8
R6
[R6]interface LoopBack 0
[R6-LoopBack0]ip address 172.16.6.1 24
[R6-LoopBack0]q
[R6]in se4/0/0
[R6-Serial4/0/0]ip address 46.0.0.1 8
[R6-Serial4/0/0]q
[R6]interface g0/0/0
[R6-GigabitEthernet0/0/0]ip address 172.16.20.1 24
R7
[R7]interface LoopBack 0
[R7-LoopBack0]ip address 172.16.7.1 24
[R7-LoopBack0]q
[R7]interface g0/0/0
[R7-GigabitEthernet0/0/0]ip address 47.0.0.1 8
[R7-GigabitEthernet0/0/0]q
[R7]interface g0/0/1
[R7-GigabitEthernet0/0/1]ip address 172.16.30.1 24
R8
[R8]interface LoopBack 0
[R8-LoopBack0]ip address 172.16.38.1 24
[R8-LoopBack0]q
[R8]interface g0/0/0
[R8-GigabitEthernet0/0/0]ip address 172.16.30.2 24
[R8-GigabitEthernet0/0/0]q
[R8]interface g0/0/1
[R8-GigabitEthernet0/0/1]ip address 172.16.31.1 24
R9
[R9]interface LoopBack 0
[R9-LoopBack0]ip address 172.16.39.1 24
[R9-LoopBack0]q
[R9]interface g0/0/0
[R9-GigabitEthernet0/0/0]ip address 172.16.31.2 24
[R9-GigabitEthernet0/0/0]q
[R9]interface g0/0/1
[R9-GigabitEthernet0/0/1]ip address 172.16.40.1 24
R10
[R10]interface LoopBack 0
[R10-LoopBack0]ip address 172.16.41.1 24
[R10-LoopBack0]q
[R10]interface g0/0/0
[R10-GigabitEthernet0/0/0]ip address 172.16.40.2 24
R11
[R11]interface LoopBack 0
[R11-LoopBack0]ip address 172.16.22.1 24
[R11-LoopBack0]q
[R11]interface g0/0/0
[R11-GigabitEthernet0/0/0]ip address 172.16.20.2 24
[R11-GigabitEthernet0/0/0]q
[R11]interface g0/0/1
[R11-GigabitEthernet0/0/1]ip address 172.16.21.1 24
R12
[R12]interface LoopBack 0
[R12-LoopBack0]ip address 172.16.24.1 24
[R12-LoopBack0]q
[R12]interface g0/0/0
[R12-GigabitEthernet0/0/0]ip address 172.16.21.2 24
[R12-GigabitEthernet0/0/0]q
五、命令配置—OSPF配置
R1
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]a 1
[R1-ospf-1-area-0.0.0.1]network 172.16.11.0 0.0.0.255
[R1-ospf-1-area-0.0.0.1]network 172.16.10.0 0.0.0.255
R2
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]a 1
[R2-ospf-1-area-0.0.0.1]network 172.16.12.0 0.0.0.255
[R2-ospf-1-area-0.0.0.1]network 172.16.10.0 0.0.0.255
R3
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]a 1
[R3-ospf-1-area-0.0.0.1]network 172.16.13.0 0.0.0.255
[R3-ospf-1-area-0.0.0.1]network 172.16.10.0 0.0.0.255
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]a 0
[R3-ospf-1-area-0.0.0.0]network 34.0.0.0 0.255.255.255
[R3-ospf-1-area-0.0.0.0]network 172.16.1.0 0.0.0.255
R5
[R5]ospf 1 router-id 5.5.5.5
[R5-ospf-1]a 0
[R5-ospf-1-area-0.0.0.0]network 172.16.5.0 0.0.0.255
[R5-ospf-1-area-0.0.0.0]network 172.16.1.0 0.0.0.255
[R5-ospf-1-area-0.0.0.0]network 45.0.0.0 0.255.255.255
R6
[R6]ospf 1 router-id 6.6.6.6
[R6-ospf-1]a 0
[R6-ospf-1-area-0.0.0.0]network 172.16.1.0 0.0.0.255
[R6-ospf-1-area-0.0.0.0]network 46.0.0.0 0.255.255.255
[R6]ospf 1 router-id 6.6.6.6
[R6-ospf-1]a 2
[R6-ospf-1-area-0.0.0.2]network 172.16.6.0 0.0.0.255
[R6-ospf-1-area-0.0.0.2]network 172.16.20.0 0.0.0.255
[R6-ospf-1-area-0.0.0.2]q
R7
[R7]ospf 1 router-id 7.7.7.7
[R7-ospf-1]a 0
[R7-ospf-1-area-0.0.0.0]network 47.0.0.0 0.255.255.255
[R7-ospf-1-area-0.0.0.0]network 172.16.1.0 0.0.0.255
[R7]ospf 1 router-id 7.7.7.7
[R7-ospf-1]a 3
[R7-ospf-1-area-0.0.0.3]network 172.16.7.0 0.0.0.255
[R7-ospf-1-area-0.0.0.3]network 172.16.30.0 0.0.0.255
[R7-ospf-1-area-0.0.0.3]q
R8
[R8]ospf 1 router-id 8.8.8.8
[R8-ospf-1]a 3
[R8-ospf-1-area-0.0.0.3]network 172.16.30.0 0.0.0.255
[R8-ospf-1-area-0.0.0.3]network 172.16.31.0 0.0.0.255
[R8-ospf-1-area-0.0.0.3]network 172.16.38.0 0.0.0.255
R9
[R9]ospf 1 router-id 9.9.9.9
[R9-ospf-1]a 3
[R9-ospf-1-area-0.0.0.3]network 172.16.31.0 0.0.0.255
[R9-ospf-1-area-0.0.0.3]q
[R9-ospf-1]q
[R9]ospf 2 router-id 9.9.9.9
[R9-ospf-2]a 4
[R9-ospf-2-area-0.0.0.4]network 172.16.39.0 0.0.0.255
[R9-ospf-2-area-0.0.0.4]network 172.16.40.0 0.0.0.255
R10
[R10]ospf 2 router-id 10.10.10.10
[R10-ospf-2]a 4
[R10-ospf-2-area-0.0.0.4]network 172.16.41.0 0.0.0.255
[R10-ospf-2-area-0.0.0.4]network 172.16.40.0 0.0.0.255
area 4按不规则区域处理,在R9进行路由引入
[R9]ospf 1
[R9-ospf-1]import-route ospf 2
R11
[R11]ospf 1 router-id 11.11.11.11
[R11-ospf-1]a 2
[R11-ospf-1-area-0.0.0.2]network 172.16.21.0 0.0.0.255
[R11-ospf-1-area-0.0.0.2]network 172.16.22.0 0.0.0.255
[R11-ospf-1-area-0.0.0.2]network 172.16.20.0 0.0.0.255
R12
[R12]ospf 1 router-id 12.12.12.12
[R12-ospf-1]a 2
[R12-ospf-1-area-0.0.0.2]network 172.16.21.0 0.0.0.255
[R12-ospf-1-area-0.0.0.2]q
[R12]rip 1
[R12-rip-1]network 172.16.0.0
[R12-rip-1]q
随机Ping测试结果如下
六、命令配置—搭建MGRE环境
R3
[R3]ip route-static 0.0.0.0 0 34.0.0.2
[R3]interface t0/0/0
[R3-Tunnel0/0/0]ip address 172.16.1.1 24
[R3-Tunnel0/0/0]tunnel-protocol gre p2mp
[R3-Tunnel0/0/0]source 34.0.0.1
[R3-Tunnel0/0/0]nhrp network-id 100
[R3-Tunnel0/0/0]nhrp entry multicast dynamic
[R3-Tunnel0/0/0]ospf network-type broadcast
R5
[R5]ip route-static 0.0.0.0 0 45.0.0.2
[R5]interface t0/0/0
[R5-Tunnel0/0/0]ip address 172.16.1.2 24
[R5-Tunnel0/0/0]tunnel-protocol gre p2mp
[R5-Tunnel0/0/0]nhrp network-id 100
[R5-Tunnel0/0/0]source 45.0.0.1
[R5-Tunnel0/0/0]nhrp entry 172.16.1.1 34.0.0.1 register
[R5-Tunnel0/0/0]ospf network-type broadcast
R6
[R6]ip route-static 0.0.0.0 0 46.0.0.2
[R6]interface Tunnel 0/0/0
[R6-Tunnel0/0/0]ip address 172.16.1.3 24
[R6-Tunnel0/0/0]tunnel-protocol gre p2mp
[R6-Tunnel0/0/0]source 46.0.0.1
[R6-Tunnel0/0/0]nhrp network-id 100
[R6-Tunnel0/0/0]nhrp entry 172.16.1.1 34.0.0.1 register
[R6-Tunnel0/0/0]ospf network-type broadcast
R7
[R7]ip route-static 0.0.0.0 0 47.0.0.2
[R7]interface t0/0/0
[R7-Tunnel0/0/0]ip address 172.16.1.4 24
[R7-Tunnel0/0/0]tunnel-protocol gre p2mp
[R7-Tunnel0/0/0]nhrp network-id 100
[R7-Tunnel0/0/0]source 47.0.0.1
[R7-Tunnel0/0/0]nhrp entry 172.16.1.1 34.0.0.1 register
[R7-Tunnel0/0/0]ospf network-type broadcast
随机Ping测试结果如下
七、命令配置—配置NAT
R3
[R3]acl 2000
[R3-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[R3-acl-basic-2000]q
[R3]in se4/0/0
[R3-Serial4/0/0]nat outbound 2000
R6
[R6]acl 2000
[R6-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[R6]in se4/0/0
[R6-Serial4/0/0]nat outbound 2000
R7
[R7]acl 2000
[R7-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[R7-acl-basic-2000]q
[R7]interface g0/0/0
[R7-GigabitEthernet0/0/0]nat outbound 2000
八、命令配置—线路优化
area 1
R1-R3
[R1-ospf-1-area-0.0.0.1]stub no-summary
[R2-ospf-1-area-0.0.0.1]stub no-summary
[R3-ospf-1-area-0.0.0.1]stub no-summary
area 2
R6 R11 R12
[R6-ospf-1-area-0.0.0.2]nssa no-summary
[R11-ospf-1-area-0.0.0.2]nssa no-summary
[R12-ospf-1-area-0.0.0.2]nssa no-summary
area 3
R7-R9
[R7-ospf-1-area-0.0.0.3]nssa no-summary
[R8-ospf-1-area-0.0.0.3]nssa no-summary
[R9-ospf-1-area-0.0.0.3]nssa no-summary
area 4
[R9]ospf 2
[R9-ospf-2]default-route-advertise always
九、全网Ping通测试
测试结果如下图
实验成功