防火墙虚拟系统——租户隔离

拓扑图

实验需求

  1. VLAN10,VLAN20业务隔离,可以访问server且流量经过自身的防火墙
  2. OSPF区域规划如上图
  3. VLAN10,VLAN20租户流量有互访的需求,需要经过各自的防火墙且路径最优

配置

基础配置

SW1配置:

  • VRF,隔离用户
  • 链路聚合
  • 相关vlan及vlanif
  • OSPF多VPN实例,使流量走自己的虚墙
sysname SW1
#
vlan batch 10 20 100 121 to 124
#
lacp priority 16384
#
ip vpn-instance VRF_A
 ipv4-family
#
ip vpn-instance VRF_B
 ipv4-family
#
interface Vlanif10
 ip binding vpn-instance VRF_A
 ip address 10.1.10.254 255.255.255.0
#
interface Vlanif20
 ip binding vpn-instance VRF_B
 ip address 10.1.20.254 255.255.255.0
#
interface Vlanif100
 ip address 10.1.100.254 255.255.255.0
#
interface Vlanif121
 ip binding vpn-instance VRF_A
 ip address 10.1.121.254 255.255.255.0
#
interface Vlanif122
 ip address 10.1.122.254 255.255.255.0
#
interface Vlanif123
 ip binding vpn-instance VRF_B
 ip address 10.1.123.254 255.255.255.0
#
interface Vlanif124
 ip address 10.1.124.254 255.255.255.0
#
interface Eth-Trunk1
 port link-type trunk
 port trunk allow-pass vlan 121 to 124
 mode lacp-static
 trunkport GigabitEthernet 0/0/10 0/0/11
#
interface GigabitEthernet0/0/1
 port link-type access
 port default vlan 100
#
interface GigabitEthernet0/0/2
 port link-type access
 port default vlan 10
#
interface GigabitEthernet0/0/3
 port link-type access
 port default vlan 20
#
ospf 10 router-id 10.1.121.254 vpn-instance VRF_A
 silent-interface Vlanif10
 area 0.0.0.1
  network 10.1.121.254 0.0.0.0
  network 10.1.10.254 0.0.0.0
#
ospf 20 router-id 10.1.123.254 vpn-instance VRF_B
 silent-interface Vlanif20
 area 0.0.0.2
  network 10.1.20.254 0.0.0.0
  network 10.1.123.254 0.0.0.0
#
ospf 100 router-id 10.1.100.100
 silent-interface Vlanif100
 area 0.0.0.0
  network 10.1.100.254 0.0.0.0
 area 0.0.0.1
  network 10.1.122.254 0.0.0.0
 area 0.0.0.2
  network 10.1.124.254 0.0.0.0
#

FW配置:

  • 开启虚拟系统
  • 配置将相应vlan分配到虚墙
  • 接口划到相应安全区域
  • OSPF
  • 安全策略local->any
sysname FW1
#
vlan batch 121 to 124
#
vsys enable
#
vsys name VRF_A 1
 assign vlan 121
 assign vlan 122
#
vsys name VRF_B 2
 assign vlan 123
 assign vlan 124
#
interface Vlanif121
 ip address 10.1.121.253 255.255.255.0
#
interface Vlanif122
 ip address 10.1.122.253 255.255.255.0
#
interface Vlanif123
 ip address 10.1.123.253 255.255.255.0
#
interface Vlanif124
 ip address 10.1.124.253 255.255.255.0
#
interface Eth-Trunk1
 portswitch
 port link-type trunk
 port trunk allow-pass vlan 121 to 124
 mode lacp-static
 trunkport GigabitEthernet 1/0/0 1/0/1
#
ospf 10 router-id 10.1.121.253 vpn-instance VRF_A
 area 0.0.0.1
  network 10.1.121.253 0.0.0.0
  network 10.1.122.253 0.0.0.0
#
ospf 20 router-id 10.1.123.253 vpn-instance VRF_B
 area 0.0.0.2
  network 10.1.123.253 0.0.0.0
  network 10.1.124.253 0.0.0.0
#
switch vsys VRF_A
#
sy
#
firewall zone trust
 add interface Vlanif121
