OSPF综合实验(超详细易懂)(HCIP)

发布于:2024-05-09 ⋅ 阅读:(47) ⋅ 点赞:(0)

1、拓扑信息
2、需求分析
3、IP规划
4、配置
5、测试

1、拓扑信息


2、需求分析

  1. R4为ISP,其上只能配置I地址;                                                                                                        R4与其他所有直连设备间均使用公有IP
    1. 公网中使用的是点到点链路,因为比以太网链路稳定安全(只有两人)
  2. 5/6/7为MGRE环境,R3-RR3为中心站点;
    1. 只能使用非shortcut方式(因为如果shortcut方式,无法在R3上汇总除直连区域学到的路由信息,例:区域2)
  3. 整个OSPF环境IP基于172.16.0.0/16划分;
  4. 所有设备均可访问R4的环回;(需要做NAT)
  5. 减少LSA的更新量,加快收敛,保障更新安全;
    1. (OSPF优化:特殊区域)
    2. 减少Hello时间与死亡时间,网络接口P2P/P2MP
    3. 做认证
  6. 全网可达


3、IP规划

172.16.0.0/16

先分成2个网段(OSPF + RIP),借1位

        172.16.0.0/17         ---OSPF

        再按区域划分(5个区域),借3位

                172.16.0.0/20        ---Area 0

                三个环回 + MGRE = 4个网段,但一般网络只有200主机左右,所以直接规划到/24

                        172.16.0.0/24        ---MGRE

                        172.16.0.0/24        ---R5环回

                        172.16.0.0/24        ---R6环回

                        172.16.0.0/24        ---R7环回

                        ...

                        172.16.15.0/24    ---保留备用

                172.16.16.0/20      ---Area 1

                三个环回 + 一个骨干 = 4个网段,但还是直接规划到/24

                        172.16.16.0/24        ---Area 1骨干

                        需要3个IP,所以到/29

                                172.16.16.0/29        ---不能用

                                172.16.16.1/29        ---R1接口

                                172.16.16.2/29        ---R2接口

                                172.16.16.3/29        ---R3接口

                                172.16.16.4/29        ---保留备用

                                172.16.16.5/29        ---保留备用

                                172.16.16.6/29        ---保留备用

                                172.16.16.7/29        ---不能用

                        172.16.17.0/24        ---R1环回

                        172.16.18.0/24        ---R2环回

                        172.16.19.0/24        ---R3环回

                        ...

                        172.16.31.0/24    ---保留备用

                172.16.32.0/20      ---Area 2

                1个环回+2个骨干

                        172.16.32.0/24        ---R11环回

                        172.16.33.0/30        ---R6-R11

                        172.16.33.4/30        ---R11-R12

                172.16.48.0/20      ---Area 3

                1个环回+2个骨干

                        172.16.48.0/24        ---R8环回

                        172.16.49.0/30        ---R7-R8

                        172.16.49.4/30        ---R8-R9

                172.16.64.0/20      ---Area 4

                2个环回+1个骨干

                        172.16.64.0/24        ---R9环回

                        172.16.65.0/24        ---R10环回

                        172.16.66.0/30        ---R9-R10                  

                172.16.80.0/20      ---保留备用

                172.16.96.0/20      ---保留备用

                172.16.112.0/20    ---保留备用

        172.16.128.0/17     ---RIP

        2个环回

                172.16.128.0/18

                172.16.192.0/18


4、配置

配置IP和环回

R1配置

<Huawei>sys
[Huawei]sys r1
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 172.16.16.1 29
[r1-GigabitEthernet0/0/0]int l 0
[r1-LoopBack0]ip add 172.16.17.1 24

R2配置

<Huawei>sys
[Huawei]sys r2
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 172.16.16.2 29
[r2-GigabitEthernet0/0/0]int l 0
[r2-LoopBack0]ip add 172.16.18.1 24

R3配置

<Huawei>sys
[Huawei]sys r3
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add 172.16.16.3 29
[r3-GigabitEthernet0/0/0]int l 0
[r3-LoopBack0]ip add 172.16.19.1 24

