MGRE环境下的OSPF实验


一、实验拓扑图:
在这里插入图片描述

二、 实验步骤

1.首先我们需要给各路由器配置接口IP地址,和环回地址。

[R1]int LoopBack 0
[R1-LoopBack0]ip ad    
[R1-LoopBack0]ip address 192.168.1.1 24
[R1-GigabitEthernet0/0/0]ip address 16.0.0.1 24
Jul 10 2024 23:06:27-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R1-GigabitEthernet0/0/1]ip ad	
[R1-GigabitEthernet0/0/1]ip address 116.0.0.1 24
Jul 10 2024 23:07:04-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state.

[R2-LoopBack0]ip add	
[R2-LoopBack0]ip address 192.168.2.1 24
[R2-GigabitEthernet0/0/0]ip ad	
[R2-GigabitEthernet0/0/0]ip address 26.0.0.1 24
Jul 10 2024 23:16:24-08:00 R2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state.

[R3-LoopBack0]ip add	
[R3-LoopBack0]ip address 192.168.3.1 24
[R3-GigabitEthernet0/0/0]ip address 36.0.0.1 24
Jul 10 2024 23:18:47-08:00 R3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state.

[R4-LoopBack0]ip address 192.168.4.1 24
[R4-GigabitEthernet0/0/0]ip address 46.0.0.1 24

[R5-LoopBack0]ip address 192.168.5.1 24
[R5-GigabitEthernet0/0/0]ip add	
[R5-GigabitEthernet0/0/0]ip address 56.0.0.1 24
Jul 10 2024 23:23:01-08:00 R5 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state.

[ISP-LoopBack0]ip address 6.6.6.6 24
[ISP-GigabitEthernet0/0/0]ip address 16.0.0.2 24
[ISP-GigabitEthernet0/0/1]ip address 116.0.0.2 24
[ISP-GigabitEthernet0/0/2]ip address 56.0.0.2 24
[ISP-GigabitEthernet4/0/0]ip address 26.0.0.2 24
[ISP-GigabitEthernet4/0/1]ip address 36.0.0.2 24
[ISP-GigabitEthernet4/0/2]ip address 46.0.0.2 24

​2.接下来,我们需要配置所有路由器的缺省,使得公网全通

[R1]ip route-static 0.0.0.0 0 116.0.0.2
[R1]ip route-static 0.0.0.0 0 16.0.0.2

[R2]ip route-static 0.0.0.0 0 26.0.0.2

[R3]ip route-static 0.0.0.0 0 36.0.0.2

[R4]ip route-static 0.0.0.0 0 46.0.0.2

[R5]ip route-static 0.0.0.0 0 56.0.0.2

3.用ping 测试

[R1]ping 46.0.0.1
  PING 46.0.0.1: 56  data bytes, press CTRL_C to break
    Request time out
    Reply from 46.0.0.1: bytes=56 Sequence=2 ttl=254 time=30 ms
    Reply from 46.0.0.1: bytes=56 Sequence=3 ttl=254 time=20 ms
    Reply from 46.0.0.1: bytes=56 Sequence=4 ttl=254 time=20 ms
    Reply from 46.0.0.1: bytes=56 Sequence=5 ttl=254 time=40 ms

  --- 46.0.0.1 ping statistics ---
    5 packet(s) transmitted
    4 packet(s) received
    20.00% packet loss
    round-trip min/avg/max = 20/27/40 ms
    [R1]ping 56.0.0.1
 
  PING 56.0.0.1: 56  data bytes, press CTRL_C to break
    Request time out
    Reply from 56.0.0.1: bytes=56 Sequence=2 ttl=254 time=30 ms
    Reply from 56.0.0.1: bytes=56 Sequence=3 ttl=254 time=20 ms
    Reply from 56.0.0.1: bytes=56 Sequence=4 ttl=254 time=30 ms
    Reply from 56.0.0.1: bytes=56 Sequence=5 ttl=254 time=20 ms

  --- 56.0.0.1 ping statistics ---
    5 packet(s) transmitted
    4 packet(s) received
    20.00% packet loss
    round-trip min/avg/max = 20/25/30 ms

4.R1/R4/R5为全连的MGRE结构,按照要求配置

[R1-Tunnel0/0/0]ip address 192.168.6.1 24
[R1-Tunnel0/0/0]tunnel-protocol gre p2mp
[R1-Tunnel0/0/0]source 16.0.0.1
[R1-Tunnel0/0/0]nhrp network-id 100
[R1-Tunnel0/0/0]nhrp entry 192.168.6.2 46.0.0.1 register
[R1-Tunnel0/0/0]nhrp entry 192.168.6.3 56.0.0.1 register

