Sub topic 13
Firewall rules, port forwarding, and DMZ
This chapter assumes you know what NAT does, can read an IPv4 address, and recognize common port numbers such as 80, 443, and 3389. It covers how a SOHO router decides which traffic to allow in, and how to open a path to an internal device when you need to.
How a SOHO firewall behaves by default
A firewall is a set of rules that allows or blocks traffic based on addresses, ports, and protocols. Most SOHO routers use stateful inspection. The router tracks each connection that starts inside the network. Replies to that traffic are allowed back in automatically.
Traffic that starts outside is dropped, because NAT has no record of which internal device should receive it. This default is why home devices are not reachable from the internet unless you configure it.
Firewall rules
A rule matches traffic on one or more of these fields and then takes an action.
| Field | Example |
|---|---|
| Source address | Any, or a single IP |
| Destination address | 192.168.1.50 |
| Protocol | TCP, UDP, or both |
| Port | 443 |
| Action | Allow or deny |
Rules are read in order, and the first match wins. A broad "deny all" placed above a specific "allow" will block that traffic. Many routers also let you block outbound ports or websites, which is how basic content filtering is done.
Port forwarding
Port forwarding tells the router to send unsolicited inbound traffic on a chosen external port to a specific internal address and port. You use it when a device inside must be reachable from outside, such as a game server, a security camera, or a remote desktop host.
A typical entry has these parts:
- External port: the port the internet connects to, such as 3389.
- Protocol: TCP, UDP, or both.
- Internal IP address: the device that receives the traffic, such as 192.168.1.50.
- Internal port: the port that device listens on.
Some routers support port triggering. The router opens an inbound port only after the internal device sends outbound traffic on a trigger port. It is less permanent than forwarding, but it works for only one device at a time.
DMZ
A DMZ (demilitarized zone) on a SOHO router forwards all unsolicited inbound traffic to a single internal host. It is a shortcut for hosting something when you do not know which ports it needs.
The host receives traffic on every port, with no router filtering. If it is compromised, an attacker can try to reach the rest of the LAN from it. Use a DMZ only for an isolated, fully patched device, and prefer specific port forwards.
Common mistakes
- Forwarding to a device whose IP address changed.
- Choosing the wrong protocol, such as TCP when the service uses UDP.
- Forgetting that the device's own software firewall can still block the traffic.
- Leaving unused forwards or a DMZ enabled after testing.
Exercise
A technician forwards external port 3389 to 192.168.1.50 for remote desktop. It worked last week and now fails. The rule is unchanged. What is the most likely cause, and how do you prevent it from recurring?
Show answer
The PC's DHCP lease changed its address, so the rule points at the wrong IP. Prevent it by creating a DHCP reservation (or a static address) for the PC so it always gets 192.168.1.50.
Exercise
Why is a DMZ riskier than port forwarding?
Show answer
A DMZ sends all unsolicited inbound traffic on every port to one host with no router filtering. Port forwarding exposes only the specific ports you choose.