[r3-LoopBack0]int s4/0/0
[r3-Serial4/0/0]ip add 34.0.0.3 24

R4配置

<Huawei>sys
[Huawei]sys r4

[r4]int g0/0/0
[r4-GigabitEthernet0/0/0]ip add 47.0.0.4 24
[r4-GigabitEthernet0/0/0]int s4/0/0
[r4-Serial4/0/0]ip add 34.0.0.4 24
[r4-Serial4/0/0]int s4/0/1
[r4-Serial4/0/1]ip add 45.0.0.4 24
[r4-Serial4/0/1]int s3/0/0
[r4-Serial3/0/0]ip add 46.0.0.4 24
[r4-Serial3/0/0]int l 0
[r4-LoopBack0]ip add 4.4.4.4 32

R5配置

<Huawei>sys
[Huawei]sys r5

[r5]int s4/0/0
[r5-Serial4/0/0]ip add 45.0.0.5 24
[r5-Serial4/0/0]int l 0
[r5-LoopBack0]ip add 172.16.1.1 24

R6配置

<Huawei>sys
[Huawei]sys r6
[r6]int s4/0/0
[r6-Serial4/0/0]ip add 46.0.0.6 24
[r6-Serial4/0/0]int g0/0/0
[r6-GigabitEthernet0/0/0]ip add 172.16.33.1 30
[r6-GigabitEthernet0/0/0]int l 0
[r6-LoopBack0]ip add 172.16.2.1 24

R7配置

<Huawei>sys
[Huawei]sys r7

[r7]int g0/0/0
[r7-GigabitEthernet0/0/0]ip add 47.0.0.7 24
[r7-GigabitEthernet0/0/0]int l 0
[r7-LoopBack0]ip add 172.16.3.1 24
[r7-LoopBack0]int g0/0/1
[r7-GigabitEthernet0/0/1]ip add 172.16.49.1 30

R8配置

<Huawei>sys
[Huawei]sys r8

[r8]int g0/0/0
[r8-GigabitEthernet0/0/0]ip add 172.16.49.2 30
[r8-GigabitEthernet0/0/0]int g0/0/1
[r8-GigabitEthernet0/0/1]ip add 172.16.49.5 30
[r8-GigabitEthernet0/0/1]int l 0
[r8-LoopBack0]ip add 172.16.48.1 24

R9配置

<Huawei>sys
[Huawei]sys r9

[r9]int g0/0/0
[r9-GigabitEthernet0/0/0]ip add 172.16.49.6 30
[r9-GigabitEthernet0/0/0]int l 0
[r9-LoopBack0]ip add 172.16.64.1 24
[r9-LoopBack0]int g0/0/1
[r9-GigabitEthernet0/0/1]ip add 172.16.66.1 30

R10配置

<Huawei>sys
[Huawei]sys r10

[r10]int g0/0/0
[r10-GigabitEthernet0/0/0]ip add 172.16.66.2 30
[r10-GigabitEthernet0/0/0]int l 0
[r10-LoopBack0]ip add 172.16.65.1 24

R11配置

<Huawei>sys
[Huawei]sys r11

[r11]int g0/0/0
[r11-GigabitEthernet0/0/0]ip add 172.16.33.2 30
[r11-GigabitEthernet0/0/0]int g0/0/1
[r11-GigabitEthernet0/0/1]ip add 172.16.33.5 30
[r11-GigabitEthernet0/0/1]int l 0
[r11-LoopBack0]ip add 172.16.32.1 24

R12配置

<Huawei>sys
[Huawei]sys r12

[r12]int g0/0/0
[r12-GigabitEthernet0/0/0]ip add 172.16.33.6 30
[r12-GigabitEthernet0/0/0]int l 0
[r12-LoopBack0]ip add 172.16.128.1 18
[r12-LoopBack0]int l 1
[r12-LoopBack1]ip add 172.16.192.1 18

测试所有直连网段是否通

用 Ping

搭建非shortcut方式的MGRE环境

R3配置

[r3]int t0/0/0
[r3-Tunnel0/0/0]ip add 172.16.0.1 24
[r3-Tunnel0/0/0]tunnel-protocol gre p2mp 
[r3-Tunnel0/0/0]source 34.0.0.3
[r3-Tunnel0/0/0]nhrp entry multicast dynamic 

[r3]ip route-static 0.0.0.0 0 34.0.0.4

R5配置

[r5]int t0/0/0
[r5-Tunnel0/0/0]ip add 172.16.0.2 24
[r5-Tunnel0/0/0]tunnel-protocol gre p2mp 
[r5-Tunnel0/0/0]source Serial 4/0/0
[r5-Tunnel0/0/0]nhrp entry 172.16.0.1 34.0.0.3 register 

[r5]ip route-static 0.0.0.0 0 45.0.0.4

R6配置

[r6]int t0/0/0
[r6-Tunnel0/0/0]ip add 172.16.0.3 24
[r6-Tunnel0/0/0]tunnel-protocol gre p2mp 
[r6-Tunnel0/0/0]source Serial 4/0/0
[r6-Tunnel0/0/0]nhrp entry 172.16.0.1 34.0.0.3 register 

[r6]ip route-static 0.0.0.0 0 46.0.0.4

R7配置

[r7]int t0/0/0
[r7-Tunnel0/0/0]ip add 172.16.0.4 24
[r7-Tunnel0/0/0]tunnel-protocol gre p2mp 
[r7-Tunnel0/0/0]source GigabitEthernet 0/0/0
[r7-Tunnel0/0/0]nhrp entry 172.16.0.1 34.0.0.3 register 

[r7]ip route-static 0.0.0.0 0 47.0.0.4

检查NHRP表

起Area 0的OSPF

R3配置

[r3]ospf 1 router-id 3.3.3.3  
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0]network 172.16.0.1 0.0.0.0

改p2mp类型

[r3-ospf-1-area-0.0.0.0]int t0/0/0

[r3-Tunnel0/0/0]ospf network-type p2mp

减少Hello时间与死亡时间

[r3-Tunnel0/0/0]ospf timer hello 1

将环回类型(主机)改为broadcast (不然OSPF学到的是掩码32的路由)

[r6]int l 0

[r6-LoopBack0]ospf network-type broadcast 

R5配置

[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.0.0 0.0.255.255

改p2mp类型

[r5-ospf-1-area-0.0.0.0]int t0/0/0
[r5-Tunnel0/0/0]ospf network-type p2mp

减少Hello时间与死亡时间

[r5-Tunnel0/0/0]ospf timer hello 1

R6配置

[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.3 0.0.0.0
[r6-ospf-1-area-0.0.0.0]network 172.16.2.1 0.0.0.0

改p2mp类型

[r6-ospf-1-area-0.0.0.0]int t0/0/0
[r6-Tunnel0/0/0]ospf network-type p2mp

减少Hello时间与死亡时间

[r6-Tunnel0/0/0]ospf timer hello 1

R7配置

[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.15.255.255

改p2mp类型

[r7-ospf-1-area-0.0.0.0]int t0/0/0
[r7-Tunnel0/0/0]ospf network-type p2mp

减少Hello时间与死亡时间

[r7-Tunnel0/0/0]ospf timer hello 1

测试OSPF与Hello修改

起Area 1的OSPF

R1配置

[r1]ospf 1 router-id 1.1.1.1
[r1-ospf-1]area 1
[r1-ospf-1-area-0.0.0.1]network 0.0.0.0 255.255.255.255

减少Hello时间与死亡时间

[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ospf timer hello 1

R2配置

[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 1
[r2-ospf-1-area-0.0.0.1]network 0.0.0.0 255.255.255.255

减少Hello时间与死亡时间

[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ospf timer hello 1

R3配置

[r3]ospf 1 
[r3-ospf-1]area 1
[r3-ospf-1-area-0.0.0.1]network 172.16.16.0 0.15.255.255

减少Hello时间与死亡时间

[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ospf timer hello 1

起Area 2的OSPF与RIP

R6配置

[r6]ospf 1
[r6-ospf-1]area 2
[r6-ospf-1-area-0.0.0.2]network 172.16.33.1 0.0.0.0

减少Hello时间与死亡时间

[r6]int g0/0/0
[r6-GigabitEthernet0/0/0]ospf timer hello 1

R11配置

[r11]ospf 1 router-id 11.11.11.11
[r11-ospf-1]area 2
[r11-ospf-1-area-0.0.0.2]network 0.0.0.0 255.255.255.255

减少Hello时间与死亡时间

[r11]int g0/0/0
[r11-GigabitEthernet0/0/0]ospf timer hello 1

[r11-GigabitEthernet0/0/0]int g0/0/1
[r11-GigabitEthernet0/0/1]ospf timer hello 1

R12配置

[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.33.6 0.0.0.0

减少Hello时间与死亡时间

[r12]int g0/0/0
[r12-GigabitEthernet0/0/0]ospf timer hello 1

起RIP

[r12-ospf-1-area-0.0.0.2]q
[r12-ospf-1]q
[r12]rip 1
[r12-rip-1]ver 2
[r12-rip-1]undo summary 
[r12-rip-1]network 172.16.0.0

起Area 3的OSPF

R7配置

[r7]ospf 1
[r7-ospf-1]area 3
[r7-ospf-1-area-0.0.0.3]network 172.16.49.1 0.0.0.0

减少Hello时间与死亡时间

[r7]int g0/0/1
[r7-GigabitEthernet0/0/1]ospf timer hello 1

R8配置

[r8]ospf 1 router-id 8.8.8.8 
[r8-ospf-1]area 3
[r8-ospf-1-area-0.0.0.3]network 0.0.0.0 255.255.255.255

减少Hello时间与死亡时间

[r8]int g0/0/0
[r8-GigabitEthernet0/0/0]ospf timer hello 1

[r8]int g0/0/1
[r8-GigabitEthernet0/0/1]ospf timer hello 1

R9配置

[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.49.6 0.0.0.0

减少Hello时间与死亡时间

[r9]int g0/0/0
[r9-GigabitEthernet0/0/0]ospf timer hello 1

起Area 4的OSPF(不同进程)

R9配置

[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.64.0 0.15.255.255

减少Hello时间与死亡时间

[r9-GigabitEthernet0/0/0]int g0/0/1
[r9-GigabitEthernet0/0/1]ospf timer hello 1

R10配置

[r10]ospf 1 router-id 10.10.10.10
[r10-ospf-1]area 4
[r10-ospf-1-area-0.0.0.4]network 0.0.0.0 255.255.255.255

减少Hello时间与死亡时间

[r10]int g0/0/0
[r10-GigabitEthernet0/0/0]ospf timer hello 1

R12与R9上做重发布

R12配置

[r12]ospf 1
[r12-ospf-1]import-route rip 1
[r12-ospf-1]q
[r12]rip 1
[r12-rip-1]import-route ospf 1

R9配置

[r9]ospf 1
[r9-ospf-1]import-route ospf 2
[r9-ospf-1]q
[r9]ospf 2
[r9-ospf-2]import-route ospf 1

做OSPF路由汇总

R3配置

[r3]ospf 1
[r3-ospf-1]area 1
[r3-ospf-1-area-0.0.0.1]abr-summary 172.16.16.0 255.255.240.0

R6配置

[r6]ospf 1
[r6-ospf-1]area 2
[r6-ospf-1-area-0.0.0.2]abr-summary 172.16.32.0 255.255.240.0

R7配置

[r7]ospf 1
[r7-ospf-1]area 3
[r7-ospf-1-area-0.0.0.3]abr-summary 172.16.48.0 255.255.240.0

R9配置(域外路由汇总

[r9]ospf 1
[r9-ospf-1]asbr-summary 172.16.64.0 255.255.240.0

R12配置(域外路由汇总

[r12]ospf 1
[r12-ospf-1]asbr-summary 172.16.128.0 255.255.128.0

做特殊区域

Area 1做成Totally Stub Area

R1配置

[r1]ospf 1
[r1-ospf-1]area 1
[r1-ospf-1-area-0.0.0.1]stub

R2配置

[r2]ospf 1
[r2-ospf-1]area 1
[r2-ospf-1-area-0.0.0.1]stub

R3配置

[r3]ospf 1
[r3-ospf-1]area 1

[r3-ospf-1-area-0.0.0.1]stub no-summary 

Area 2做成Totally NSSA

R6配置

[r6]ospf 1
[r6-ospf-1]area 2
[r6-ospf-1-area-0.0.0.2]nssa no-summary

R11配置

[r11]ospf 1
[r11-ospf-1]area 2
[r11-ospf-1-area-0.0.0.2]nssa 

R12配置

[r12]ospf 1 
[r12-ospf-1]area 2
[r12-ospf-1-area-0.0.0.2]nssa 

Area 3做成Totally NSSA

R7配置

[r7]ospf 1
[r7-ospf-1]area 3
[r7-ospf-1-area-0.0.0.3]nssa no-summary

R8配置

[r8]ospf 1
[r8-ospf-1]area 3
[r8-ospf-1-area-0.0.0.3]nssa 

R9配置

[r9]ospf 1
[r9-ospf-1]area 3
[r9-ospf-1-area-0.0.0.3]nssa 

下发一个缺省,不然R10中既没有缺省,也没有其他路由

[r9]ospf 2
[r9-ospf-2]default-route-advertise

做认证保障更新安全

R9配置(接口认证

[r9]int g0/0/1
[r9-GigabitEthernet0/0/1]ospf authentication-mode md5 1 cipher 123456

R10配置(接口认证

[r10]int g0/0/0
[r10-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 123456

R1配置(区域认证

[r1]ospf 1
[r1-ospf-1]area 1
[r1-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher 123456

R2配置(区域认证

[r2]ospf 1
[r2-ospf-1]area 1
[r2-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher 123456

R3配置(区域认证

[r3]ospf 1
[r3-ospf-1]area 1

[r3-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher 123456

空接口防环(优化)

R3配置

[r3]ip route-static 172.16.16.0 20 NULL 0

R6配置

[r6]ip route-static 172.16.32.0 20 NULL 0

静默接口(优化)

配在连接用户上(即环回接口)

R1配置

[r1]ospf 1
[r1-ospf-1]silent-interface LoopBack 0

R2配置

[r2]ospf 1
[r2-ospf-1]silent-interface LoopBack 0

R3配置

[r3]ospf 1
[r3-ospf-1]silent-interface LoopBack 0

R4配置

[r4]ospf 1
[r4-ospf-1]silent-interface LoopBack 0

R5配置

[r5]ospf 1
[r5-ospf-1]silent-interface LoopBack 0

R6配置

[r6]ospf 1

[r6-ospf-1]silent-interface LoopBack 0

R7配置

[r7]ospf 1
[r7-ospf-1]silent-interface LoopBack 0

R8配置

[r8]ospf 1
[r8-ospf-1]silent-interface LoopBack 0

R9配置

[r9]ospf 1
[r9-ospf-1]silent-interface LoopBack 0

R10配置

[r10]ospf 1
[r10-ospf-1]silent-interface LoopBack 0

R11配置

[r11]ospf 1
[r11-ospf-1]silent-interface LoopBack 0

R12配置

做NAT

R3配置

[r3]acl 2000
[r3-acl-basic-2000]rule permit source 172.16.16.0 0.0.15.255

[r3-acl-basic-2000]q
[r3]int s4/0/0
[r3-Serial4/0/0]nat outbound 2000

R6配置

[r6]acl 2000
[r6-acl-basic-2000]rule permit source 172.16.32.0 0.0.15.255

[r6-acl-basic-2000]rule permit source 172.16.128.0 0.0.254.255
[r6-acl-basic-2000]q
[r6]int s4/0/0
[r6-Serial4/0/0]nat outbound 2000

R7配置

[r7]acl 2000
[r7-acl-basic-2000]rule permit source 172.16.48.0 0.0.15.255
[r7-acl-basic-2000]rule permit source 172.16.64.0 0.0.15.255
[r7-acl-basic-2000]q
[r7]int g0/0/0
[r7-GigabitEthernet0/0/0]nat outbound 2000


5、测试

测试所有设备均可访问R4的环回

测试全网可达