[R4]int 	
[R4]int t	
[R4]int Tunnel 0/0/0
[R4-Tunnel0/0/0]ip ad	
[R4-Tunnel0/0/0]ip address 192.168.6.2 24
[R4-Tunnel0/0/0]r	
[R4-Tunnel0/0/0]tun	
[R4-Tunnel0/0/0]tunnel-protocol gre p	
[R4-Tunnel0/0/0]tunnel-protocol gre p2mp 
[R4-Tunnel0/0/0]s	
[R4-Tunnel0/0/0]source 46.0.0.1
Jul 10 2024 23:49:17-08:00 R4 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface Tunnel0/0/0 has entered the UP state. 
[R4-Tunnel0/0/0]
[R4-Tunnel0/0/0]nhrp network-id 100
[R4-Tunnel0/0/0]nhrp entry 192.168.6.1 16.0.0.1 register
[R4-Tunnel0/0/0]nhrp entry 192.168.6.3 56.0.0.1 register

[R5]int Tunnel 0/0/0	
[R5-Tunnel0/0/0]ip address 192.168.6.3 24	
[R5-Tunnel0/0/0]tunnel-protocol gre p2mp 
[R5-Tunnel0/0/0]source 56.0.0.1	
[R5-Tunnel0/0/0]nhrp network-id 100
[R5-Tunnel0/0/0]nhrp entry 192.168.6.1 16.0.0.1 register 
[R5-Tunnel0/0/0]nhrp entry 192.168.6.4 46.0.0.1 register

配置完所有后,检查表:

[R4]display nhrp peer all 
------------------------------------------------------------------------------- 
Protocol-addr   Mask  NBMA-addr       NextHop-addr    Type         Flag         
------------------------------------------------------------------------------- 
192.168.6.1     32    16.0.0.1        192.168.6.1     static       hub          
------------------------------------------------------------------------------- 
Tunnel interface: Tunnel0/0/0
Created time    : 00:05:34
Expire time     : --
------------------------------------------------------------------------------- 
Protocol-addr   Mask  NBMA-addr       NextHop-addr    Type         Flag         
------------------------------------------------------------------------------- 
192.168.6.3     32    56.0.0.1        192.168.6.3     static       hub          
------------------------------------------------------------------------------- 
Tunnel interface: Tunnel0/0/0
Created time    : 00:05:15
Expire time     : --

Number of nhrp peers: 2

4.R1/R2/R3均为星形拓扑结构,其中R1 为中心站点

[R1]int t	
[R1]int Tunnel 0/0/1
[R1-Tunnel0/0/1]ip add	
[R1-Tunnel0/0/1]ip address 192.168.7.1 24
[R1-Tunnel0/0/1]tun	
[R1-Tunnel0/0/1]tunnel-protocol gre p	
[R1-Tunnel0/0/1]tunnel-protocol gre p2mp 
[R1-Tunnel0/0/1]sou	
[R1-Tunnel0/0/1]source 116.0.0.1
Jul 10 2024 23:57:17-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface Tunnel0/0/1 has entered the UP state. 
[R1-Tunnel0/0/1]
[R1-Tunnel0/0/1]nhrp	
[R1-Tunnel0/0/1]nhrp n	
[R1-Tunnel0/0/1]nhrp network-id 100
[R1-Tunnel0/0/1]nh	
[R1-Tunnel0/0/1]nhrp en	
[R1-Tunnel0/0/1]nhrp entry mu	
[R1-Tunnel0/0/1]nhrp entry multicast d	
[R1-Tunnel0/0/1]nhrp entry multicast dynamic 

[R2]int Tunnel 0/0/1
[R2-Tunnel0/0/1]ip ad	
[R2-Tunnel0/0/1]ip address 192.168.7.2 24
[R2-Tunnel0/0/1]t	
[R2-Tunnel0/0/1]tun	
[R2-Tunnel0/0/1]tunnel-protocol gre p	
[R2-Tunnel0/0/1]tunnel-protocol gre p2mp 
[R2-Tunnel0/0/1]nh	
[R2-Tunnel0/0/1]nhrp n	
[R2-Tunnel0/0/1]nhrp network-id 100
[R2-Tunnel0/0/1]sou	
[R2-Tunnel0/0/1]source G	
[R2-Tunnel0/0/1]source GigabitEthernet 0/0/0
Jul 10 2024 23:59:21-08:00 R2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface Tunnel0/0/1 has entered the UP state. 
[R2-Tunnel0/0/1]
[R2-Tunnel0/0/1]nhrp e	
[R2-Tunnel0/0/1]nhrp entry 192.168.7.1 116.0.0.1 re	
[R2-Tunnel0/0/1]nhrp entry 192.168.7.1 116.0.0.1 register

