实验拓扑图
一、实验要求
1、R4为ISP。其上只能配置ip地址;R4与其他所有直接设备间均使用共有IP;
2、R3-R5/6/7为MGRE环境,R3为中心站点;
3、整个OSPF环境IP基于172.16.0.0/16划分;
4、所有设备均可访问R4的环回;
5、全网可达
二、子网划分
172.16.0.0/16
172.16.0.0/19 用于area0
172.16.0.0/24
172.16.0.0/30
172.16.0.4/30
........
172.16.1.0/24
172.16.1.0/29
172.16.1.8/29
.......
.......
172.16.32.0/19 用于area1
172.16.32.0/24
172.16.32.0/30
172.16.32.4/30
.........
172.16.33.0/24
172.16.33.0/29
172.16.33.8/29
.........
.......
172.16.64.0/19 用于area2
172.16.64.0/24
172.16.64.0/30
172.16.64.4/30
........
172.16.65.0/24
172.16.65.0/29
172.16.65.8/29
........
.......
172.16.96.0/19 用于area3
172.16.96.0/24
172.16.96.0/30
172.16.96.4/30
..........
172.16.97.0/24
172.16.97.0/29
172.16.97.8/29
.........
.......
172.16.128.0/19 用于area4
172.16.128.0/24
172.16.128.0/30
172.16.128.4/30
........
172.16.129.0/24
172.16.129.0/29
172.16.129.8/29
.........
.......
172.16.160.0/19 用于rip
172.16.160.0/24
172.16.160.0/30
172.16.160.4/30
........
172.16.161.0/24
172.16.161.0/29
172.16.161.8/29
........
.......
172.16.192.0/19 预留
172.16.224.19 预留
三、配置IP地址
[r1]int GigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]ip address 172.16.33.1 29
[r1]int LoopBack 0
[r1-LoopBack0]ip address 172.16.34.1 24
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip address 172.16.33.2 29
[r2]int LoopBack 0
[r2-LoopBack0]ip address 172.16.35.1 24
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ip address 172.16.33.3 29
[r3]int LoopBack 0
[r3-LoopBack0]ip address 172.16.36.1 24
[r3]int Serial 4/0/0
[r3-Serial4/0/0]ip address 34.0.0.1 24
[r4]int s4/0/0
[r4-Serial4/0/0]ip address 34.0.0.2 24
[r4]int s4/0/1
[r4-Serial4/0/1]ip address 45.0.0.2 24
[r4]int s3/0/0
[r4-Serial3/0/0]ip address 46.0.0.2 24
[r4-Serial3/0/0]int g0/0/0
[r4-GigabitEthernet0/0/0]ip address 47.0.0.2 24
[r4]int LoopBack 0
[r4-LoopBack0]ip address 4.4.4.4 24
[r5]int s4/0/0
[r5-Serial4/0/0]ip address 45.0.0.1 24
[r5]int LoopBack 0
[r5-LoopBack0]ip address 172.16.2.1 24
[r6]int s4/0/0
[r6-Serial4/0/0]ip address 46.0.0.1 24
[r6]int LoopBack 0
[r6-LoopBack0]ip address 172.16.3.1 24
[r6]int GigabitEthernet 0/0/0
[r6-GigabitEthernet0/0/0]ip address 172.16.65.1 29
[r7]int g0/0/0
[r7-GigabitEthernet0/0/0]ip address 47.0.0.1 24
[r7]int g0/0/1
[r7-GigabitEthernet0/0/1]ip address 172.16.97.1 29
[r7]int LoopBack 0
[r7-LoopBack0]ip address 172.16.4.1 24
[r8]int g0/0/0
[r8-GigabitEthernet0/0/0]ip address 172.16.97.2 29
[r8]int g0/0/1
[r8-GigabitEthernet0/0/1]ip address 172.16.97.9 29
[r8]int LoopBack 0
[r8-LoopBack0]ip address 172.16.98.1 24
[r9]int g0/0/0
[r9-GigabitEthernet0/0/0]ip address 172.16.97.10 29
[r9]int g0/0/1
[r9-GigabitEthernet0/0/1]ip address 172.16.129.1 29
[r9]int LoopBack 0
[r9-LoopBack0]ip address 172.16.130.1 24
[r10]int g0/0/0
[r10-GigabitEthernet0/0/0]ip address 172.16.129.2 29
[r10]int LoopBack 0
[r10-LoopBack0]ip address 172.16.131.1 24
[r11]int g0/0/0
[r11-GigabitEthernet0/0/0]ip address 172.16.65.2 29
[r11]int g0/0/1
[r11-GigabitEthernet0/0/1]ip address 172.16.65.9 29
[r11]int LoopBack 0
[r11-LoopBack0]ip address 172.16.66.1 24
[r12]int g0/0/0
[r12-GigabitEthernet0/0/0]ip address 172.16.65.10 29
[r12]int LoopBack 0
[r12-LoopBack0]ip address 172.16.162.1 24
[r12]int LoopBack 1
[r12-LoopBack1]ip address 172.16.163.1 24
四、配置缺省使公网通畅
[r3]ip route-static 0.0.0.0 0 34.0.0.2
[r5]ip route-static 0.0.0.0 0 45.0.0.2
[r6]ip route-static 0.0.0.0 0 46.0.0.2
[r7]ip route-static 0.0.0.0 0 47.0.0.2
五、搭建MGRE环境
[r3]int Tunnel 0/0/0
[r3-Tunnel0/0/0]ip address 172.16.1.1 29
[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]int Tunnel 0/0/0
[r3-Tunnel0/0/0]ip address 172.16.1.1 29
[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
[r5]int Tunnel 0/0/0
[r5-Tunnel0/0/0]ip address 172.16.1.2 29
[r5-Tunnel0/0/0]tunnel-protocol gre p2mp
[r5-Tunnel0/0/0]source Serial 4/0/0
[r5-Tunnel0/0/0]nhrp network-id 100
[r5-Tunnel0/0/0]nhrp entry 172.16.1.1 34.0.0.1 register
[r6]int Tunnel 0/0/0
[r6-Tunnel0/0/0]ip address 172.16.1.3 29
[r6-Tunnel0/0/0]tunnel-protocol gre p2mp
[r6-Tunnel0/0/0]nhrp network-id 100
[r6-Tunnel0/0/0]source Serial 4/0/0
[r6-Tunnel0/0/0]nhrp entry 172.16.1.1 34.0.0.1 register
[r7]int Tunnel 0/0/0
[r7-Tunnel0/0/0]ip address 172.16.1.4 29
[r7-Tunnel0/0/0]tunnel-protocol gre p2mp
[r7-Tunnel0/0/0]nhrp network-id 100
[r7-Tunnel0/0/0]source GigabitEthernet 0/0/0
[r7-Tunnel0/0/0]nhrp entry 172.16.1.1 34.0.0.1 register
更改网络类型
[r3]int Tunnel 0/0/0
[r3-Tunnel0/0/0]ospf network-type p2mp
[r5]int Tunnel 0/0/0
[r5-Tunnel0/0/0]ospf network-type p2mp
[r6]int Tunnel 0/0/0
[r6-Tunnel0/0/0]ospf network-type p2mp
[r7]int Tunnel 0/0/0
[r7-Tunnel0/0/0]ospf network-type p2mp
六、配置OSPF和RIP
[r1]ospf 1 router-id 1.1.1.1
[r1-ospf-1]a 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
[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]a 1
[r2-ospf-1-area-0.0.0.1]net
[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]a 1
[r3-ospf-1-area-0.0.0.1]network 172.16.32.0 0.0.7.255
[r3-ospf-1-area-0.0.0.1]q
[r3-ospf-1]a 0
[r3-ospf-1-area-0.0.0.0]network 172.16.1.1 0.0.0.0
[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.0.0 0.0.255.255
[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.0.0 0.0.3.255
[r6-ospf-1-area-0.0.0.0]q
[r6-ospf-1]a 2
[r6-ospf-1-area-0.0.0.2]network 172.16.65.1 0.0.0.0
[r7]ospf 1 router-id 7.7.7.7
[r7-ospf-1]a 0
[r7-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.7.255
[r7-ospf-1-area-0.0.0.0]q
[r7-ospf-1]a 3
[r7-ospf-1-area-0.0.0.3]network 172.16.97.1 0.0.0.0
[r8]ospf 1 router-id 8.8.8.8
[r8-ospf-1]a 3
[r8-ospf-1-area-0.0.0.3]net
[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]a 3
[r9-ospf-1-area-0.0.0.3]network 172.16.97.10 0.0.0.0
[r9-ospf-1-area-0.0.0.3]q
[r9-ospf-1]q
[r9]ospf 2
[r9-ospf-2]a 4
[r9-ospf-2-area-0.0.0.4]network 172.16.128.0 0.0.3.255
[r10]ospf 1 router-id 10.10.10.10
[r10-ospf-1]a 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]a 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]a 2
[r12-ospf-1-area-0.0.0.2]network 172.16.65.10 0.0.0.0
[r12-ospf-1-area-0.0.0.2]q
[r12-ospf-1]q
[r12]rip
[r12-rip-1]v 2
[r12-rip-1]net
[r12-rip-1]network 172.16.0.0
将rip和area 4重发布到ospf中
[r9]ospf 1
[r9-ospf-1]import-route ospf 2
[r12]ospf 1
[r12-ospf-1]import-route rip 1
[r9-ospf-2]default-route-advertise
七、OSPF路由汇总
[r3]ospf 1
[r3-ospf-1]a 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]a 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]a 3
[r7-ospf-1-area-0.0.0.3]abr-summary 172.16.96.0 255.255.224.0
[r9]ospf 1
[r9-ospf-1]asbr-summary 172.16.128.0 255.255.224.0
[r12]ospf 1
[r12-ospf-1]asbr-summary 172.16.160.0 255.255.224.0
八、做特殊区域
1、area1的完全末梢区域
[r1]ospf 1
[r1-ospf-1]a 1
[r1-ospf-1-area-0.0.0.1]stub
[r2]ospf 1
[r2-ospf-1]a 1
[r2-ospf-1-area-0.0.0.1]stub
[r3]ospf 1
[r3-ospf-1]a 1
[r3-ospf-1-area-0.0.0.1]stub no-summary
2、area2完全的非完全末梢区域
[r6]ospf 1
[r6-ospf-1]ar 2
[r6-ospf-1-area-0.0.0.2]nssa no-summary
[r11]ospf 1
[r11-ospf-1]ar 2
[r11-ospf-1-area-0.0.0.2]nssa
[r12]ospf 1
[r12-ospf-1]ar 2
[r12-ospf-1-area-0.0.0.2]nssa
3、area3完全的非完全末梢区域
[r7]ospf 1
[r7-ospf-1]a 3
[r7-ospf-1-area-0.0.0.3]nssa no-summary
[r8]ospf 1
[r8-ospf-1]a 3
[r8-ospf-1-area-0.0.0.3]nssa
[r9]ospf 1
[r9-ospf-1]a 3
[r9-ospf-1-area-0.0.0.3]nssa
九、配置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 Serial 4/0/0
[r3-Serial4/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 Serial 4/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 GigabitEthernet 0/0/0
[r7-GigabitEthernet0/0/0]nat outbound 2000
十、将网络类型接口改为p2p
[r7]int g0/0/1
[r7-GigabitEthernet0/0/1]ospf network-type p2p
[r8]int g0/0/0
[r8-GigabitEthernet0/0/0]ospf network-type p2p
[r8]int g0/0/1
[r8-GigabitEthernet0/0/1]ospf network-type p2p
[r9]int g0/0/0
[r9-GigabitEthernet0/0/0]ospf network-type p2p
[r9]int g0/0/1
[r9-GigabitEthernet0/0/1]ospf network-type p2p
[r10]int g0/0/0
[r10-GigabitEthernet0/0/0]ospf network-type p2p
[r6]int g0/0/0
[r6-GigabitEthernet0/0/0]ospf network-type p2p
[r11]int g0/0/0
[r11-GigabitEthernet0/0/0]ospf network-type p2p
[r11]int g0/0/1
[r11-GigabitEthernet0/0/1]ospf network-type p2p
[r12]int g0/0/0
[r12-GigabitEthernet0/0/0]ospf network-type p2p