缺省情况下,VPN实例的路由信息和公共实例中的路由信息是不能互通的,为了实现互通,前面对比了VRF路由泄露的几种方式,有手工配置静态路由引入的(震惊!VRF路由泄露了!),还有使用子接口做MCE的(避免路由泄露,VPN实例流量怎么互通?),后来还使用NAT做了改进(VRF + 子接口 + NAT,改进大不大?)。
最近在研究MPLS相关配置的时候意外发现设备还支持VPN实例间的路由信息引入,支持引入直连路由、静态路由、协议路由(ISIS、OSPF、RIP)还有BGP等等,同时支持配置路由策略,那这岂不是能省不少事。
同时配置还特别简单,如果是需要将指定VPN实例的路由信息引入到公网中,从而使公网获取指定VPN的路由,那就在公共实例下配置引入即可,示例如下:
#
ip public-instance
#
address-family ipv4
route-replicate from vpn-instance RT1 protocol ospf 1
而如果是需要将公网或其他VPN实例的路由信息引入到指定VPN实例中,那就在指定VPN实例下配置引入即可,示例如下:
#
ip vpn-instance vpn1
#
address-family ipv4
route-replicate frompublic protocol ospf 1
组网需求
RT1-RT3分别对应3个内网网关,内网网段相同,均为192.168.1.0/24网段。用户流量在POP上通过VRF进行隔离,同时需要经过GW设备访问SRV服务器。
组网图
VPN实例间路由引入组网图。
实验环境
Windows 10专业版(1909-18363.1556,16 GB内存)
HCL 3.0.1
MSR 36-20(Version 7.1.064, Release 0821P11)
配置步骤
参考命令特性,像这种不同租户的流量被划分到不同的VPN中,同时租户流量有需要访问公网的场景,需要配置将公网的路由信息引入到指定VPN实例中。正常来讲肯定是建议使用动态路由 + 路由策略进行引入的,此处作为演示,就直接引入直连路由和静态路由了。
这么看整体上就没有什么难点了,直接上设备配置:
POP
#
sysnamePOP
#
ipvpn-instance RT1
route-distinguisher11:11
vpn-target11:11 import-extcommunity
vpn-target11:11 export-extcommunity
#
address-familyipv4
route-replicatefrom public protocol direct
route-replicatefrom public protocol static
#
ipvpn-instance RT2
route-distinguisher22:22
vpn-target22:22 import-extcommunity
vpn-target22:22 export-extcommunity
#
address-familyipv4
route-replicatefrom public protocol direct
route-replicatefrom public protocol static
#
ipvpn-instance RT3
route-distinguisher33:33
vpn-target33:33 import-extcommunity
vpn-target33:33 export-extcommunity
#
address-family ipv4
route-replicatefrom public protocol direct
route-replicatefrom public protocol static
#
interfaceGigabitEthernet0/0
ipbinding vpn-instance RT1
ipaddress 192.168.1.1 255.255.255.0
#
interfaceGigabitEthernet0/1
ip binding vpn-instance RT2
ip address 192.168.1.1 255.255.255.0
#
interfaceGigabitEthernet0/2
ipbinding vpn-instance RT3
ipaddress 192.168.1.1 255.255.255.0
#
interfaceGigabitEthernet5/0
ipaddress 12.1.1.1 255.255.255.0
#
iproute-static 23.1.1.0 24 12.1.1.2
GW
#
sysnameGW
#
interfaceGigabitEthernet0/0
ipaddress 12.1.1.2 255.255.255.0
#
interfaceGigabitEthernet0/1
ipaddress 23.1.1.2 255.255.255.0
natoutbound
SRV
#
sysname SRV
#
interface GigabitEthernet0/0
ip address 23.1.1.3255.255.255.0
验证配置
我们先查看POP设备的VRF路由表信息。
可以看到已经有引入的路由条目了,分别是接口G5/0的直连路由和全局的静态路由。现在测试一下RT1的访问情况。
发现无法正常访问,我们从POP设备上debug看一下。
可以看到收包正常,发包也是正常的。但是再接着往下来,就不正常了。
从公共实例中没有到RT1的转发表项,到RT1的转发表项在VPN实例中。
那就只能是再从公共实例中引入一遍了。https://wxa.wxs.qq.com/tmpl/mg/base_tmpl.html
#
ip public-instance
#
address-family ipv4
route-replicate from vpn-instance RT1 protocol direct
加上这个配置到POP设备上的接口地址就通了。
但是再往后走又不通了,问题是一样的,远端设备也是缺少回程路由。
这次在POP设备上行口配置NAT来解决。
#
interface GigabitEthernet5/0
ip address 12.1.1.1255.255.255.0
nat outbound
不过现在有个问题,那就是3个VRF的私网网段是相同的,能实现全部访问SRV设备吗?
可以看到能够正常访问,那为啥没有冲突呢?
通过debug ip packet和nat packet可以看到,设备在转发报文时,给每个会话或者说是每条流都有对应的VPN实例记录,本案例中RT2对应的编号是2,全局公共实例对应的编号是0。这样以来,即使租户网络地址重叠也没有影响了。
再和之前的方案对比一下,该方案不需要增加接口,每当有新的租户接上来时,只要对应的配置VPN实例间的路由引入即可。再说了,动态路由就是要比手工配置的静态路由高级不是?
额外提醒一下,通过本文的方法引入的路由默认是不允许再发布的,如果需要发布,需要配置advertise参数,以允许发布引入的路由。示例如下:
route-replicate from vpn-instance RT1 protocol direct advertise
声明:来自铁军哥,仅代表创作者观点。链接:https://eyangzhen.com/1398.html