What is this iptables / nftables rule builder?
A Linux firewall keeps unwanted traffic off your server. The two tools that ship with the kernel are iptables (the classic one, around since 1998) and nftables (the modern replacement, default on Debian 11+, Ubuntu 22.04+, RHEL 9+ and most current distros).
This builder lets you write firewall rules in a friendly form and produces both syntaxes at the same time. Pick a chain (INPUT, OUTPUT, FORWARD), pick an action (ACCEPT, DROP, REJECT, LOG), set the protocol, source, destination, ports and connection state, and you get a paste-ready ruleset.
Everything runs in your browser: no rules are applied, no server is contacted, nothing is uploaded. You copy the output, open your terminal, read it carefully, and run it yourself. The tool is a builder, not a runner.
A few things worth knowing before you start:
- The default policy of a chain is what happens when no rule matches. Setting INPUT to DROP plus a few targeted ACCEPT rules is the classic "deny by default" stance.
- Order matters in iptables: rules are evaluated top to bottom, first match wins. Put your return traffic rule (ESTABLISHED, RELATED) first to avoid breaking existing connections.
- nftables is declarative (the whole table is one document); iptables is imperative (each `-A` line appends one rule).
How to use it
- Start with a preset if you can: "Basic webserver", "Locked-down SSH", "Allow LAN, deny WAN", "Docker forward chain", or "Rate limit SSH". Each one fills in sensible defaults you can tweak.
- Set the default policy per chain. The safe stance is INPUT=DROP, FORWARD=DROP, OUTPUT=ACCEPT. The OUTPUT policy is usually ACCEPT because you trust your own server to talk out.
- Add rules in order. The very first INPUT rule should be: protocol=any, state=ESTABLISHED+RELATED, action=ACCEPT. This keeps existing connections alive when you reload the firewall.
- For each rule pick the chain, action, protocol, optional source IP (or CIDR like 192.168.1.0/24), optional destination IP, optional source/destination port, and a connection state if you need stateful matching.
- Use the conntrack toggle to choose between the modern `-m conntrack --ctstate` and the legacy `-m state --state`. Modern kernels default to conntrack; keep it on unless your distro is ancient.
- Watch the live preview on the right. The top pane is iptables, the bottom pane is nftables. Both are kept in sync from the same model and both have a Copy button.
- Test before you commit. Copy the iptables block, paste it on the server, run it. If you lock yourself out, the rules will not survive a reboot (they live in memory only). After 5 minutes of testing, persist them with `netfilter-persistent save` (Debian/Ubuntu) or save the nftables block into `/etc/nftables.conf`.
When this is useful
Five concrete situations where building rules in a form beats writing them by hand:
- You set up a fresh VPS and need a starting firewall. The "Basic webserver" preset opens ports 22 (SSH), 80 (HTTP), 443 (HTTPS) and drops everything else. It is the canonical first step after installing a server, and the builder writes it once for both syntaxes so you can pick whichever your distro uses.
- You are migrating from iptables to nftables. Many distros (Debian 11+, RHEL 9+) made nftables the default and the legacy `iptables` command is a wrapper. Paste your existing iptables rules into the form, switch the preview to nftables, and you have a ready-to-save `/etc/nftables.conf`.
- You want to lock SSH to one IP. The "Locked-down SSH" preset shows the pattern: ACCEPT from your office IP, LOG and DROP everything else. Three rules, in the right order, with state matching included.
- You manage a Docker host and the FORWARD chain is a mess. Docker rewrites the FORWARD chain on every restart, which is fine, but you still need to know what good FORWARD rules look like. The "Docker forward chain" preset is a clean baseline you can adapt.
- You are teaching someone Linux networking. The side-by-side iptables vs nftables view is the fastest way to show the equivalence: same model, two syntaxes. Toggle a state, watch both panes update, and the relationship between `-m conntrack --ctstate` and `ct state` clicks instantly.