MGRE环境下的ospf实验

1.中间的路由器为ISP,只能配置IP地址,其他的路由器都有自己的私有网段

2.R1/3/4为全连的MGRE结构,R1/6/5为星型的拓扑结构,R1为中心站点

3.所有私有网段可以互相通讯,私有网段用ospf完成,实现全网通

IP地址配置如下:ip address IP地址 掩码

AR1:

sys
sys r1
int g 0/0/1
ip add 11.1.2.1 24
int g 0/0/0 
ip add 11.1.1.1 24
int lo0
ip add 192.168.1.1 24

AR6:

sys
sys r2
int g 0/0/0
ip add 21.1.1.1 24
int lo0
ip add 192.168.2.1 24

AR5: r3 31.1.1.1 24 回环:192.168.3.1 24

AR4:  r4 41.1.1.1 24 回环:192.168.4.1 24

AR3:  r5 51.1.1.1 24 回环:192.168.5.1 24

ISP:

11.1.1.2
11.1.2.2
21.1.1.2
31.1.1.2
41.1.1.2
51.1.1.2
int lo0
ip add 6.6.6.6 24 #回环地址

第二步:配置缺省实现公网通

sys
ip route-static 0.0.0.0 0.0.0.0 (下一跳地址,写接口对应的ispIP地址)
#比如AR1
ip route- 0.0.0.0 0 11.1.1.2
ip route- 0.0.0.0 0 11.1.2.2#这里要写两条,因为有两条途径,负载均衡

然后写完后最好就试一下能全公网通了吗,方便未来好排错

<r1>ping 21.1.1.1
  PING 21.1.1.1: 56  data bytes, press CTRL_C to break
    Reply from 21.1.1.1: bytes=56 Sequence=1 ttl=254 time=20 ms
    Reply from 21.1.1.1: bytes=56 Sequence=2 ttl=254 time=30 ms
    Reply from 21.1.1.1: bytes=56 Sequence=3 ttl=254 time=30 ms
    Reply from 21.1.1.1: bytes=56 Sequence=4 ttl=254 time=30 ms
    Reply from 21.1.1.1: bytes=56 Sequence=5 ttl=254 time=30 ms

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

...

 建立tunnel口

先实现全连的mgre结构,全连结构的路由接口的IP信息不变

AR1:

interface tunnel 0/0/0
ip add 192.168.6.1 24
tunnel-protocol gre p2mp#mgre协议
source 11.1.2.1

AR3/4

int tunnel 0/0/0
ip add 192.168.6.2/3 24
tunnel gre p2
source 41.1.1.1/51.1.1.1 24
nhrp entry 192.168.6.1 11.1.2.1 register#去往192.168.6.1进行注册登记,同时对其开启伪广播功能,便于ospf的hello包传输

同时AR1也对到该接口登记的开启伪广播功能

int tunnel 0/0/0
nhrp entry multicast dynamic#表示对来进行登记的路由开启伪广播功能

但是ospf协议要这三个路由彼此都打开伪广播功能,所以在AR3或4上进行上述操作

#AR3
int tunnel 0/0/0
nhrp entry 51.1.1.1 192.168.6.3 register
#AR4
int tunnel 0/0/0
nhrp entry multicast dynamic

最后依次ospf宣告即可

#AR1/3/4
ospf 1 route-id 1.1.1.1/2.2.2.2/3.3.3.3
area 0
network 192.168.6.(1/2/3) 0.0.0.0#宣告tunnel地址
network 192.168.(1/4/5).1 0.0.0.0#宣告回环

但是出现了一个问题,在mgre中ospf的连接方式是p-2-p连接的,导致只会有其中两个路由器会进入full状态,另一个init状态,所以我们需要改为bma网路中的broadcast模式,即可

#三个都同样操作
int tunnel 0/0/0 
ospf network-type broadcast

星型拓扑:

同理上

#AR1
#
interface Tunnel0/0/1
 ip address 192.168.7.1 255.255.255.0 
 tunnel-protocol gre p2mp
 source 11.1.1.1
 ospf network-type broadcast
 nhrp entry multicast dynamic
#

#AR6
#
interface Tunnel0/0/1
 ip address 192.168.7.2 255.255.255.0 
 tunnel-protocol gre p2mp
 source GigabitEthernet0/0/0#写接口
 ospf network-type broadcast
 nhrp entry 192.168.7.1 11.1.1.1 register
#

#AR5
#
interface Tunnel0/0/0
 ip address 192.168.7.3 255.255.255.0 
 tunnel-protocol gre p2mp
 source GigabitEthernet0/0/0#写接口
 ospf network-type broadcast
 nhrp entry 192.168.7.1 11.1.1.1 register
#

值得注意的是,此处有两处不同,就是source写的是接口,而不是IP。这是因为星型拓扑的结构的接口ip有可能发生改变,所以直接写接口即可。

然后ospf宣告

#AR1
ospf 1
area 0
network 192.168.7.1 0.0.0.0

#AR3
ospf 1 route-id 4.4.4.4
area 0
network 192.168.7.2 0.0.0.0
network 192.168.2.1 0.0.0.0

#AR4
ospf 1 route-id 5.5.5.5
area 0
network 192.168.7.3 0.0.0.0
network 192.168.3.1 0.0.0.0

此时,由于ar5和ar6之间没有开启伪广播(没法写register和multicast),broadcast需要选出dr和bdr,所以对AR5来说,只有自己和AR1,对于AR1来说则是三台路由进行选举。所以需要改一下选择的优先级,使得其他的优先级为0,AR1为dr,无bdr即可。

#AR5/6
int tunnel 0/0/0
ospf dr-priority 0

成果:

AR1ping各自的私有IP

<r1>ping 192.168.2.1
  PING 192.168.2.1: 56  data bytes, press CTRL_C to break
    Reply from 192.168.2.1: bytes=56 Sequence=1 ttl=255 time=30 ms
...

<r1>ping 192.168.3.1
  PING 192.168.3.1: 56  data bytes, press CTRL_C to break
    Reply from 192.168.3.1: bytes=56 Sequence=1 ttl=255 time=20 ms
...

<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=20 ms
...

<r1>ping 192.168.5.1
  PING 192.168.5.1: 56  data bytes, press CTRL_C to break
    Reply from 192.168.5.1: bytes=56 Sequence=1 ttl=255 time=30 ms
...

<r3>ping 6.6.6.6
  PING 6.6.6.6: 56  data bytes, press CTRL_C to break
    Reply from 6.6.6.6: bytes=56 Sequence=1 ttl=255 time=10 ms
...

 这里可以在每一台路由器上面写上配置好nat用于私有地址访问公网IP,但由于私有地址我们用的是回环,不会进行地址转换,所以这里便不再配置nat,读者可以自行配置主机ip然后边界路由上面配置试试。

acl 2000
rule permit source 192.168.1.0 0.0.0.255
#接口上
nat outbound 2000

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值