步骤一:子网划分
首先先进行子网划分:要求给出的总网段是172.16.0.0 16 ;我们要划分6个子网段给区域0、1、2、3、4和rip;借3位主机位得到8个子网段:
000、001、010、011、100、101、110、111
0 32 64 96 128 160 196 228
选择前6个分别为区域0、1、2、3、4 和rip的网段即:
area 0 172.16.0.0/19
area1 172.16.32.0/19
area2 172.16.64.0/19
area3 172.16.96.0/19
area4 172.16.128.0/19
rip 172.16.160.0/19
再对各区域进行细致划分,具体如上图
步骤二:IP配置
[r1]interface g 0/0/0
[r1-GigabitEthernet0/0/0]ip address 172.16.33.1 29
[r1-GigabitEthernet0/0/0]interface LoopBack 0
[r1-LoopBack0]ip address 172.16.34.1 24
[r2]interface g 0/0/0
[r2-GigabitEthernet0/0/0]ip address 172.16.33.2 29
[r2-GigabitEthernet0/0/0]interface LoopBack 0
[r2-LoopBack0]ip address 172.16.35.1 24
[r3]interface GigabitEthernet 0/0/0
[r3-GigabitEthernet0/0/0]ip address 172.16.33.3 29
[r3-GigabitEthernet0/0/0]interface LoopBack 0
[r3-LoopBack0]ip address 172.16.36.1 24
[r3-LoopBack0]interface Serial 4/0/0
[r3-Serial4/0/0]ip address 34.0.0.1 24
[ISP]interface Serial 4/0/0
[ISP-Serial4/0/0]ip address 34.0.0.2 24
[ISP-Serial4/0/0]interface Serial 4/0/1
[ISP-Serial4/0/1]ip address 45.0.0.2 24
[ISP-Serial4/0/1]interface Serial 3/0/0
[ISP-Serial3/0/0]ip address 46.0.0.2 24
[ISP-Serial3/0/0]interface g 0/0/0
[ISP-GigabitEthernet0/0/0]ip address 47.0.0.2 24
[ISP-GigabitEthernet0/0/0]interface LoopBack 0
[ISP-LoopBack0]ip address 4.4.4.4 24
[r5]interface Serial 4/0/0
[r5-Serial4/0/0]ip address 45.0.0.1 24
[r5-Serial4/0/0]interface LoopBack 0
[r5-LoopBack0]ip address 172.16.2.1 24
[r6]interface g 0/0/0
[r6-GigabitEthernet0/0/0]ip address 172.16.65.1 29
[r6-GigabitEthernet0/0/0]interface Serial 4/0/0
[r6-Serial4/0/0]ip address 46.0.0.1 24
[r6-Serial4/0/0]interface LoopBack 0
[r6-LoopBack0]ip address 172.16.3.1 24
[r7]interface g 0/0/0
[r7-GigabitEthernet0/0/0]ip address 47.0.0.1 24
[r7-GigabitEthernet0/0/0]interface g 0/0/1
[r7-GigabitEthernet0/0/1]ip address 172.16.97.1 29
[r7-GigabitEthernet0/0/1]interface LoopBack 0
[r7-LoopBack0]ip address 172.16.4.1 24
[r8]interface g 0/0/0
[r8-GigabitEthernet0/0/0]ip address 172.16.97.2 29
[r8-GigabitEthernet0/0/0]interface g 0/0/1
[r8-GigabitEthernet0/0/1]ip address 172.16.97.9 29
[r8-GigabitEthernet0/0/1]interface LoopBack 0
[r8-LoopBack0]ip address 172.16.98.1 24
[r9]interface g 0/0/0
[r9-GigabitEthernet0/0/0]ip address 172.16.97.10 29
[r9-GigabitEthernet0/0/0]interface g 0/0/1
[r9-GigabitEthernet0/0/1]ip address 172.16.129.1 29
[r9-GigabitEthernet0/0/1]interface LoopBack 0
[r9-LoopBack0]ip address 172.16.130.1 24
[r10]interface g 0/0/0
[r10-GigabitEthernet0/0/0]ip address 172.16.129.2 29
[r10-GigabitEthernet0/0/0]interface LoopBack 0
[r10-LoopBack0]ip address 172.16.131.1 24
[r11]interface g 0/0/0
[r11-GigabitEthernet0/0/0]ip address 172.16.65.2 29
[r11-GigabitEthernet0/0/0]interface g 0/0/1
[r11-GigabitEthernet0/0/1]ip address 172.16.65.9 29
[r11-GigabitEthernet0/0/1]interface LoopBack 0
[r11-LoopBack0]ip address 172.16.66.1 24
[r12]interface g 0/0/0
[r12-GigabitEthernet0/0/0]ip address 172.16.65.10 29
[r12-GigabitEthernet0/0/0]
[r12-GigabitEthernet0/0/0]interface LoopBack 0
[r12-LoopBack0]ip address 172.16.162.1 24
[r12-LoopBack0]interface 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
ping一下公网,发现ping的到;此时公网通
步骤四:创建MGRE环境(r3、r5、r6、r7之间,r3是中心)
[r3]interface Tunnel 0/0/0 //创建隧道接口
[r3-Tunnel0/0/0]ip address 172.16.1.1 29 //配置隧道接口ip
[r3-Tunnel0/0/0]tunnel-protocol gre p2mp //定义封装协议
[r3-Tunnel0/0/0]source 34.0.0.1 //定义封装的源ip
[r3-Tunnel0/0/0]nhrp network-id 100 //创建NHRP于
[r3-Tunnel0/0/0]nhrp entry multicast dynamic //宣告中心
[r5]interface 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]interface 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]interface 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 g 0/0/0
[r7-Tunnel0/0/0]nhrp entry 172.16.1.1 34.0.0.1 register
查看r3的邻居表,中心有其他邻居的全部信息
将MGRE环境下的隧道接口的网络类型改为p2mp类型 (转换为OSPF环境)
[r3-Tunnel0/0/0]ospf network-type p2mp
[r5-Tunnel0/0/0]ospf network-type p2mp
[r6-Tunnel0/0/0]ospf network-type p2mp
[r7-Tunnel0/0/0]ospf network-type p2mp
步骤五:配置OSPF和RIP
[r1]ospf 1 router-id 1.1.1.1 //启动ospf进程
[r1-ospf-1]area 1 //创建区域
[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]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 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]area 0
[r3-ospf-1-area-0.0.0.0]network 172.16.1.1 0.0.0.0
[r5]ospf 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 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.65.1 0.0.0.0
[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.7.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.97.1 0.0.0.0
[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.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]area 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]area 4
[r10-ospf-1-area-0.0.0.4]network172.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]ospf 1 router-id 12.12.12.12
[r12-ospf-1]area 2
[r12-ospf-1-area-0.0.0.2]ne
[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]version 2
[r12-rip-1]network 172.16.0.0
将rip和area4重发布到ospf中
[r9]ospf 1
[r9-ospf-1]import-route ospf 2 //-如果想要A协议获取到B协议的路由信息,
进入A协议的进程中import-route 引入B协议的路由即可
[r12]ospf 1
[r12-ospf-1]import-route rip 1
[r9-ospf-2]default-route-advertise //五类缺省路由
步骤五:OSPF的路由汇总
[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 //网段汇总的结果(真实掩码)
[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
[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
//ASBR设备
[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
步骤六:给area1、2、3做特殊区域
[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
查看area1的lsdb表
查看路由表
area2的完全的非完全末梢区域
[r6]ospf 1
[r6-ospf-1]area 2
[r6-ospf-1-area-0.0.0.2]nssa no-summary //ABR设备
[r11]ospf 1
[r11-ospf-1]area 2
[r11-ospf-1-area-0.0.0.2]nssa //ASBR设备
[r12]ospf 1
[r12-ospf-1]area 2
[r12-ospf-1-area-0.0.0.2]nssa //ASBR设备
area3的完全的非完全末梢区域
[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
步骤七:配置NULL 0接口防环(区域内的通过SPF算法得出,区域间要进行说明
[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
步骤七:配置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]interface 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]interface 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]interface g 0/0/0
[r7-GigabitEthernet0/0/0]nat outbound 2000
步骤八:加快收敛
[r3]interface Tunnel 0/0/0
[r3-Tunnel0/0/0]ospf timer hello 10
[r5]interface Tunnel 0/0/0
[r5-Tunnel0/0/0]ospf timer hello 10
[r6]interface Tunnel 0/0/0
[r6-Tunnel0/0/0]ospf timer hello 10
[r7]interface Tunnel 0/0/0
[r7-Tunnel0/0/0]ospf timer hello 10
将所有直连的MA接口网络类型改为p2p
[r6]interface g 0/0/0
[r6-GigabitEthernet0/0/0]ospf ne
[r6-GigabitEthernet0/0/0]ospf network-type p2p
[r7]interface g 0/0/1
[r7-GigabitEthernet0/0/1]ospf network-type p2p
[r8]interface g 0/0/0
[r8-GigabitEthernet0/0/0]ospf network-type p2p
[r8]interface g 0/0/1
[r8-GigabitEthernet0/0/1]ospf network-type p2p
[r9]interface g 0/0/0
[r9-GigabitEthernet0/0/0]ospf network-type p2p
[r9]interface g 0/0/1
[r9-GigabitEthernet0/0/1]ospf network-type p2p
[r10]interface g 0/0/0
[r10-GigabitEthernet0/0/0]ospf ne
[r10-GigabitEthernet0/0/0]ospf network-type p2p
[r11]interface g 0/0/0
[r11-GigabitEthernet0/0/0]ospf network-type p2p
[r11]interface g 0/0/1
[r11-GigabitEthernet0/0/1]ospf network-type p2p
[r12]interface g 0/0/0
[r12-GigabitEthernet0/0/0]ospf ne
[r12-GigabitEthernet0/0/0]ospf network-type p2p
步骤九:OSPF认证
[r1-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher 123456
[r2-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher 123456
[r3-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher 123456
[r3-ospf-1-area-0.0.0.0]authentication-mode md5 1 cipher 123456
[r5-ospf-1-area-0.0.0.0]authentication-mode md5 1 cipher 123456
[r6-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher 123456
[r6-ospf-1-area-0.0.0.2]authentication-mode md5 1 cipher 123456
[r7-ospf-1-area-0.0.0.0]authentication-mode md5 1 cipher 123456
[r7-ospf-1-area-0.0.0.3]authentication-mode md5 1 cipher 123456
[r8-ospf-1-area-0.0.0.3]authentication-mode md5 1 cipher 123456
[r9-ospf-1-area-0.0.0.3]authentication-mode md5 1 cipher 123456
[r9-ospf-2-area-0.0.0.4]authentication-mode md5 1 cipher 123456
[r10-ospf-1-area-0.0.0.4]authentication-mode md5 1 cipher 123456
[r11-ospf-1-area-0.0.0.2]authentication-mode md5 1 cipher 123456
[r12-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 123456