瞻博网络 SRX 1400:将用户重定向到自定义 URL 的策略

网络工程 防火墙 杜松 瞻博网络 杜松-srx 回复
2021-07-07 15:24:15

我需要的

我有 SRX 1400 @ JUNOS 12.3X48-D40.5

想象一下,除其他外,还有以下区域:UNTRUSTED-CLIENTSWORLDINTRANET

我想阻止所有来自UNTRUSTED-CLIENTSto 的流量WORLD,但我想让用户知道他们被阻止的原因,因此我希望他们被重定向到http://lockmessage.local位于INTRANET.

试图

我创建了一个简单的应用程序防火墙配置文件,它应该匹配所有流量并使用custom-redirect-url指定的拒绝它然后将此配置文件附加到许可策略。

结果

  • 策略与流量正确匹配(如日志所示)
  • 用户无法访问WORLD区域中的任何 URL ,但是...
  • 用户没有到达指定的 URL,而是超时 :(
  • UNTRUSTED-USERS之间没有流量INTRANET被记录

有什么建议?

  • 这应该有效,还是我完全错了?
  • 可能缺少什么?
  • 有没有另一种方法可以实现我想要的?

配置

应用防火墙:

application-firewall {
    profile Block-Message-profile {
        block-message {
            type {
                custom-redirect-url {
                    content http://blockmessage.local;
                }
            }
        }
    }
    rule-sets Block-Message {
        rule Dummy-Policy-Deny-Everything {  # I am using any application available, since I need at least one rule;
            match {
                dynamic-application junos:GOOGLE;
                ssl-encryption any;
            }
            then {
                deny {
                    block-message;
                }
            }
        }
        default-rule {  # For all other websites - also block
            deny {
                block-message;
            }
        }
        profile Block-Message-profile;
    }
}

之后,策略(省略日志记录以使其整洁):

policies {
    from-zone UNTRUSTED-CLIENTS to-zone WORLD {
        policy REDIRECT-UNTRUSTED-CLIENTS-TO-BLOCK-URL {
            match {
                source-address any;
                destination-address any;
                application [ junos-http junos-https ];
            }
            then {
                permit {
                    application-services {
                        application-firewall {
                            rule-set Block-Message;
                        }
                    }
                }
            }
        }
    }
    from-zone UNTRUSTED-CLIENTS to-zone INTRANET {
        policy ALLOW-ACCESS-TO-BLOCK-URL-SERVER {
            match {
                source-address any;
                destination-address BOCK-URL-SERVER;
                application [ junos-http junos-https ];
            }
            then {
                permit 
            }
        }
    }
}

更新 1

我已经确定了可能提供线索的特定行为。

在监视run show security application-firewall rule-set all命令输出时,我注意到:

  1. 的数量sessions redirected始终为零,因此不是重定向无法工作,而是无法触发;
  2. 的数量sessions matched停留在 的某个旧值85,但不再增长;这很可能是因为我已将父规则限制为application junos-http85值可能意味着,在过去,在将策略限制为 之前junos-ssh,其他一些协议可能已经匹配/触发了default rule但不再匹配它;为什么?
  3. 唯一对我的流量做出明显反应的计数器是Number of sessions with appid pending
  4. 所有这些会话都正确匹配所讨论的策略,可以使用show security flow session application-firewall-rule-set Block-Message.

命令的完整列表:

Rule-set: Block-Message
    Logical system: root-logical-system
    Profile: Block-Message-LAN-Unauthenticated-profile
    Rule: Dummy-Policy-Deny-Something
        Dynamic Application Groups: junos:web
        SSL-Encryption: no
        Action:reject or redirect
        Number of sessions matched: 0
        Number of sessions redirected: 0
Default rule:reject or redirect
        Number of sessions matched: 85
        Number of sessions redirected: 0
Number of sessions with appid pending: 4
1个回答

问题是:你申请一个错误的配置文件profile Block-Message-WLAN-profile您)rule-sets Block-Message

正确的配置文件是profile Block-Message-profile(在 betwwen 中没有“WLAN”字样)如定义的那样。

此外,为确保您的from-zone UNTRUSTED-CLIENTS to-zone INTRANET策略正常运行,请尝试直接从不受信任的客户端访问/打开 blockmessage.local(在 BOCK-URL-SERVER 上)的 URL。

我希望它有帮助。