#
firewall zone untrust
 add interface Vlanif122
#
security-policy
 rule name local->any
  source-zone local
  action permit
#
return
#
sy
#
switch vsys VRF_B
#
sy
#
firewall zone trust
 add interface Vlanif123
#
firewall zone untrust
 add interface Vlanif124
#
security-policy
 rule name local->any
  source-zone local
  action permit
#


 

FW1上查看OSPF邻居

FW1上查看路由

 SW1上查看OSPF邻居

SW1上查看public路由

SW1上VPN实例VRF_A的路由

SW1上VPN实例VRF_B的路由

OSPF邻居已正常建立,下面继续配置,使PC1和PC2可以访问Server

配置VLAN10和VLAN20的PC访问Server

FW1中到各自的虚墙配置安全策略

FW1:

switch vsys VRF_A
#
sy
#
security-policy
 rule name trust->untrust
  source-zone trust
  destination-zone untrust
  source-address 10.1.10.1 mask 255.255.255.255
  destination-address 10.1.100.1 mask 255.255.255.255
  action permit
#
return
#
sy
#
switch vsys VRF_B
#
sy
#
security-policy
 rule name trust->untrust
  source-zone trust
  destination-zone untrust
  source-address 10.1.20.1 mask 255.255.255.255
  destination-address 10.1.100.1 mask 255.255.255.255
  action permit
#

配置完了安全策略,先不急着测试访问Server,先看一下路由表(细心的小伙伴应该从上面的路由截图中发现了),VPN实例中并没有区域间的网段的路由。

以PC1所在的VRF_A举例,确实没有发现100网段的路由

按照正常的LSA传递,100网段的路由会由区域0中的1类和2类LSA计算,并以3类LSA传递给防火墙的虚拟系统VRF_A,然后在传递到交换机的VRF_A实例中,既然是这样,我们看一下防火墙和交换机的OSPF的LSDB中是否存在100网段的3类LSA。

从上图可以看出,我们想的没错,OSPF的LSDB中确实收到了100网段的3类LSA,但是并没有去计算路由,因为在FW和SW1上开启了VPN-Instance,从而触发了OSPF多实例下的3类LSA防环,只是将3类LSA放到了LSDB中,并未计算路由,因此,FW和SW1关闭VPN实例防环检测。

FW1、SW1:

ospf 10 
 vpn-instance-capability simple
#
ospf 20 
 vpn-instance-capability simple
#

关闭防环之后,再来查看路由表,发现有了100网段的路由

此时测试PC1 ping Server,可以访问

PC1 ping PC2,虽然有路由,但由于安全策略,不能访问,实现了隔离

PC2与Server、PC1的访问同理。

配置VLAN10与VLAN20的PC的互访

如果两个租户属于不同的公司,没有业务上的往来,通过VRF确实实现了租户的隔离。但是如果VRF_A和VRF_B两个实例是一个公司的两个不同业务,在不同VRF的大部分机器需要隔离,但某些服务器可能需要通信,该如何实现?

从上面PC1 ping PC2可以知道,虽然有路由,但是由于安全策略没有放行,流量到防火墙被丢弃

那么在虚墙上配置安全策略放行流量即可实现互访

FW1:

switch vsys VRF_A
#
sy
#
security-policy
 rule name trust->untrust
  destination-address 10.1.20.1 mask 255.255.255.255
  action permit
 rule name untrust->trust
  source-zone untrust
  destination-zone trust
  source-address 10.1.20.1 mask 255.255.255.255
  destination-address 10.1.10.1 mask 255.255.255.255
  action permit
#
return
#
sy
#
switch vsys VRF_B
#
sy
#
security-policy
 rule name trust->untrust
  destination-address 10.1.10.1 mask 255.255.255.255
 rule name untrust->trust
  source-zone untrust
  destination-zone trust
  source-address 10.1.10.1 mask 255.255.255.255
  destination-address 10.1.20.1 mask 255.255.255.255
  action permit
#

配置完安全策略后,测试PC1 ping PC2,可以通信

再查看下访问的路径

先开启FW的icmp的ttl超时响应

