防火墙旁挂部署二选一:详解单臂/双臂方案,避坑策略一看就懂!

假设有这样一张网络,某企业有两个办公站点,均具备公网IP地址,两个站点之间建立了GRE隧道,使得两张办公网之间可以通过内网互相访问。
现在出于安全考虑,需要在站点1增加一台防火墙设备,使得两个内网之间互放的流量均经过防火墙进行安全防护。为减小对业务的影响,防火墙设备采用旁挂在出口路由器的部署方式,配置引流实现互访流量经过防火墙设备。
一般来讲,以旁挂方式部署防火墙设备有两种方式,一种是双臂旁挂,如下图所示:

另一种是单臂旁挂,如下图所示:

首先,我们先参考之前的GRE配置完成PC1和PC2之间的互通(GRE隧道也能实现两端配置相同子网了,快来看看!)。
RT1
#
interface GigabitEthernet0/0
ip address 10.1.1.1255.255.255.0
#
interface GigabitEthernet0/1
ip address 12.1.1.1255.255.255.0

interface Tunnel0 mode gre
ip address 10.13.1.1255.255.255.0
source 12.1.1.1
destination 23.1.1.3
#
ip route-static 10.2.1.02410.13.1.3
ip route-static 23.1.1.02412.1.1.2
ISP
#
interface GigabitEthernet0/0
ip address 12.1.1.2255.255.255.0
#
interface GigabitEthernet0/1
ip address 23.1.1.2255.255.255.0
RT2
#
interface GigabitEthernet0/0
ip address 10.2.1.1255.255.255.0
#
interface GigabitEthernet0/1
ip address 23.1.1.3255.255.255.0
#
interface Tunnel0 mode gre
ip address 10.13.1.3255.255.255.0
source 23.1.1.3
destination 12.1.1.1
#
ip route-static 10.1.1.02410.13.1.1
ip route-static 12.1.1.02423.1.1.2
PC1
#
interface GigabitEthernet0/0
ip address 10.1.1.2255.255.255.0
#
ip route-static 0.0.0.0010.1.1.1
PC2
#
interface GigabitEthernet0/0
ip address 10.2.1.2255.255.255.0

ip route-static 0.0.0.0010.2.1.1
我们测试一下PC1和PC2之间的互访。

可以看到,流量的转发路径为PC1→RT1→RT2→PC2,与设想情况一致。
接下来,如果要使用双臂旁挂,我们要先配置RT1和FW之间的互通。
RT1
#
interface GigabitEthernet0/2
ip address 10.1.2.1255.255.255.0
#
interface GigabitEthernet5/0
ip address 10.1.3.1255.255.255.0
FW
#
interface GigabitEthernet1/0/0
ip address 10.1.2.2255.255.255.0
#
interface GigabitEthernet1/0/1
ip address 10.1.3.2255.255.255.0
然后使用路由方式指导路由的转发就行了,比如说我们让互访的流量均通过10.1.2.0/24这个网段上行到FW,再通过10.1.3.0/24这个网段回到RT1。配置时,我们建议先配置FW的路由:
#
iproute-static 10.1.1.0 24 10.1.3.1
iproute-static 10.2.1.0 24 10.1.3.1
当然,使用默认路由配置也是可以的。
然后,就需要调整RT1的流量走向了,需要让PC1访问PC2的流量先经过防火墙,当防火墙转发回来之后再经过GRE隧道转发给RT2。这种配置需要使用策略路由来实现(一条100M宽带 + 一条200M宽带 = 300M,怎么就有人不信呢?),RT1的配置如下:
#
acl advanced 3401
description PC1-PC2
rule 0 permit ip source 10.1.1.00.0.0.255 destination 10.2.1.00.0.0.255
#
policy-based-route fw1 permit node 10
if-match acl 3401
apply next-hop 10.1.2.2
#
interface GigabitEthernet0/0
ip policy-based-route fw1
正常来讲,我们需要将配置的策略应用到报文的接口上,指导接口对接收报文的转发。在本例中,报文从GE0/0接口进来之后,由GE0/2接口出,再从GE5/0接口进来,之后就可以正常查表转发了;但是,模拟器的实际情况是,会出现路由环路,应该是实现有问题。不过,我们仍然可以在防火墙接口上配置NAT,改变报文源地址,使处理完的报文不再命中策略路由;对应的,需要在RT2上配置一条到防火墙的明细路由。
配置完成之后,我们看一下PC1访问PC2的流量转发情况。

可以看到,流量的转发路径为PC1→RT1→FW→RT1→RT2→PC2,与设想情况一致。
对应的,我们把PC2访问PC1的策略也配置一下。
#
acladvanced 3402
descriptionPC2-PC1
rule 0 permitipsource 10.2.1.0 0.0.0.255destination 10.1.1.0 0.0.0.255
#
policy-based-routefw2permitnode 10
if-matchacl 3402
applynext-hop 10.1.2.2

interfaceTunnel0modegre
ippolicy-based-routefw2
配置完成之后,我们看一下PC2访问PC1的流量转发情况。

可以看到,流量的转发路径为PC2→RT2→RT1→FW→RT1→PC2,与设想情况一致。
以上就是双臂旁挂的情况,其实在策略路由实现机制有问题的情况下,使用单臂旁挂会更简洁。
RT1
#
policy-based-routefw1 permit node 10
if-matchacl 3401
applynext-hop 10.1.2.2
#
policy-based-routefw2 permit node 10
if-matchacl 3402
applynext-hop 10.1.2.2
#
interfaceGigabitEthernet0/0
ippolicy-based-route fw1
#
interfaceTunnel0 mode gre
ippolicy-based-route fw2
#
acladvanced 3401
descriptionPC1-PC2
rule0 permit ip source 10.1.1.0 0.0.0.255 destination 10.2.1.0 0.0.0.255
#
acladvanced 3402
descriptionPC2-PC1
rule0 permit ip source 10.2.1.0 0.0.0.255 destination 10.1.1.0 0.0.0.255
RT2
#
iproute-static 10.1.2.0 24 10.13.1.1
FW
#
interface GigabitEthernet1/0/0
ip address 10.1.2.2255.255.255.0
nat outbound
#
ip route-static 0.0.0.0010.1.2.1
配置完成之后,我们再看一下PC1访问PC2的流量转发情况。

可以看到,流量的转发路径为PC1→RT1→FW→RT1→RT2→PC2,与设想情况一致。
再看一下PC2访问PC1的流量转发情况。

可以看到,流量的转发路径为PC2→RT2→RT1→FW→RT1→PC2,与设想情况一致。
经历过双臂旁挂的曲折,我们不难发现,单臂旁挂的方案堪称化繁为简的典范。它减少了物理链路,降低了配置复杂度,有效避免了前述的环路风险,实在是一招鲜,吃遍天的实用技巧。怎么样,是不是很简单呢?

声明:来自铁军哥,仅代表创作者观点。链接:https://eyangzhen.com/6331.html

铁军哥的头像铁军哥

相关推荐

添加微信
添加微信
Ai学习群
返回顶部