[R3]int t	
[R3]int Tunnel 0/0/1
[R3-Tunnel0/0/1]ip ad	
[R3-Tunnel0/0/1]ip address 192.168.7.3 24
[R3-Tunnel0/0/1]tun	
[R3-Tunnel0/0/1]tunnel-protocol gre p	
[R3-Tunnel0/0/1]tunnel-protocol gre p2mp 
[R3-Tunnel0/0/1]sou	
[R3-Tunnel0/0/1]source G	
[R3-Tunnel0/0/1]source GigabitEthernet 0/0/0
Jul 11 2024 00:00:41-08:00 R3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface Tunnel0/0/1 has entered the UP state. 
[R3-Tunnel0/0/1]
[R3-Tunnel0/0/1]nhrp n	
[R3-Tunnel0/0/1]nhrp network-id 100
[R3-Tunnel0/0/1]n	
[R3-Tunnel0/0/1]nh	
[R3-Tunnel0/0/1]nhrp en	
[R3-Tunnel0/0/1]nhrp entry 192.168.7.1 116.0.01 re	
[R3-Tunnel0/0/1]nhrp entry 192.168.7.1 116.0.01 register

检查
[R2]display nhrp peer all 
------------------------------------------------------------------------------- 
Protocol-addr   Mask  NBMA-addr       NextHop-addr    Type         Flag         
------------------------------------------------------------------------------- 
192.168.7.1     32    116.0.0.1       192.168.7.1     static       hub          
------------------------------------------------------------------------------- 
Tunnel interface: Tunnel0/0/1
Created time    : 00:02:28
Expire time     : --

Number of nhrp peers: 1

5.使用OSPF配置路由

[R1]ospf 1rou	
[R1]ospf 1 rou	
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]are	
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 192.168.6.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 192.168.7.0 0.0.0.255

[R2]ospf 1	
[R2]ospf 1 rou	
[R2]ospf 1 router-id 2.2.2.2
Info: The configuration succeeded. You need to restart the OSPF process to valid
ate the new router ID.
[R2-ospf-1]are 0
[R2-ospf-1-area-0.0.0.0]network 192.168.7.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]
Jul 11 2024 00:10:41-08:00 R2 %%01OSPF/4/CONFLICT_ROUTERID_INTF(l)[1]:OSPF Route
r id conflict is detected on interface. (ProcessId=256, RouterId=1.1.1.1, AreaId
=0.0.0.0, InterfaceName=Tunnel0/0/1,  IpAddr=2.7.168.192, PacketSrcIp=1.7.168.19
2) 
[R2-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255

[R3]ospf 1 rou	
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]are	
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]net	
[R3-ospf-1-area-0.0.0.0]network 192.168.3.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 192.168.7.0 0.0.0.255

[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]are	
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 192.168.4.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]network 192.168.6.0 0.0.0.255

[R5]ospf 1 router-id 5.5.5.5
[R5-ospf-1]area 0
[R5-ospf-1-area-0.0.0.0]network 192.168.5.0 0.0.0.255
[R5-ospf-1-area-0.0.0.0]network 192.168.6.0 0.0.0.255
[R5-ospf-1-area-0.0.0.0]
Jul 11 2024 00:13:54-08:00 R5 %%01OSPF/4/NBR_CHANGE_E(l)[0]:Neighbor changes eve
nt: neighbor status changed. (ProcessId=256, NeighborAddress=2.6.168.192, Neighb
orEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init)

此时在r1上ping其他路由只能ping通192.168.2.1,原因是因为跟MGRE环境下接口的网络类型有关,它是以P2P的工作方式进行的,P2P是点到点的工作方式,且P2P是不需要进行DR/BDR的选举的,它只能建立一个邻居,所以我们需要更改网络类型为breadcast
6.紧接着更改网络类型

[R1]int t0/0/0
[R1-Tunnel0/0/0]ospf network-type broadcast 
[R1-Tunnel0/0/0]int t0/0/1
[R1-Tunnel0/0/1]ospf network-type broadcast

R2]int t0/0/1
[R2-Tunnel0/0/1]ospf network-type broadcast 
 
[R3-ospf-1]int t0/0/1	
[R3-Tunnel0/0/1]ospf network-type broadcast 
 
[R4]int t0/0/0
[R4-Tunnel0/0/0]ospf network-type broadcast 
 
[R5-ospf-1]int t0/0/0
[R5-Tunnel0/0/0]ospf network-type broadcast

7接下来修改R2 和R3 的接口优先级

[R2]int t0/0/1
[R2-Tunnel0/0/1]os	
[R2-Tunnel0/0/1]ospf d	
[R2-Tunnel0/0/1]ospf dr-priority 0

[R3]int t	
[R3]int Tunnel 0/0/1
[R3-Tunnel0/0/1]os	
[R3-Tunnel0/0/1]ospf d	
[R3-Tunnel0/0/1]ospf dr-priority 0

最后完成所有步骤后,紧接着测试所有设备:

[R1]ping 192.168.4.1
  PING 192.168.4.1: 56  data bytes, press CTRL_C to break
    Reply from 192.168.4.1: bytes=56 Sequence=1 ttl=255 time=30 ms
    Reply from 192.168.4.1: bytes=56 Sequence=2 ttl=255 time=30 ms
    Reply from 192.168.4.1: bytes=56 Sequence=3 ttl=255 time=30 ms
    Reply from 192.168.4.1: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 192.168.4.1: bytes=56 Sequence=5 ttl=255 time=20 ms

  --- 192.168.4.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/26/30 ms

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值