ospf小实验

在这里插入图片描述
根据题目上的要求,我们搭建出相应的拓扑:
在这里插入图片描述
我们给R1-R5没有配环回,是为了好做NAT,所以每个路由器下面做了pc,所有的私有网段为ospf,R1,R4,R5为MGRE,我们有tunnel0/0/0口;R1,R2,R3为星型拓扑,R1为中心,我们用tunnel0/0/1口。
pc的ip地址我们依次给192.168.1.1-192.168.5.1,网关依次给192.168.1.254-192.168.5.254,掩码都为255.255.255.0;isp环回为6.6.6.6/24.R1到R5于isp的接口网段分别为16.1.1.0/24-56.1.1.0/24.
我们开始我们的配置:
1.首先我们给每个接口配上ip地址,所有路由器配置缺省路由,pc配置ip地址;

[r1]interface GigabitEthernet 0/0/1
[r1-GigabitEthernet0/0/1]ip address 61.1.1.1 24
[r1-GigabitEthernet0/0/1]int g 0/0/0
[r1-GigabitEthernet0/0/0]ip address 16.1.1.1 24
[r1]interface GigabitEthernet 0/0/2
[r1-GigabitEthernet0/0/2]ip address 192.168.1.254 24

[r2]interface GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]ip address 26.1.1.1 24
[r2-GigabitEthernet0/0/0]int g 0/0/2	
[r2-GigabitEthernet0/0/2]ip address 192.168.2.254 24

[r3]interface GigabitEthernet 0/0/0	
[r3-GigabitEthernet0/0/0]ip address 36.1.1.1 24
[r3-GigabitEthernet0/0/0]int g 0/0/2	
[r3-GigabitEthernet0/0/2]ip address 192.168.3.254 24

[r4]interface GigabitEthernet 0/0/0	
[r4-GigabitEthernet0/0/0]ip address 46.1.1.1 4
[r4-GigabitEthernet0/0/0]int g 0/0/2
[r4-GigabitEthernet0/0/2]ip address 192.168.4.254 24

[r5]interface GigabitEthernet 0/0/0	
[r5-GigabitEthernet0/0/0]ip address 56.1.1.1 24
[r5-GigabitEthernet0/0/0]int g 0/0/2
[r5-GigabitEthernet0/0/2]ip address 192.168.5.254 24

[isp]interface GigabitEthernet 0/0/0
[isp-GigabitEthernet0/0/0]ip address 16.1.1.2 24
[isp-GigabitEthernet0/0/0]int g 0/0/1	
[isp-GigabitEthernet0/0/1]ip address 61.1.1.2 24
[isp-GigabitEthernet0/0/1]int g 0/0/2
[isp-GigabitEthernet0/0/2]ip address 26.1.1.2 24
[isp-GigabitEthernet0/0/2]int g 4/0/0
[isp-GigabitEthernet4/0/0]ip address 36.1.1.2 24
[isp-GigabitEthernet4/0/0]int g 6/0/0
[isp-GigabitEthernet6/0/0]ip address 46.1.1.2 24
[isp-GigabitEthernet6/0/0]int g 6/0/1	
[isp-GigabitEthernet6/0/1]ip address 56.1.1.2 24
[isp]interface LoopBack 0	
[isp-LoopBack0]ip address 6.6.6.6 24

[r1]ip route-static 0.0.0.0 0.0.0.0 16.1.1.2
[r1]ip route-static 0.0.0.0 0.0.0.0 61.1.1.2
[r2]ip route-static 0.0.0.0 0.0.0.0 26.1.1.2
[r3]ip route-static 0.0.0.0 0.0.0.0 36.1.1.2
[r4]ip route-static 0.0.0.0 0.0.0.0 46.1.1.2
[r5]ip route-static 0.0.0.0 0.0.0.0 56.1.1.2

手动给每个pc写上ip地址和网关,掩码,然后ping网关和路由器出接口,检查是否配置成功。
2.给每个路由器配置NAT,检查pc是否可以上网

[r1]acl 2000
[r1-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[r1]interface GigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]nat outbound 2000
[r1]interface GigabitEthernet 0/0/1
[r1-GigabitEthernet0/0/1]nat outbound 2000

[r2]acl 2000
[r2-acl-basic-2000]rule permit source 192.168.2.0 0.0.0.255
[r2]interface GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]nat outbound 2000

[r3]acl 2000
[r3-acl-basic-2000]rule permit source 192.168.3.0 0.0.0.255
[r3]interface GigabitEthernet 0/0/0
[r3-GigabitEthernet0/0/0]nat outbound 2000

[r4]acl 2000
[r4-acl-basic-2000]rule permit source 192.168.4.0 0.0.0.255
[r4]interface GigabitEthernet 0/0/0
[r4-GigabitEthernet0/0/0]nat outbound 2000

