Linux Advanced 04 — Firewall Zones and Runtime Rules

Linux course index · Linux Advanced category · Lesson 4 of 9

AI disclosure — AI-generated content, posted as is. AI can make mistakes. This lesson draws on the linked Open Education posts and adds original explanations or lab examples where useful. The newly written explanations and examples may be freely reused. Linked source material retains its own terms.

Learning goal

Identify the active zone and compare a timed runtime firewall rule with permanent policy.

Concepts and setup

A firewall allows or denies an application path, but opening a path does not create a listener. In firewalld, a zone groups the policy for an interface or source. A runtime change applies now, while permanent configuration is used after reload or restart. Old TCP Wrappers and FTP posts are historical examples and should not be copied to current systems.

Use firewalld in a disposable VM with a host-only adapter and console access. Use the internal zone only if it contains the intended isolated interface and no unrelated interfaces or sources.

Inspect the real interface and zone

sudo firewall-cmd --state
sudo firewall-cmd --get-default-zone
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --list-all --zone=internal
sudo ss -ltn

Possible output

running
public
internal
  interfaces: enp0s8
internal (active)
  interfaces: enp0s8
  services: ...
...
LISTEN ... 127.0.0.1:22 ...

Do not assume the default zone applies. Confirm the VM uses internal for the isolated interface before continuing.

Add a one-minute test rule

sudo firewall-cmd --zone=internal --query-port=8088/tcp
# Continue only if the query above prints "no".
sudo firewall-cmd --zone=internal --add-port=8088/tcp --timeout=60s
sudo firewall-cmd --zone=internal --query-port=8088/tcp
sudo firewall-cmd --permanent --zone=internal --query-port=8088/tcp
# Wait a minute before running this final query:
sudo firewall-cmd --zone=internal --query-port=8088/tcp

Possible output

no
success
yes
no
no

The timeout is runtime only. No listener is started. A query printing no can return a nonzero status. If ending early, remove the temporary port from the same zone.

Questions only

Quick-check questions

  1. Does an allowed port prove a process is listening?
  2. Does the timed rule change the permanent policy?

Assessment questions

  1. How would you prove a service was reachable from an authorized client?
  2. Why might opening a port on the default zone have no effect?
  3. Why can an earlier test work until the firewall reloads?

Questions and answers

Quick-check answers

  1. Does an allowed port prove a process is listening?
    Answer — No. The firewall rule and listener are separate.
  2. Does the timed rule change the permanent policy?
    Answer — No. It expires from runtime policy.

Assessment answer key

  1. How would you prove a service was reachable from an authorized client?
    Answer — Check the listener address on the server and exercise the intended application protocol from that client.
  2. Why might opening a port on the default zone have no effect?
    Answer — The incoming interface or source may belong to another zone.
  3. Why can an earlier test work until the firewall reloads?
    Answer — The test rule may exist only at runtime. Review scope before making a lasting change.

Source articles on this site

Continue the course

Previous lesson 03 — SELinux Contexts, Booleans, and Denials. Next lesson 05 — Authoritative DNS with BIND.

Linux course index · Linux Advanced category · Lesson 4 of 9

Leave a Reply