FW1:

icmp ttl-exceeded send 
#

pc1 tracert PC2,可以看到并非是最优路径

注:路由学习方向为数据流量的反方向

可以看到PC1访问PC2,流量经过虚墙VRF_A—>SW—>虚墙VRF_B到达PC2,但实际上的最优路径为虚墙VRF_A—>虚墙VRF_B到达PC2,无需绕行SW

看到这里,要实现PC互访的最优路径,可以配置静态路由达到虚拟系统的直接互访的目的

配置虚拟系统之间互访的路由,需要在根系统下配置

另一点需要把virtual-if1和virtual-if2接口加入到untrust安全区域中

FW1:

ip route-static vpn-instance VRF_A 10.1.20.1 32 vpn-instance VRF_B 
ip route-static vpn-instance VRF_B 10.1.10.1 32 vpn-instance VRF_A
#
switch vsys VRF_A
#
sy
#
firewall zone untrust
 add interface Virtual-if1
#
return
#
sy
#
switch vsys VRF_B
#
sy
#
firewall zone untrust
 add interface Virtual-if2
#

查看路由表

再次PC1 tracert PC2,路径已切换到规划的最优路径

PC2 访问PC1同理。

补充

上面的实验实现最优路径,配置的是32位的主机路由,有的小伙伴会问,如果我配置成24位掩码的静态路由可不可以.....当然也是可以的,但是配置会稍微复杂一些。

我们先去掉之前的32位掩码的主机路由,重新配置24位掩码的静态路由

FW1:

undo ip route-static vpn-instance VRF_A 10.1.20.1 255.255.255.255 vpn-instance VRF_B
undo ip route-static vpn-instance VRF_B 10.1.10.1 255.255.255.255 vpn-instance VRF_A
#
ip route-static vpn-instance VRF_A 10.1.20.0 255.255.255.0 vpn-instance VRF_B
ip route-static vpn-instance VRF_B 10.1.10.0 255.255.255.0 vpn-instance VRF_A
#

再次查看路由表,20网段的路由并不是静态路由,而是OSPF路由

由于优先级OSPF为10,静态为60,所以静态路由为Inactive

以PC1访问PC2为例,看下20网段的路由是如何学习的(PC2访问PC1的路由同理)

看一下路由是如何学习的

从图中看出,要让静态路由加表,只要不让20网段的3类LSA传给虚墙VRF_A或不让其加入路由表即可

在SW1上过滤掉20网段的3类LSA

SW1:

ip ip-prefix net20 deny 10.1.20.0 24
ip ip-prefix net20 permit 0.0.0.0 0 less-equal 32
#
ospf 100 router-id 10.1.100.100
 area 0.0.0.1
  filter ip-prefix net20 import
#

查看路由,已经有OSPF变为静态

在查看LSDB中,已经没有了20网段的3类LSA,说明确实被过滤掉了

既然过滤掉了3类LSA,那么FW的LSDB中没有了20网段的3类LSA,也就是说FW传递给交换机的LSA中也没有20网段的3类LSA

查看交换机OSPF进程10的LSDB

那么交换机的路由表中也不会存在20网段的路由

我们还需要在防火墙上将配置的静态引入到OSPF中

FW1:

ospf 10 
 import-route static
#

再次查看交换机的路由表,20网段的路由以外部路由的形式出现

同理,我们需要让虚墙VRF_B中的路由表中加入配置的静态,此处我们在FW上禁止10.1.10.0/24的OSPF路由加表,从而让静态路由加表

FW1:

ip ip-prefix net10 index 10 deny 10.1.10.0 24
ip ip-prefix net10 index 20 permit 0.0.0.0 0 less-equal 32
#
ospf 20
 filter-policy ip-prefix net10 import
#

查看虚墙VRF_B的路由表,静态路由已经加表

由于并没有过滤掉3类LSA,只是阻止10网段路由加表,所以交换机的OSPF 20进程的LSDB中仍然有10网段的3类LSA,并且存在于路由表中

测试PC1 tracert PC2,路径达到最优

同理PC2 tracert PC1,路径达到最优

  • 21
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值