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.全网可达
二.实验拓扑
三.实验步骤
area 0
(1)总地址:172.16.0.0/19 用户地址: 172.16.0.0/24–P2P 172.16.1.0/24–MA 172.16.2.0/24–R4(环回) 172.16.3.0/24–R5(环回) 172.16.5.0/24–R7(环回) 172.16.6.0/24–隧道
area 1
(2)总地址:172.16.32.0/19 用户地址: 172.16.32.0/24–P2P 172.16.33.0/24–MA 172.16.34.0/24–R1(环回) 172.16.35.0/24–R2(环回) 172.16.36.0/24–R3(环回)
area 2
(3)总地址:172.16.64.0/19 用户地址: 172.16.64.0/24–P2P 172.16.65.0/24–MA 172.16.65.0/30 172.16.65.4/30 172.16.66.0/24–R11(环回)
area 3
(4)总地址:172.16.96.0/19 用户地址: 172.16.96.0/24–P2P 172.16.97.0/24–MA 172.16.97.0/30 172.16.97.4/30 172.16.98.0/24–R8(环回)
area 3
(5)总地址:172.16.96.0/19 用户地址: 172.16.96.0/24–P2P 172.16.97.0/24–MA 172.16.97.0/30 172.16.97.4/30 172.16.98.0/24–R8(环回)
area 4
(6)总地址:172.16.128.0/19 用户地址: 172.16.128.0/24–P2P 172.16.129.0/24–MA 172.16.129.0/30 172.16.130.0/24–R9(环回) 172.16.131.0/24–R10(环回)
1.配置ip地址
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 172.16.33.1 24
[R1-GigabitEthernet0/0/0]int l0
[R1-LoopBack0]ip add 172.16.34.1 24
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 172.16.33.2 24
[R2-LoopBack0]ip add 172.16.35.2 24
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 172.16.33.3 24
[R3-GigabitEthernet0/0/0]int l0
[R3-LoopBack0]ip add 172.16.36.3 24
[R3-LoopBack0]quit
[R3]dis ip int b
[R3]int s4/0/0
[R3-Serial4/0/0]ip add 43.0.0.3 24
[R3-Serial4/0/0]quit
[R3]dis ip int b
[R5]int s 4/0/0
[R5-Serial4/0/0]ip add 45.0.0.5 24
[R5-Serial4/0/0]quit
[R5]int l0
[R5-LoopBack0]ip add 172.16.3.5 24
[R5-LoopBack0]quit
[R5]dis ip int b
[R6]int s 4/0/0
[R6-Serial4/0/0]ip add 46.0.0.6 24
[R6-Serial4/0/0]quit
[R6]int l0
[R6-LoopBack0]ip add 172.16.4.6 24
[R6-LoopBack0]quit
[R6]dis ip int b
[R7]int g0/0/0
[R7-GigabitEthernet0/0/0]ip add 47.0.0.7 24
[R7-GigabitEthernet0/0/0]int l0
[R7-LoopBack0]ip add 172.16.5.7 24
[R7-LoopBack0]quit
[R7]dis ip int b
[R4]int s 4/0/0
[R4-Serial4/0/0]ip add 43.0.0.4 24
[R4-Serial4/0/0]int s 4/0/1
[R4-Serial4/0/1]ip add 45.0.0.4 24
[R4-Serial4/0/1]int s 3/0/0
[R4-Serial3/0/0]ip add 46.0.0.4 24
[R4-Serial3/0/0]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 47.0.0.4 24
[R4-GigabitEthernet0/0/0]int l0
[R4-LoopBack0]ip add 172.16.2.4 24
[R4-LoopBack0]quit
[R4]dis ip int b
[R6]int g0/0/0
[R6-GigabitEthernet0/0/0]ip add 172.16.65.1 30
[R6-GigabitEthernet0/0/0]quit
[R6]dis ip int b
[R11]int g0/0/0
[R11-GigabitEthernet0/0/0]ip add 172.16.65.2 30
[R11-GigabitEthernet0/0/0]int g0/0/1
[R11-GigabitEthernet0/0/1]ip add 172.16.65.5 30
[R11-GigabitEthernet0/0/1]int l0
[R11-LoopBack0]ip add 172.16.66.11 24
[R11-LoopBack0]quit
[R11]dis ip int b
[R12]int g0/0/0
[R12-GigabitEthernet0/0/0]ip add 172.16.65.6 30
[R12-GigabitEthernet0/0/0]int l0
[R12-LoopBack0]ip add 172.16.160.12 24
[R12-LoopBack0]int l1
[R12-LoopBack1]ip add 172.16.161.12 24
[R12-LoopBack1]quit
[R12]dis ip int b
[R7]int g0/0/1
[R7-GigabitEthernet0/0/1]ip add 172.16.97.1 30
[R7-GigabitEthernet0/0/1]quit
[R7]dis ip int b
[R8]int g0/0/0
[R8-GigabitEthernet0/0/0]ip add 172.16.97.2 30
[R8-GigabitEthernet0/0/0]int g0/0/1
[R8-GigabitEthernet0/0/1]ip add 172.16.97.5 30
[R8-GigabitEthernet0/0/1]int l0
[R8-LoopBack0]ip add 172.16.98.8 24
[R8-LoopBack0]quit
[R8]dis ip int b
[R9]int g0/0/0
[R9-GigabitEthernet0/0/0]ip add 172.16.97.6 30
[R9-GigabitEthernet0/0/0]quit
[R9]dis ip int b
[R9]int g0/0/1
[R9-GigabitEthernet0/0/1]ip add 172.16.129.1 30
[R9-GigabitEthernet0/0/1]int l0
[R9-LoopBack0]ip add 172.16.130.9 24
[R9-LoopBack0]quit
[R9]dis ip int b
[R10]int g0/0/0
[R10-GigabitEthernet0/0/0]ip add 172.16.129.2 30
[R10-GigabitEthernet0/0/0]int l0
[R10-LoopBack0]ip add 172.16.131.10 24
[R10-LoopBack0]quit
[R10]dis ip int b
2.配置OSPF协议,并进行宣告
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 1
[R1-ospf-1-area-0.0.0.1]network 172.16.33.0 0.0.0.255
[R1-ospf-1-area-0.0.0.1]network 172.16.34.0 0.0.0.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.33.0 0.0.0.255
[R2-ospf-1-area-0.0.0.1]network 172.16.35.0 0.0.0.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.33.0 0.0.0.255
[R3-ospf-1-area-0.0.0.1]network 172.16.36.0 0.0.0.255
[R3-ospf-1-area-0.0.0.1]quit
[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.3.0 0.0.0.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.4.0 0.0.0.255
[R6-ospf-1-area-0.0.0.0]quit
[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.5.0 0.0.0.255
[R7-ospf-1-area-0.0.0.0]quit
[R6]ospf 1 router-id 6.6.6.6
[R6-ospf-1]area 2
[R6-ospf-1-area-0.0.0.2]network 172.16.65.1 0.0.0.0
[R6-ospf-1-area-0.0.0.2]quit
[R6-ospf-1]quit
[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.65.5 0.0.0.0
[R11-ospf-1-area-0.0.0.2]network 172.16.65.2 0.0.0.0
[R11-ospf-1-area-0.0.0.2]network 172.16.66.0 0.0.0.255
[R11-ospf-1-area-0.0.0.2]quit
[R11-ospf-1]quit
[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.65.6 0.0.0.0
[R12-ospf-1-area-0.0.0.2]quit
[R12-ospf-1]quit
[R7]ospf 1 router-id 7.7.7.7
[R7-ospf-1]area 3
[R7-ospf-1-area-0.0.0.3]network 172.16.97.1 0.0.0.0
[R7-ospf-1-area-0.0.0.3]quit
[R7-ospf-1]quit
[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.97.2 0.0.0.0
[R8-ospf-1-area-0.0.0.3]network 172.16.97.5 0.0.0.0
[R8-ospf-1-area-0.0.0.3]network 172.16.98.0 0.0.0.255
[R8-ospf-1-area-0.0.0.3]quit
[R8-ospf-1]quit
[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.6 0.0.0.0
[R9-ospf-1-area-0.0.0.3]quit
[R9-ospf-1]quit
R9]ospf 2 router-id 9.9.9.9
[R9-ospf-2]area 4
[R9-ospf-2-area-0.0.0.4]network 172.16.129.1 0.0.0.0
[R9-ospf-2-area-0.0.0.4]network 172.16.130.0 0.0.0.255
[R9-ospf-2-area-0.0.0.4]quit
[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.129.2 0.0.0.0
[R10-ospf-2-area-0.0.0.4]network 172.16.131.0 0.0.0.255
[R10-ospf-2-area-0.0.0.4]quit
3.解决ospf区域划分不合理的情况
[R9]ospf 1
[R9-ospf-1]import-route ospf 2
[R9-ospf-1]quit
[R9]ospf 2
[R9-ospf-2]import-route ospf 1
4.配置rip协议
[R12]rip 1
[R12-rip-1]v 2
[R12-rip-1]network 172.16.0.0
[R12]ospf 1
[R12-ospf-1]import-route rip
5.公网通
[R3]ip route-static 0.0.0.0 0 43.0.0.4
[R5]ip route-static 0.0.0.0 0 45.0.0.4
[R6]ip route-static 0.0.0.0 0 46.0.0.4
[R7]ip route-static 0.0.0.0 0 47.0.0.4
6.搭建MGRE隧道,R3为中心站点(使所有私网都互通)
[R3]int tu 0/0/0
[R3-Tunnel0/0/0]ip add 172.16.6.3 24
[R3-Tunnel0/0/0]tunnel-protocol gre p2mp
[R3-Tunnel0/0/0]source s4/0/0
[R5]int tu 0/0/0
[R5-Tunnel0/0/0]ip add 172.16.6.5 24
[R5-Tunnel0/0/0]tunnel-protocol gre p2mp
[R5-Tunnel0/0/0]source s4/0/0
[R6]int tu0/0/0
[R6-Tunnel0/0/0]ip add 172.16.6.6 24
[R6-Tunnel0/0/0]tunnel-protocol gre p2mp
[R6-Tunnel0/0/0]source s4/0/0
[R7]int tu0/0/0
[R7-Tunnel0/0/0]ip add 172.16.6.7 24
[R7-Tunnel0/0/0]tunnel-protocol gre p2mp
[R7-Tunnel0/0/0]source g0/0/0
R3]int tu 0/0/0
[R3-Tunnel0/0/0]nhrp network-id 100
[R3-Tunnel0/0/0]nhrp entry multicast dynamic
[R5]int tu0/0/0
[R5-Tunnel0/0/0]nhrp network-id 100
[R5-Tunnel0/0/0]nhrp entry 172.16.6.3 43.0.0.3 register
[R6]int tu0/0/0
[R6-Tunnel0/0/0]nhrp network-id 100
[R6-Tunnel0/0/0]nhrp entry 172.16.6.3 43.0.0.3 register
进入ospf协议视图下对隧道口进行宣告;
[R3]ospf 1
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]net
[R3-ospf-1-area-0.0.0.0]network 172.16.6.0 0.0.0.255
[R5]ospf 1
[R5-ospf-1]area 0
[R5-ospf-1-area-0.0.0.0]network 172.16.6.0 0.0.0.255
[R6]ospf 1
[R6-ospf-1]area 0
[R6-ospf-1-area-0.0.0.0]network 172.16.6.0 0.0.0.255
[R7]ospf 1
[R7-ospf-1]area 0
[R7-ospf-1-area-0.0.0.0]network 172.16.6.0 0.0.0.255
修改网络类型
[R3]int tu0/0/0
[R3-Tunnel0/0/0]ospf network-type broadcast
[R5]int tu0/0/0
[R5-Tunnel0/0/0]ospf network-type broadcast
[R6]int Tunnel 0/0/0
[R6-Tunnel0/0/0]ospf network-type broadcast
[R7]int tu0/0/0
[R7-Tunnel0/0/0]ospf network-type broadcast
修改选举DR/BDR的权限
R5]int tu0/0/0
[R5-Tunnel0/0/0]ospf dr-priority 0
[R6]int tu0/0/0
[R6-Tunnel0/0/0]ospf dr-priority 0
[R7]int tu0/0/0
[R7-Tunnel0/0/0]ospf dr-priority 0
查看邻居总表和路由表
7.所有设备均可访问R4的环回
R3]acl 2000
[R3-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[R3-acl-basic-2000]quit
[R3]int s 4/0/0
[R3-Serial4/0/0]nat outbound 2000
[R5]acl 2000
[R5-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[R5-acl-basic-2000]quit
[R5]int s 4/0/0
[R5-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]quit
[R6]int s 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]quit
[R7]int g0/0/0
[R7-GigabitEthernet0/0/0]nat outbound 2000
8.减少LSA的更新量: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
R12]ospf 1
[R12-ospf-1]asbr-summary 172.16.160.0 255.255.224.0
[R9]ospf 1
[R9-ospf-1]asbr
[R9-ospf-1]asbr-summary 172.16.129.0 255.255.224.0
8.减少LSA的更新量
[R3]ospf 1
[R3-ospf-1]area 1
[R3-ospf-1-area-0.0.0.1]stub no-summary
[R1]ospf 1
[R1-ospf-1]area 1
[R1-ospf-1-area-0.0.0.1]stub no-summary
[R2]ospf 1
[R2-ospf-1]area 1
[R2-ospf-1-area-0.0.0.1]stub no-summary
[R6]ospf 1
[R6-ospf-1]area 2
[R6-ospf-1-area-0.0.0.2]nssa no-summary
[R11]ospf 1
[R11-ospf-1]area 2
[R11-ospf-1-area-0.0.0.2]nssa no-summary
[R12]ospf 1
[R12-ospf-1]area 2
[R12-ospf-1-area-0.0.0.2]nssa no-summary
[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 no-summary
[R9]ospf 1
[R9-ospf-1]area 3
[R9-ospf-1-area-0.0.0.3]nssa no-summary
各区域下的路由器ping一下区域0中R4的环回,看是否已经全网通:
区域4下的路由器R10ping不通其他区域——原因:其他区域设置特殊区域后都下发了3类缺省,导致区域4学习不到区域1和区域2的路由信息,只有区域3的路由信息(解决办法:在R10上配置指向R9的静态缺省;也可以在R9上下发5类缺省)
[R9]ospf 1
[R9-ospf-1]default-route-advertise
9.加快收敛:进入到接口下更改hello时间
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ospf timer hello 5
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ospf timer hello 5
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ospf timer hello 5
[R3]int s4/0/0
[R3-Serial4/0/0]ospf timer hello 5
[R5]int s 4/0/0
[R5-Serial4/0/0]ospf timer hello 5
[R6]int s 4/0/0
[R6-Serial4/0/0]ospf timer hello 5
[R7]int g0/0/0
[R7-GigabitEthernet0/0/0]ospf timer hello 5
[R6]int g0/0/0
[R6-GigabitEthernet0/0/0]ospf timer hello 5
[R11]int g0/0/0
[R11-GigabitEthernet0/0/0]ospf timer hello 5
[R11]int g0/0/1
[R11-GigabitEthernet0/0/1]ospf timer hello 5
[R12]int g0/0/0
[R12-GigabitEthernet0/0/0]ospf timer hello 5
[R7]int g0/0/1
[R7-GigabitEthernet0/0/1]ospf timer hello 5
[R8]int g0/0/0
[R8-GigabitEthernet0/0/0]ospf timer hello 5
[R8]int g0/0/1
[R8-GigabitEthernet0/0/1]ospf timer hello 5
[R9]int g0/0/0
[R9-GigabitEthernet0/0/0]ospf timer hello 5
[R9]int g0/0/1
[R9-GigabitEthernet0/0/1]ospf timer hello 5
[R10]int g0/0/0
[R10-GigabitEthernet0/0/0]ospf timer hello 5
R10分别ping一下其他区域,加快收敛不影响全网通
10.保障更新安全
R1]ospf 1
[R1-ospf-1]area 1
[R1-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher 123456
[R2]ospf 1
[R2-ospf-1]area 1
[R2-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher 123456
[R3]ospf 1
[R3-ospf-1]area 1
[R3-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher 123456
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]authentication-mode md5 1 cipher 123456
[R5]ospf 1
[R5-ospf-1]area 0
[R5-ospf-1-area-0.0.0.0]au
[R5-ospf-1-area-0.0.0.0]authentication-mode md5 1 cipher 123456
[R5-ospf-1]area 0
[R5-ospf-1-area-0.0.0.0]authentication-mode md5 1 cipher 123456
[R6]ospf 1
[R6-ospf-1]area 0
[R6-ospf-1-area-0.0.0.0]authentication-mode md5 1 cipher 123456
[R7]ospf 1
[R7-ospf-1]area 0
[R7-ospf-1-area-0.0.0.0]authentication-mode md5 1 cipher 123456
[R6-ospf-1]are 2
[R6-ospf-1-area-0.0.0.2]authentication-mode md5 1 cipher 123456
[R11]ospf 1
[R11-ospf-1]area 2
[R11-ospf-1-area-0.0.0.2]authentication-mode md5 1 cipher 123456
[R12]ospf 1
[R12-ospf-1]area 2
[R12-ospf-1-area-0.0.0.2]authentication-mode md5 1 cipher 123456
[R7]ospf 1
[R7-ospf-1]area 0
[R7-ospf-1]area 3
[R7-ospf-1-area-0.0.0.3]authentication-mode md5 1 cipher 123456
[R8]ospf 1
[R8-ospf-1]area 3
[R8-ospf-1-area-0.0.0.3]authentication-mode md5 1 cipher 123456
[R9]ospf 1
[R9-ospf-1]area 3
[R9-ospf-1-area-0.0.0.3]authentication-mode md5 1 cipher 123456
全网通: