HCIP-Day4(OSPF实验2)
实验要求具体如下:
1、R7为ISP,只能配置ip2、红色为私有ip范围
3、使用OSPF将所有私有网段,实现全通
4、OSPF的区域划分为紫色
5、R4-6可以正常访问R7环回
6、R1telnet R3公有ip,实际登录到R6
一、拓扑搭建
二、配置端口及环回
R1
[r1]int g0/0/1
[r1-GigabitEthernet0/0/1]ip add
[r1-GigabitEthernet0/0/1]ip address 192.168.1.1 24
[r1-GigabitEthernet0/0/1]int loo 0
[r1-LoopBack0]ip add
[r1-LoopBack0]ip address 1.1.1.1 24
R2
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add
[r2-GigabitEthernet0/0/0]ip address 192.168.2.1 24
[r2-GigabitEthernet0/0/0]int loo 0
[r2-LoopBack0]ip add
[r2-LoopBack0]ip address 2.2.2.2 24
R3
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add
[r3-GigabitEthernet0/0/0]ip address 192.168.3.1 24
[r3]int g0/0/1
[r3-GigabitEthernet0/0/1]ip ad
[r3-GigabitEthernet0/0/1]ip address 192.172.1.1 24
[r3-GigabitEthernet0/0/0]int loo 0
[r3-LoopBack0]ip add
[r3-LoopBack0]ip address 3.3.3.3 24
R4
[r4]int g0/0/0
[r4-GigabitEthernet0/0/0]ip add
[r4-GigabitEthernet0/0/0]ip address 192.172.1.2 24
[r4-GigabitEthernet0/0/0]int g 0/0/1
[r4-GigabitEthernet0/0/1]ip add
[r4-GigabitEthernet0/0/1]ip address 192.172.2.1 24
[r4-GigabitEthernet0/0/1]
[r4-GigabitEthernet0/0/1]int loo 0
[r4-LoopBack0]ip add
[r4-LoopBack0]ip address 4.4.4.4 24
R5
[r5]int g0/0/0
[r5-GigabitEthernet0/0/0]ip add
[r5-GigabitEthernet0/0/0]ip address 192.172.2.2 24
[r5-GigabitEthernet0/0/0]int loo 0
[r5-LoopBack0]ip add
[r5-LoopBack0]ip address 5.5.5.5 24
R6
[r6]int g0/0/0
[r6-GigabitEthernet0/0/0]ip add
[r6-GigabitEthernet0/0/0]ip address 192.172.3.2 24
[r6-GigabitEthernet0/0/0]int loo 0
[r6-LoopBack0]ip add
[r6-LoopBack0]ip address 6.6.6.6 24
R7
[r7]int g0/0/0
[r7-GigabitEthernet0/0/0]ip ad
[r7-GigabitEthernet0/0/0]ip address 192.168.1.2 24
[r7-GigabitEthernet0/0/0]int g0/0/1
[r7-GigabitEthernet0/0/1]ip ad
[r7-GigabitEthernet0/0/1]ip address 192.168.2.2 24
[r7-GigabitEthernet0/0/1]int g0/0/2
[r7-GigabitEthernet0/0/2]ip ad
[r7-GigabitEthernet0/0/2]ip address 192.168.3.2 24
[r7-GigabitEthernet0/0/2]q
[r7]int loo 0
[r7-LoopBack0]ip ad
[r7-LoopBack0]ip address 7.7.7.7 24
三、配置缺省路由
R1 [r1]ip route-static 0.0.0.0 0 192.172.1.2
R2 [r2]ip route-static 0.0.0.0 0 198.172.2.2
R3 [r3]ip route-static 0.0.0.0 0 198.172.3.2
四、GRE隧道搭建
R1
[r1]int t 0/0/0
[r1-Tunnel0/0/0]ip ad
[r1-Tunnel0/0/0]ip address 10.1.1.1 24
[r1-Tunnel0/0/0]tun
[r1-Tunnel0/0/0]tunnel-protocol gre p2mp
[r1-Tunnel0/0/0]sou
[r1-Tunnel0/0/0]source 192.168.1.1
[r1-Tunnel0/0/0]nhrp e
[r1-Tunnel0/0/0]nhrp entry mu
[r1-Tunnel0/0/0]nhrp entry multicast dy
[r1-Tunnel0/0/0]nhrp entry multicast dynamic
[r1-Tunnel0/0/0]nh
[r1-Tunnel0/0/0]nhrp ne
[r1-Tunnel0/0/0]nhrp network-id 100
[r1-Tunnel0/0/0]nh
[r1-Tunnel0/0/0]nhrp entry
[r1-Tunnel0/0/0]nhrp entry 10.1.1.2 192.168.2.1 re
[r1-Tunnel0/0/0]nhrp entry 10.1.1.2 192.168.2.1 register
[r1-Tunnel0/0/0]nhrp entry 10.1.1.2 192.168.3.1 register
R2
[r2]int t0/0/0
[r2-Tunnel0/0/0]ip ad
[r2-Tunnel0/0/0]ip address 10.1.1.2 24
[r2-Tunnel0/0/0]tu
[r2-Tunnel0/0/0]tunnel-protocol gre
[r2-Tunnel0/0/0]tunnel-protocol gre p2mp
[r2-Tunnel0/0/0]so
[r2-Tunnel0/0/0]source 192.168.2.1
[r2-Tunnel0/0/0]nh
[r2-Tunnel0/0/0]nhrp entry m
[r2-Tunnel0/0/0]nhrp entry multicast d
[r2-Tunnel0/0/0]nhrp entry multicast dynamic
[r2-Tunnel0/0/0]nhrp
[r2-Tunnel0/0/0]nhrp net
[r2-Tunnel0/0/0]nhrp network-id 100
[r2-Tunnel0/0/0]nhrp
[r2-Tunnel0/0/0]nhrp entr
[r2-Tunnel0/0/0]nhrp entry 10.1.1.1 192.168.1.1 reg
[r2-Tunnel0/0/0]nhrp entry 10.1.1.1 192.168.1.1 register
[r2-Tunnel0/0/0]nhrp entry 10.1.1.3 192.168.3.2 r
[r2-Tunnel0/0/0]nhrp entry 10.1.1.3 192.168.3.2 register
R3
[r3]int t0/0/0
[r3-Tunnel0/0/0]ip d
[r3-Tunnel0/0/0]ip add
[r3-Tunnel0/0/0]ip address 10.1.1.3 24
[r3-Tunnel0/0/0]tu
[r3-Tunnel0/0/0]tunnel-protocol gre p2mp
[r3-Tunnel0/0/0]sou
[r3-Tunnel0/0/0]source 198.172.3.1
[r3-Tunnel0/0/0]nhrp entry
[r3-Tunnel0/0/0]nhrp entry m
[r3-Tunnel0/0/0]nhrp entry multicast dy
[r3-Tunnel0/0/0]nhrp entry multicast dynamic
[r3-Tunnel0/0/0]nh
[r3-Tunnel0/0/0]nhrp net
[r3-Tunnel0/0/0]nhrp network-id 100
[r3-Tunnel0/0/0]nhrp
[r3-Tunnel0/0/0]nhrp en
[r3-Tunnel0/0/0]nhrp entry 10.1.1.1 192.172.1.1 r
[r3-Tunnel0/0/0]nhrp entry 10.1.1.1 192.172.1.1 register
[r3-Tunnel0/0/0]nh
[r3-Tunnel0/0/0]nhrp en
[r3-Tunnel0/0/0]nhrp entry 10.1.1.2 192.172.2.1 r
[r3-Tunnel0/0/0]nhrp entry 10.1.1.2 192.172.2.1 register
[r3-Tunnel0/0/0]
五、启用OSPF使私网全通
宣告每一个路由且对环回宣告
R1
[r1]ospf 1 router-id 1.1.1.1
[r1-ospf-1]area 0
[r1-ospf-1-area-0.0.0.0]net
[r1-ospf-1-area-0.0.0.0]network 10.1.1.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]net
[r1-ospf-1-area-0.0.0.0]network 192.168.1.1 0.0.0.0
R2
[r2]ospf router-id 2.2.2.2
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]net
[r2-ospf-1-area-0.0.0.0]network 10.1.1.2 0.0.0.0
[r2-ospf-1-area-0.0.0.0]network 192.168.2.1 0.0.0.0
R3
[r3]ospf router-id 3.3.3.3
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0]network 192.168.3.1 0.0.0.0
[r3-ospf-1-area-0.0.0.0]area 1
[r3-ospf-1-area-0.0.0.1]network 3.3.3.3 0.0.0.0
[r3-ospf-1-area-0.0.0.1]network 192.172.1.1 0.0.0.0
R4
[r4]ospf 1 r
[r4]ospf 1 router-id 4.4.4.4
[r4-ospf-1]area 1
[r4-ospf-1-area-0.0.0.1]net
[r4-ospf-1-area-0.0.0.1]network 192.172.1.2 0.0.0.0
[r4-ospf-1-area-0.0.0.1]network 192.172.2.1 0.0.0.0
R5
[r5]ospf 1 r
[r5]ospf 1 router-id 5.5.5.5
[r5-ospf-1]area 1
[r5-ospf-1-area-0.0.0.1]net
[r5-ospf-1-area-0.0.0.1]network 192.172.2.2 0.0.0.0
[r5-ospf-1-area-0.0.0.1]q
[r5-ospf-1]area 2
[r5-ospf-1-area-0.0.0.2]network 192.172.3.1 0.0.0.0
R6
[r6]ospf router-id 6.6.6.6
[r6-ospf-1]area 2
[r6-ospf-1-area-0.0.0.2]netw
[r6-ospf-1-area-0.0.0.2]network 192.172.3.2 0.0.0.0
[r6-ospf-1-area-0.0.0.2]net
[r6-ospf-1-area-0.0.0.2]network 6.6.6.6 0.0.0.0
六、改变R1、R2、R3的OSPF接口类型
R1
[r1]int t0/0/0
[r1-Tunnel0/0/0]osp
[r1-Tunnel0/0/0]ospf ne
[r1-Tunnel0/0/0]ospf network-type br
[r1-Tunnel0/0/0]ospf network-type broadcast
R2
[r2]int t0/0/0
[r2-Tunnel0/0/0]os
[r2-Tunnel0/0/0]ospf n
[r2-Tunnel0/0/0]ospf network-type b
[r2-Tunnel0/0/0]ospf network-type broadcast
R3
[r3]int t0/0/0
[r3-Tunnel0/0/0]os
[r3-Tunnel0/0/0]ospf n
[r3-Tunnel0/0/0]ospf network-type b
[r3-Tunnel0/0/0]ospf network-type broadcast
七、重新建立R5与R6之间的邻居关系
R5
[r5]ospf 1
[r5-ospf-1]area 2
[r5-ospf-1-area-0.0.0.2]undo ne
[r5-ospf-1-area-0.0.0.2]
[r5-ospf-1-area-0.0.0.2]undo network 192.172.3.1 0.0.0.0
[r5-ospf-1-area-0.0.0.2]q
[r5-ospf-1]osp
[r5-ospf-1]q
[r5]os
[r5]ospf 2
[r5-ospf-2]area
[r5-ospf-2]area 2
[r5-ospf-2-area-0.0.0.2]netw
[r5-ospf-2-area-0.0.0.2]network 192.172.3.1 0.0.0.0
[r5-ospf-2-area-0.0.0.2]q
[r5-ospf-2]q
[r5]ospf 1
//开启R5双向重发布
[r5-ospf-1]im
[r5-ospf-1]import-route osp
[r5-ospf-1]import-route ospf 2
[r5-ospf-1]q
[r5]ospf 2
[r5-ospf-2]im
[r5-ospf-2]import-route os
[r5-ospf-2]import-route ospf 1
八、对R3进行重发布使R4-R6可以访问R7
R3
[r3]osp
[r3]ospf 1
[r3-ospf-1]de
[r3-ospf-1]default-route-advertise
//在R3路由器上配置net实现公私有地址转换
[r3]acl 2000
[r3-acl-basic-2000]ru
[r3-acl-basic-2000]rule p
[r3-acl-basic-2000]rule permit s
[r3-acl-basic-2000]rule permit source 192.168.0.0 0.0.255.255
[r3-acl-basic-2000]q
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]nat
[r3-GigabitEthernet0/0/0]nat outbound 2000