示例:使用基于过滤器的转发将应用程序流量路由到安全设备
此示例介绍如何在 EX 系列交换机或QFX10000上设置基于过滤器的转发。您可以使用防火墙过滤器配置基于过滤器的转发,以将匹配的流量转发到特定的虚拟路由实例。
要求
此示例适用于运行 Junos OS 9.4 或更高版本的 EX 系列交换机,以及运行 Junos OS 15.1X53-D10 或更高版本的QFX10000交换机。
概述和拓扑
在此示例中,我们创建一个防火墙过滤器,以根据出口源应用程序服务器的数据包的目标地址 (192.168.0.1) 匹配从一个应用程序服务器发送到另一个应用程序服务器的流量。匹配的数据包被路由到虚拟路由实例,该实例将流量转发到安全设备,然后安全设备将流量转发到目标应用程序服务器。
基于过滤器的转发不适用于某些瞻博网络交换机上的 IPv6 接口。
配置
要配置基于过滤器的转发,请执行以下操作:
CLI 快速配置
要在您自己的设备上使用此示例,请将以下命令复制到文本文件中,删除换行符,然后更改必要的详细信息以适合您的配置。然后将命令复制并粘贴到层次结构级别的 CLI [edit]
中。
[edit] set interfaces xe-0/0/0 unit 0 family inet address 10.1.0.1/24 set interfaces xe-0/0/3 unit 0 family inet address 10.1.3.1/24 set firewall family inet filter f1 term t1 from source-address 10.1.0.50/32 set firewall family inet filter f1 term t1 from protocol tcp set interfaces xe-0/0/0 unit 0 family inet filter input f1 set routing-instances vrf01 instance-type virtual-router set routing-instances vrf01 interface xe-0/0/3.0 set routing-instances vrf01 routing-options static route 192.168.0.1/24 next-hop 10.1.3.254 set firewall family inet filter f1 term t1 then routing-instance vrf01
程序
分步过程
要配置基于过滤器的转发,请执行以下操作:
配置接口以连接到应用程序服务器:
[edit interfaces] user@switch# set xe-0/0/0 unit 0 family inet address 10.1.0.1/24
配置接口以连接到安全设备:
[edit interfaces] user@switch# set xe-0/0/3 unit 0 family inet address 10.1.3.1/24
创建防火墙过滤器,该过滤器根据将发送流量的应用程序服务器的地址匹配数据包。同时配置过滤器,使其仅匹配 TCP 数据包:
[edit firewall] user@switch# set family inet filter f1 term t1 from source-address 10.1.0.50/32 user@switch# set firewall family inet filter f1 term t1 from protocol tcp
将过滤器应用于连接到源应用程序服务器的接口,并将其配置为匹配传入数据包:
[edit interfaces] user@switch# set xe-0/0/0 unit 0 family inet filter input f1
创建虚拟路由器:
[edit] user@switch# set routing-instances vrf01 instance-type virtual-router
将虚拟路由器与连接到安全设备的接口相关联:
[edit routing-instances] user@switch# set vrf01 interface xe-0/0/3.0
配置虚拟路由实例的路由信息:
[edit routing-instances] user@switch# set vrf01 routing-options static route 192.168.0.1/24 next-hop 10.1.3.254
设置过滤器以将数据包转发到虚拟路由器:
[edit firewall] user@switch# set family inet filter f1 term t1 then routing-instance vrf01
结果
检查配置结果:
user@switch> show configuration interfaces { xe-0/0/0 { unit 0 { family inet { filter { input f1; } address 10.1.0.1/24; } } } xe-0/0/3 { unit 0 { family inet { address 10.1.3.1/24; } } } } firewall { family inet { filter f1 { term t1 { from { source-address { 10.1.0.50/32; } protocol tcp; } then { routing-instance vrf01; } } } } } routing-instances { vrf01 { instance-type virtual-router; interface xe-0/0/3.0; routing-options { static { route 192.168.0.1/24 next-hop 10.1.3.254; } } } }
验证
要确认配置工作正常,请执行以下任务:
验证是否配置了基于过滤器的转发
目的
验证交换机上是否正确启用了基于过滤器的转发。
操作
show interfaces filters
使用以下命令:user@switch> show interfaces filters xe-0/0/0.0 Interface Admin Link Proto Input Filter Output Filter xe-0/0/0.0 up down inet fil
show route forwarding-table
使用以下命令:user@switch> show route forwarding-table Routing table: default.inet Internet: Destination Type RtRef Next hop Type Index NhRef Netif default user 1 0:12:f2:21:cf:0 ucst 331 4 me0.0 default perm 0 rjct 36 3 0.0.0.0/32 perm 0 dscd 34 1 10.1.0.0/24 ifdn 0 rslv 613 1 xe-0/0/0.0 10.1.0.0/32 iddn 0 10.1.0.0 recv 611 1 xe-0/0/0.0 10.1.0.1/32 user 0 rjct 36 3 10.1.0.1/32 intf 0 10.1.0.1 locl 612 2 10.1.0.1/32 iddn 0 10.1.0.1 locl 612 2 10.1.0.255/32 iddn 0 10.1.0.255 bcst 610 1 xe-0/0/0.0 10.1.1.0/26 ifdn 0 rslv 583 1 vlan.0 10.1.1.0/32 iddn 0 10.1.1.0 recv 581 1 vlan.0 10.1.1.1/32 user 0 rjct 36 3 10.1.1.1/32 intf 0 10.1.1.1 locl 582 2 10.1.1.1/32 iddn 0 10.1.1.1 locl 582 2 10.1.1.63/32 iddn 0 10.1.1.63 bcst 580 1 vlan.0 255.255.255.255/32 perm 0 bcst 32 1 Routing table: vrf01.inet Internet: Destination Type RtRef Next hop Type Index NhRef Netif default perm 0 rjct 559 2 0.0.0.0/32 perm 0 dscd 545 1 10.1.3.0/24 ifdn 0 rslv 617 1 xe-0/0/3.0 10.1.3.0/32 iddn 0 10.1.3.0 recv 615 1 xe-0/0/3.0 10.1.3.1/32 user 0 rjct 559 2 192.168.0.1/24 user 0 10.1.3.254 ucst 616 2 xe-0/0/3.0 192.168.0.1/24 user 0 10.1.3.254 ucst 616 2 xe-0/0/3.0 10.1.3.255/32 iddn 0 10.1.3.255 bcst 614 1 xe-0/0/3.0 224.0.0.0/4 perm 0 mdsc 546 1 224.0.0.1/32 perm 0 224.0.0.1 mcst 529 1 255.255.255.255/32 perm 0 bcst 543 1 Routing table: default.iso ISO: Destination Type RtRef Next hop Type Index NhRef Netif default perm 0 rjct 60 1 Routing table: vrf01.iso ISO: Destination Type RtRef Next hop Type Index NhRef Netif default perm 0 rjct 600 1
意义
输出指示过滤器是在接口上创建的,并且虚拟路由实例正在将匹配的流量转发到正确的 IP 地址。