Juniper SRX 防火墙用户认证配置:区域、策略与验证 - 夜莺博客

Juniper SRX 防火墙用户认证配置:区域、策略与验证

Juniper SRX 的防火墙用户认证(Firewall User Authentication)解决一个很具体的问题:在放行流量之前,先让用户通过 Web 门户或 Telnet 认证,认证成功后再动态放行该用户的会话。它由三部分构成:认证方式(本地或外部服务器)、被认证流量所匹配的安全策略、以及通过认证后执行的附加动作。本文用中文把配置顺序和验证方法讲清楚。

第一步:接口与地址

set interfaces ge-0/0/0 unit 0 family inet address 203.0.113.2/24
set interfaces ge-0/0/1 unit 0 family inet address 192.168.10.1/24
set routing-options static route 0.0.0.0/0 next-hop 203.0.113.1

一个口朝外(untrust),一个口朝内(trust)。如果 SRX 还要给终端分配地址,需要额外配置 DHCP 或在区域里指定系统服务。初始配置的完整流程可参考SRX300 初始配置教程

第二步:安全区域

set security zones security-zone trust interfaces ge-0/0/1.0
set security zones security-zone untrust interfaces ge-0/0/0.0
set security zones security-zone trust host-inbound-traffic system-services dhcp
set security zones security-zone trust host-inbound-traffic system-services ping

区域是策略的基础:没有把接口挂到区域上,任何策略都不会匹配。host-inbound-traffic 控制的是"到设备本身"的流量(管理、DHCP、ping),和穿越流量是两回事。

第三步:认证方式(本地用户或外部服务器)

set access profile FWAUTH client USER1 firewall-user password "Str0ngPass!"
set access profile FWAUTH session-options client-idle-timeout 10
set access profile FWAUTH session-options client-session-timeout 60

生产环境通常对接 RADIUS 或 LDAP:

set access radius-server 192.168.10.50 secret "RadiusKey"
set access profile FWAUTH authentication-order radius
set access profile FWAUTH radius-server 192.168.10.50

本地用户适合应急和管理员账号,外部服务器适合员工认证——两者可以同时配置,用 authentication-order 控制优先级。

第四步:写放行策略并挂上认证

set security policies from-zone trust to-zone untrust policy AUTH-WEB match source-address any
set security policies from-zone trust to-zone untrust policy AUTH-WEB match destination-address any
set security policies from-zone trust to-zone untrust policy AUTH-WEB match application junos-http
set security policies from-zone trust to-zone untrust policy AUTH-WEB then permit
set security policies from-zone trust to-zone untrust policy AUTH-WEB then firewall-authentication pass-through web
set security policies from-zone trust to-zone untrust policy AUTH-WEB then firewall-authentication web redirect

关键点是 then firewall-authentication:pass-through 表示认证通过后放行该用户流量,web redirect 表示把未认证的 HTTP 请求重定向到认证页面,也可以用 telnet 方式做 pass-through 认证。

第五步:验证顺序

show security zones
show security policies from-zone trust to-zone untrust
show security flow session
show security firewall-authentication users
show security firewall-authentication history
clear security firewall-authentication users
  • 策略计数为 0:说明流量根本没匹配到策略,先查区域绑定和路由,参考SRX 防火墙配置完整指南
  • 出现认证页面但登录失败:查 access profile 是否绑定到策略、认证服务器是否可达、时间是否同步。
  • 认证成功但访问不通:检查认证后的会话是否命中更高优先级的拒绝策略,以及是否已配置源 NAT——穿越流量做 NAT 的方式与站点到站点 VPN 场景一致,可对照SRX 基于路由的 IPsec VPN 配置里的 NAT 处理顺序。

原文链接:https://www.juniper.net/documentation/cn/zh/software/junos/identity-aware-firewall/topics/topic-map/config-examples-srx-firewall-users.html