28
2025
03
15:30:25

VRF路由泄露了!

学网络的时候就总是听到有人说VRF什么的,因为华三的配置里面极少见到这个东西,一般都是说VPN实例,所以我一直以为只有思科才叫VRF。

其实在MPLS L3VPN或其他场景中,不同VPN之间的路由隔离一般通过VPN实例(VPN-instance)实现,VPN实例又称为VRF(Virtual Routing and Forwarding,虚拟路由和转发)实例。设备上每个VPN实例都有相对独立的路由表和FIB(Forwarding Information Base,转发信息库),确保VPN数据的独立性和安全性。

碰巧我最近遇到了一个这样的问题,如果在POP接入侧为每个接入用户都分配了单独的VPN实例,那怎么实现集中访问公网呢?

后来我就开始在网上冲浪,最终发现了一个被称为路由泄露的东西。

组网需求

RT1-RT3分别对应3个内网网关,用户流量在POP上通过VRF进行隔离,同时需要经过GW设备访问SRV服务器。

组网图

VRF路由泄露组网图。

实验环境

Windows 10专业版(1909-18363.1556,16 GB内存)

HCL 3.0.1

MSR 36-20(Version 7.1.064, Release 0821P11)

配置步骤

首先按照组网图所示配置各接口的IP地址和掩码,其中POP设备的接口GE0/0、GE0/1、GE0/2分别绑定VPN实例RT1、RT2和RT3。

基础设备配置如下:

RT1





#interface GigabitEthernet0/0 ip address 10.1.1.2 255.255.255.0#ip route-static 0.0.0.0 0 10.1.1.1
RT2





#interface GigabitEthernet0/0 ip address 10.1.2.2 255.255.255.0#ip route-static 0.0.0.0 0 10.1.2.1
RT3





#interface GigabitEthernet0/0 ip address 10.1.3.2 255.255.255.0#ip route-static 0.0.0.0 0 10.1.3.1
POP




































#ip vpn-instance RT1 route-distinguisher 11:11 vpn-target 11:11 import-extcommunity vpn-target 11:11 export-extcommunity#ip vpn-instance RT2 route-distinguisher 22:22 vpn-target 22:22 import-extcommunity vpn-target 22:22 export-extcommunity#ip vpn-instance RT3 route-distinguisher 33:33 vpn-target 33:33 import-extcommunity vpn-target 33:33 export-extcommunity#ip vpn-instance POP route-distinguisher 44:44 vpn-target 44:44 import-extcommunity vpn-target 44:44 export-extcommunity#interface GigabitEthernet0/0 ip binding vpn-instance RT1 ip address 10.1.1.1 255.255.255.0#interface GigabitEthernet0/1 ip binding vpn-instance RT2 ip address 10.1.2.1 255.255.255.0#interface GigabitEthernet0/2 ip binding vpn-instance RT3 ip address 10.1.3.1 255.255.255.0#interface GigabitEthernet5/0 ip binding vpn-instance POP ip address 10.2.1.2 255.255.255.0
GW









#interface GigabitEthernet0/0 ip address 10.2.1.1 255.255.255.0#interface GigabitEthernet0/1 ip address 10.3.1.2 255.255.255.0 nat outbound#ip route-static 10.1.0.0 16 10.2.1.2
SRV



#interface GigabitEthernet0/0 ip address 10.3.1.1 255.255.255.0

此时我们查看设备接口都是正常的,但是查看路由表项却一条都没有了。

如果我们从POP上请求SRV,将是不通的,因为上行口GE5/0绑定了VPN实例,所以要把路由添加到VPN实例POP中。



#ip route-static vpn-instance POP 0.0.0.0 0 10.2.1.1

查看路由表和执行ping命令时都要带VPN实例,如下所示。

然后就是配置路由泄露,其实就是在一个VPN示例中添加另一个VPN实例的下一跳,比如在VPN实例RT1中添加去往SRV的默认路由。



#ip route-static vpn-instance RT1 0.0.0.0 0 vpn-instance POP 10.2.1.1

对应的,也要在VPN实例POP中添加回程路由。



#ip route-static vpn-instance POP 10.1.1.0 24 vpn-instance RT1 10.1.1.2

现在,从RT1上就能正常访问SRV了。

同理,再增加VPN实例RT2、RT3和POP之间的互访路由。






#ip route-static vpn-instance RT2 0.0.0.0 0 vpn-instance POP 10.2.1.1ip route-static vpn-instance RT3 0.0.0.0 0 vpn-instance POP 10.2.1.1ip route-static vpn-instance POP 10.1.2.0 24 vpn-instance RT2 10.1.2.2ip route-static vpn-instance POP 10.1.3.0 24 vpn-instance RT3 10.1.3.2

现在RT2和RT3都能正常访问SRV了。

但是也有了一个新的问题,那就是RT1、RT2和RT3也能互访了,这让VPN实例变得没有意义了。

tracert查看一下转发路径。

我们发现RT1和RT3之间的互访是由GW实现的,那我们在GW设备的接口GE0/0上加一个包过滤行不行呢?








#acl advanced 3402 rule 0 deny ip source 10.1.0.0 0.0.255.255 destination 10.1.0.0 0.0.255.255#interface GigabitEthernet0/0 ip address 10.2.1.1 255.255.255.0 packet-filter 3402 inbound

测试看一下,可以发现访问访问SRV不受影响,RT1不能访问RT2了。

对比直接把过滤配置在POP入接口上的方案,把过滤配置在GW入接口上,配置工作量更小,同时可以支持POP接入网段的扩大。




推荐本站淘宝优惠价购买喜欢的宝贝:

image.png

本文链接:https://hqyman.cn/post/9903.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:
打赏





休息一下~~


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

请先 登录 再评论,若不是会员请先 注册

您的IP地址是: