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
- Global policies live under
security policies global policy <name>. - They can match
from-zoneandto-zone, each with one zone, several zones orany. - 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.
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 match | Meaning |
|---|---|
| None configured | Any source zone to any destination zone |
from-zone any | Any source zone |
from-zone [ trust dmz ] | Traffic from trust or from dmz |
to-zone untrust | Traffic 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.
| Step | Policies checked | Result |
|---|---|---|
| 1 | Zone-based policies for the session's from-zone and to-zone | First match is used |
| 2 | Global policies, top to bottom | First match is used if step 1 found nothing |
| 3 | Default policy | deny-all unless changed |
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
| Command | Shows |
|---|---|
show security policies global | All global policies in order |
show security policies detail | Every policy in full, zone-based and global |
show security policies hit-count | Match 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.
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
| Need | Better choice |
|---|---|
| One rule for one zone pair | Zone-based policy |
| The same rule in many zone pairs | Global policy |
| A device-wide block list | Global policy, if no zone policy permits that traffic first |
| A catch-all deny with logging | Final 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.
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-zoneandto-zone, each with one zone, several zones orany. - 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;
insertreorders. show security policies globallists 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.