[r5]acl 2000
[r5-acl-basic-2000]rule permit source 192.168.5.0 0.0.0.255
[r5]interface GigabitEthernet 0/0/0
[r5-GigabitEthernet0/0/0]nat outbound 2000

配置好NAT后,我们随机找一台电脑ping ISP的环回6.6.6.6

PC>ping 6.6.6.6

Ping 6.6.6.6: 32 data bytes, Press Ctrl_C to break
From 6.6.6.6: bytes=32 seq=1 ttl=254 time=31 ms
From 6.6.6.6: bytes=32 seq=2 ttl=254 time=15 ms
From 6.6.6.6: bytes=32 seq=3 ttl=254 time=32 ms
From 6.6.6.6: bytes=32 seq=4 ttl=254 time=31 ms
From 6.6.6.6: bytes=32 seq=5 ttl=254 time=16 ms

--- 6.6.6.6 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 15/25/32 ms

通了之后,我们的NAT也就做好了。
3.给R1,R4,R5配置全连MGRE
这个学习R1的16.1.1.1口。

[r1]interface Tunnel 0/0/0
[r1-Tunnel0/0/0]ip address 10.1.1.1 24
[r1-Tunnel0/0/0]tunnel-protocol gre p2mp
[r1-Tunnel0/0/0]source 16.1.1.1
[r1-Tunnel0/0/0]nhrp entry 16.1.1.1 46.1.1.1 register
[r1-Tunnel0/0/0]nhrp entry 16.1.1.1 56.1.1.1 register
[r1-Tunnel0/0/0]nhrp network-id 100

[r4]interface Tunnel 0/0/0
[r4-Tunnel0/0/0]tunnel-protocol gre p2mp 
[r4-Tunnel0/0/0]source 46.1.1.1
[r4-Tunnel0/0/0]nhrp entry 46.1.1.1 16.1.1.1 register
[r4-Tunnel0/0/0]nhrp entry 46.1.1.1 56.1.1.1 register
[r4-Tunnel0/0/0]nhrp network-id 100

[r5]interface Tunnel 0/0/0
[r5-Tunnel0/0/0]tunnel-protocol gre p2mp
[r5-Tunnel0/0/0]source 56.1.1.1
[r5-Tunnel0/0/0]nhrp entry 56.1.1.1 16.1.1.1 register 
[r5-Tunnel0/0/0]nhrp entry 56.1.1.1 46.1.1.1 register
[r5-Tunnel0/0/0]nhrp network-id 100

4.给R1,R2,R3做星型拓扑MGRE,R1为中心
这个学习用R1的61.1.1.1口

[r1]interface Tunnel 0/0/1
[r1-Tunnel0/0/1]tunnel-protocol gre p2mp 
[r1-Tunnel0/0/1]source 61.1.1.1
[r1-Tunnel0/0/1]nhrp entry multicast dynamic   //设置R1为中心
[r1-Tunnel0/0/1]nhrp network-id 101

[r2]interface Tunnel 0/0/1
[r2-Tunnel0/0/1]tunnel-protocol gre p2mp 
[r2-Tunnel0/0/1]source 26.1.1.1
[r2-Tunnel0/0/1]nhrp entry 26.1.1.1 61.1.1.1 register
[r2-Tunnel0/0/1]nhrp network-id 101

[r3]int Tunnel 0/0/1	
[r3-Tunnel0/0/1]tunnel-protocol gre p2mp 
[r3-Tunnel0/0/1]source 36.1.1.1	
[r3-Tunnel0/0/1]nhrp entry 36.1.1.1 16.1.1.1 register 	
[r3-Tunnel0/0/1]nhrp network-id 101

5.最后我们将ospf做起来

[r1]ospf 1 router-id 1.1.1.1
[r1-ospf-1]area 0
[r1-ospf-1-area-0.0.0.0]network 192.168.1.254 0.0.0.0
[r1-ospf-1-area-0.0.0.0]network 16.1.1.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]network 61.1.1.1 0.0.0.0

[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 192.168.2.254 0.0.0.0
[r2-ospf-1-area-0.0.0.0]network 26.1.1.1 0.0.0.0

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

[r4]ospf 1 router-id 4.4.4.4
[r4-ospf-1]area 0
[r4-ospf-1-area-0.0.0.0]network 46.1.1.1 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network 192.168.4.254 0.0.0.0

[r5]ospf 1 router-id 5.5.5.5
[r5-ospf-1]area 0
[r5-ospf-1-area-0.0.0.0]network 56.1.1.1 0.0.0.0
[r5-ospf-1-area-0.0.0.0]network 192.168.5.254 0.0.0.0
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页