Security Policies · Topic 2 of 3

Global Security Policies

Learn SRX global security policies, matching from-zone and to-zone with any or several zones, the global address book and lookup order after zone policies.

  • 6 min
In a nutshell
  • Global policies live under security policies global policy <name>.
  • They can match from-zone and to-zone, each with one zone, several zones or any.
  • With no zone match, a global policy applies to all zone pairs.

What it is

A global security policy is a policy that is not tied to a single zone pair. It lives under security policies global and can apply to traffic between any zones, or to a chosen list of source and destination zones.

Global policies let you write a rule once instead of copying it into every context. A typical use is blocking a list of known bad hosts across the whole device, or permitting DNS to a central server from every zone.

Rule needed inmany zone pairsOne global policyApplies toevery matching zone pair

How it works

Global policy structure

security {
    policies {
        global {
            policy BLOCK-BAD-HOSTS {
                match {
                    source-address BAD-HOSTS;
                    destination-address any;
                    application any;
                }
                then {
                    deny;
                    log {
                        session-init;
                    }
                }
            }
        }
    }
}

In set form:

user@srx# set security policies global policy BLOCK-BAD-HOSTS match source-address BAD-HOSTS
user@srx# set security policies global policy BLOCK-BAD-HOSTS match destination-address any
user@srx# set security policies global policy BLOCK-BAD-HOSTS match application any
user@srx# set security policies global policy BLOCK-BAD-HOSTS then deny
user@srx# set security policies global policy BLOCK-BAD-HOSTS then log session-init

The match and action structure is the same as a zone-based policy. Source address, destination address and application are required, and the actions are permit, deny and reject with log and count.

Matching zones in a global policy

A global policy with no zone match applies to every zone pair. You can narrow it with from-zone and to-zone under match. Each takes one zone, several zones, or any.

user@srx# set security policies global policy DNS-TO-CORE match from-zone [ trust dmz guest ]
user@srx# set security policies global policy DNS-TO-CORE match to-zone services
user@srx# set security policies global policy DNS-TO-CORE match source-address any
user@srx# set security policies global policy DNS-TO-CORE match destination-address DNS-SERVERS
user@srx# set security policies global policy DNS-TO-CORE match application [ junos-dns-udp junos-dns-tcp ]
user@srx# set security policies global policy DNS-TO-CORE then permit
Zone matchMeaning
None configuredAny source zone to any destination zone
from-zone anyAny source zone
from-zone [ trust dmz ]Traffic from trust or from dmz
to-zone untrustTraffic going to untrust only

DNS-TO-CORE replaces three zone-based policies: trust to services, dmz to services and guest to services.

Addresses in global policies

Because a global policy is not bound to one zone pair, it can only reference addresses in the global address book. An address in a book attached to a specific zone cannot be used, and the commit fails if you try.

user@srx# set security address-book global address-set BAD-HOSTS address BAD-1
user@srx# set security address-book global address-set DNS-SERVERS address DNS-1

Lookup order

Zone-based and global policies are checked in a fixed order at the policy step of the first packet path.

StepPolicies checkedResult
1Zone-based policies for the session's from-zone and to-zoneFirst match is used
2Global policies, top to bottomFirst match is used if step 1 found nothing
3Default policydeny-all unless changed
SessionZone contextfirst matchno matchGlobal policiesfirst matchno matchDefault policyZone contextfirst matchmatchAction appliedGlobal policiesfirst matchmatchAction applied

This order matters. A zone-based permit for a zone pair is chosen before a global deny, so the global deny does not stop that traffic. To make a global block win, the zone contexts must not already permit the traffic, or the block must be added to those contexts.

Order within the global policies

Global policies are checked top to bottom, first match wins, and new policies are added at the end, just like zone-based policies. Reorder them with insert:

user@srx# insert security policies global policy BLOCK-BAD-HOSTS before policy DNS-TO-CORE

Monitoring global policies

CommandShows
show security policies globalAll global policies in order
show security policies detailEvery policy in full, zone-based and global
show security policies hit-countMatch counts per policy

Read the global list together with the zone context for the same traffic. A session only reaches the global list when its zone context has no match.

Exam tip

A global policy without a zone match applies everywhere, including traffic between interfaces of the same zone. Add from-zone and to-zone to keep a broad permit from reaching zone pairs you did not mean.

When to use each

NeedBetter choice
One rule for one zone pairZone-based policy
The same rule in many zone pairsGlobal policy
A device-wide block listGlobal policy, if no zone policy permits that traffic first
A catch-all deny with loggingFinal global policy with log session-init

Common mistakes

Expecting a global deny to override a zone permit. Zone-based policies are checked first; a matching zone permit wins.

Using an attached address book in a global policy. Global policies accept only addresses from the global address book.

Leaving out the zone match on a broad permit. With no from-zone and to-zone, the policy applies to every zone pair, including untrust to trust.

Thinking global policies replace the default policy. If no zone-based or global policy matches, the default policy still applies.

Watch out

Global policies use the same first match logic as zone-based policies. A broad global permit placed above a specific global deny makes the deny unreachable.

What to remember for the exam

  • Global policies live under security policies global policy <name>.
  • They can match from-zone and to-zone, each with one zone, several zones or any.
  • With no zone match, a global policy applies to all zone pairs.
  • Global policies use only the global address book.
  • Lookup order: zone-based context, then global policies, then the default policy.
  • Within the global list, top to bottom and first match wins; insert reorders.
  • show security policies global lists them.

Check yourself

  • A zone policy from trust to untrust permits all traffic, and a global policy denies source BAD-HOSTS. Is a session from a BAD-HOSTS address in trust to untrust denied?

    No. The zone-based permit matches first, so the global deny is never checked for that session.

  • Which address book entries can a global policy use?

    Only entries in the global address book.

  • A global policy has no from-zone or to-zone configured. Which traffic can it match?

    Traffic between any zones, including intrazone traffic, as long as the addresses and application match.

Topic 2 of 3 in Security Policies

Test yourself on Security Policies

The full Juniper JNCIA-SEC JN0-232 question bank has 658 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.