上次(避免路由泄露,VPN实例流量怎么互通?)我们用子接口的方式是VRF内的流量进行了汇聚,确实少考虑了一种情况,那就是3个内网网关私网网段相同的场景。毕竟在公有云场景中,租户的私网网段重合是常事,那怎么解决呢?
很简单,加个NAT不就解决了。


RT1-RT3分别对应3个内网网关,内网网段相同,均为192.168.1.0/24网段。用户流量在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/1、GE0/2、GE5/0分别绑定VPN实例RT1、RT2和RT3。
对应的子接口下面增加nat outbound配置。
整体没有什么难点,直接上设备配置:

#sysname POP#ip vpn-instance RT111:1111:11 import-extcommunity11:11 export-extcommunity#ip vpn-instance RT222:2222:22 import-extcommunity22:22 export-extcommunity#ip vpn-instance RT333:3333:33 import-extcommunity33:33 export-extcommunity#interface GigabitEthernet0/0ip binding vpn-instance RT1ip address 192.168.1.1 255.255.255.0#interface GigabitEthernet0/1ip binding vpn-instance RT2ip address 192.168.1.1 255.255.255.0#interface GigabitEthernet0/2ip binding vpn-instance RT3ip address 192.168.1.1 255.255.255.0#interface GigabitEthernet5/0.1ip binding vpn-instance RT1ip address 10.2.1.2 255.255.255.0nat outbound vpn-instance RT1dot1q vid 10#interface GigabitEthernet5/0.2ip binding vpn-instance RT2ip address 10.2.2.2 255.255.255.0nat outbound vpn-instance RT2dot1q vid 20#interface GigabitEthernet5/0.3ip binding vpn-instance RT3ip address 10.2.3.2 255.255.255.0nat outbound vpn-instance RT3dot1q vid 30#ip route-static vpn-instance RT1 0.0.0.0 0 10.2.1.1ip route-static vpn-instance RT2 0.0.0.0 0 10.2.2.1ip route-static vpn-instance RT3 0.0.0.0 0 10.2.3.1

#interface GigabitEthernet0/0.1ip address 10.2.1.1 255.255.255.0vlan-type dot1q vid 10#interface GigabitEthernet0/0.2ip address 10.2.2.1 255.255.255.0vlan-type dot1q vid 20#interface GigabitEthernet0/0.3ip address 10.2.3.1 255.255.255.0vlan-type dot1q vid 30#interface GigabitEthernet0/1ip address 10.3.1.2 255.255.255.0nat outbound

#interface GigabitEthernet0/0ip address 10.3.1.1 255.255.255.0


此时我们先查看POP设备的VRF路由表信息。

在查看GW设备的路由表信息,因为在POP设备上开启了NAT,所以GW设备上也就不需要添加静态路由了,配置量有所降低。

分别从RT1-RT3设备上PING测SRV设备,查看连通性。

访问都是正常的。

看一下转发路径。

和上次的方案对比一下,可以发现今天的方案有两个改进的地方。
1、配置同样是主要集中在POP设备上,这次GW设备上不需要增加回程路由了,工作量有少量减少。
2、之前的两个方案都需要增加限制策略限制互访,而使用了NAT之后,不需要再做额外的限制,对于私网网段是相同的还是不同的也不再关注。
不过有一个配置的关键点需要注意,你可能也发现了,配置NAT的命令是nat outbound vpn-instance RT1,增加VPN实例名称用于指定地址组中的地址所属的VPN实例。如果不指定VPN实例名称,则表示地址组中的地址不属于任何一个VPN实例,也就是NAT会话在全局表项中,报文可以出去,但回就回不来了。通过debug可以看到。

当然,NAT指定VPN实例也可以实现流量的跨VRF互访,这不是本次研究的重点,就不再赘述了