NanumOS

Firewall — filtering connections that come in first

What it is

A firewall is like the lock on a front door: you go out and come back as you like, but someone knocking from outside gets in only through a door you gave them a key to. The NanumOS firewall filters incoming connections only. What this computer starts (browsing, fetching mail, updates) and the answers to it always pass.

To do now: leave it on. Add a rule only for a door you opened on purpose (for example port 80 of a web server). See and change it in Security › Firewall.

How to use it

ToCommand
see the state and the rulesfw (or fw status)
open a web server (port 80)fw allow 80/tcp
several ports at oncefw allow 6000:6007/udp
remove a rulefw delete 2 or fw delete allow 80/tcp
turn off · onfw off · fw on

How it works

  1. For every packet that arrives on the network card the kernel first asks: is it part of something we know? A TCP connection this computer opened, the answer to a UDP datagram it sent (within 3 minutes), getting an address (DHCP) and finding neighbours (mDNS) pass as they are.
  2. A connection it has not seen is matched against /etc/fw/rules from the top. An allow rule lets it in; a deny rule drops it.
  3. With no rule, it checks whether a service you turned on listens there. If not, it is dropped without a word: no reset (RST) is sent, so whoever knocked waits for an answer that never comes.
  4. Drops are counted per rule and per service; the log gets one summary line a minute at most (never a line per packet).
Technical details
  • The rules file: /etc/fw/rules (owned by root, 0644). It is saved data, so it stays when the OS is updated to a new version. One per line: state on|off, allow|deny [PORT[:PORT]|any][/tcp|/udp] [from A.B.C.D[/N]], # for a note. 64 at most.
  • Only an administrator (root or a user in /etc/sudoers) changes it; an administrator logged in over SSH can.
  • With no file: on real hardware and in the Mac app it is on; inside a QEMU VM it is off (QEMU's user network is a NAT that only the ports the host opened reach, so the host decides). A host can start it on with -fw_cfg name=opt/zeusos/fw,string=on. The server editions (server, web) write their own rules with fw init at the first boot.
  • The state now: cat /proc/fw (state, source, rule N … hits H, service tcp 22 sshd hits H, dropped N tcp A udp B, last …).
  • IPv4 only (NanumOS's network has no IPv6 yet). An IPv6 source in a rule is refused.
  • Tests: tests/test_fw_core.py (the grammar, matching, order, the UDP answer window), tests/firewall.py (in a VM an allowed port answers and a dropped one stays silent with no RST, changes work at once, the rules survive a reboot, the throughput comparison --bench).

NanumOS 0.1.8349 · 2026-11-16