In the game, this was a building managerPlay “The Building Manager”
| In the game | In real IT |
|---|---|
| Visitor | Incoming traffic (packet) |
| Address | Source IP address |
| Town and block | First half of the IP address (network part) |
| Notice | Rule table |
| Come in / Sorry | Allow / Deny |
| Everyone else: Sorry | Default deny |
Reading the rule table
Rules are written as a combination of “source,” “destination,” “port number” and “action.” “any” means that field doesn’t matter. In the table below, traffic from the outside address 198.51.100.7 to port 443 on the internal web server matches row 1 and is allowed.
| No. | Source | Destination | Port | Action |
|---|---|---|---|---|
| 1 | any | Web server | 443 | allow |
| 2 | internal | any | any | allow |
| 3 | any | any | any | deny |
Traffic from the same outside address to port 3389 (Remote Desktop) on an internal PC matches neither row 1 nor row 2, and is denied by row 3.
Out and back: stateful inspection
When a PC inside the company views an outside website, the traffic goes two ways: out and back. With old-style packet filtering you also had to write separate rules to let the replies in, which tended to leave big holes.
Most firewalls today use stateful inspection: they remember only “replies to connections that went out from inside” and let those back in automatically. Traffic from outside that nobody asked for is not let in.
Public servers go in the DMZ
Web and mail servers that are open to the outside are placed in a zone separate from the internal network. This is called the DMZ (demilitarized zone). Outsiders can reach only the servers in the DMZ, and traffic from the DMZ into the internal network is blocked as a rule.
Even if a public server is taken over, it becomes much harder for the attacker to reach internal PCs and file servers.
What a firewall can’t stop
A firewall opens and closes the gate based on addresses and ports. If an attack is hidden inside allowed port-443 traffic, it can’t tell. You layer other defenses on top: a WAF for attacks on web apps (such as SQL injection), antivirus for malware in email attachments, and so on.
With firewall rules, “removing” is harder than “adding.” A port opened temporarily for testing often stays open for years.
Leave a comment on each rule saying “when, who and why,” and review them regularly. Also watch out for broad rules such as “allow any to any” placed near the top — they make every rule below them meaningless.
Practice questions
Four-choice questions in the style of Japan’s IT Passport and Fundamental Information Technology Engineer exams. Tap below to see the answer.
Q1The following rules are applied from the top. What happens to traffic from source 203.0.113.5 to destination port 80?
1. Source any, destination port 80, allow
2. Source 203.0.113.5, destination port any, deny
3. Source any, destination port any, deny
- AIt matches row 1 and is allowed
- BIt matches row 2 and is denied
- CIt matches row 3 and is denied
- DIt matches no rule
Show the answer and explanation
Answer: AChecking from the top, it is allowed by row 1, the first match. To block this source with row 2, you’d have to put it above row 1.
Q2Which of these belongs in the DMZ?
- AEmployees’ work PCs
- BA file server with HR data
- CA web server open to the outside
- DAn internal-only accounting system
Show the answer and explanation
Answer: CThe DMZ is the zone for public servers that accept access from outside. Internal-only systems go on a network further inside.
Q3Which of these does a packet-filtering firewall NOT use to decide whether to allow or block traffic?
- ASource IP address
- BDestination port number
- CProtocol type
- DWords written in an email’s body
Show the answer and explanation
Answer: DPacket filtering decides using header information such as IP addresses, port numbers and protocol. It doesn’t look at the data inside.
- Stateful inspection automatically lets in only the replies to traffic that went out from inside
- Put public servers in the DMZ, separate from the internal network
- A firewall can’t stop attacks hidden in the content, so layer a WAF and other defenses on top