Zones & direction
Group networks into zones
Lesson 8 of 20 · 11 min · Module 3: Zones and policies
Writing rules address by address does not scale. Firewalls group their networks into a few zones and describe traffic by the direction it travels between them.
Start this lesson →Free. No installation: you write and run the code in your browser, and it is checked automatically.
By the end, you’ll be able to…
- Name the three common zones and what belongs in each
- Write a rule for one direction between two zones
- Explain why untrust to trust has no allow rule
The idea
A zone is a set of networks with the same level of trust. Three are common: trust for the internal network, untrust for the internet, and dmz for servers that outsiders may reach. A rule from trust to untrust covers outgoing traffic only; the opposite direction needs its own rule, and usually should not get one.
allow tcp from trust to untrust port 25
deny any from untrust to trust log
01Think in directions
trust to untrust is the office using the internet. untrust to trust would be the internet starting connections into the office, which almost never has a legitimate reason. With stateful inspection, the replies to outgoing requests come back through the session, so the inbound direction can stay closed.
02A zone is not "any"
In this lab untrust means every address that is not in another zone. A rule "from trust to untrust" therefore does not cover the DMZ, and that is useful: traffic to your own servers is decided by its own rule. "to any" would quietly include them.
03Zones on real devices
On real firewalls a zone is a group of interfaces, and a packet belongs to the zone of the interface it arrives on or leaves from.
# Huawei USG
firewall zone trust
add interface GigabitEthernet0/0/1
firewall zone untrust
add interface GigabitEthernet0/0/2
# FortiGate: policies name interfaces, or zones built from them
config system zone
edit "trust"
set interface "port2" "port3"
next
end
# nftables: match the interfaces directly
nft add rule inet filter forward iifname "lan0" oifname "wan0" tcp dport { 80, 443 } accept
Your turn
trust) to use the internet (untrust): web browsing on tcp 80 and 443, and DNS on udp 53. Write the rules with zone names. Do not open anything from untrust into trust, and do not include the DMZ.What the checks look for
- The office can browse and resolve names
- Nothing is opened from the internet into the office
- The rules name the internet zone, so the DMZ is not included
- Other internet services stay closed
Take this with you
Describe traffic by direction between zones. Open trust to untrust for the services people need, and leave untrust to trust closed.
Go a little further
Replace untrust with any in your first rule and run the lab. Read which check fails and which test packet changed its verdict.