NAT and port forwarding
Each host in managed-chain mode has a NAT / port forwarding section in its Desired tab. NAT rules are deployed, versioned, diffed, drift-checked, rolled back and persisted together with the filter rules.
On hosts in full mode there is no separate NAT section: NAT rules live in the nat table’s chains of the full-mode editor (nat (IPv6) for IPv6).
Kinds and support per backend
Section titled “Kinds and support per backend”| Kind | Purpose | iptables | nftables | firewalld | ufw |
|---|---|---|---|---|---|
| Port forward (DNAT) | Send matching traffic to another address (and port). | yes | yes | yes, forward-port | no |
| Redirect to local port | Send matching traffic to another port on this host. | yes | yes | yes, forward-port | no |
| Masquerade | Outbound NAT: rewrite the source to the outgoing interface’s address (gateway, router). | yes | yes | yes, zone-wide or per source | no |
| SNAT | Outbound NAT to a fixed source address. | yes | yes | no (firewalld has no SNAT) | no |
ufw has no NAT commands: enabled NAT rules on a ufw host make the deploy fail.
Add a NAT rule
Section titled “Add a NAT rule”-
In the host’s Desired tab, click + Add NAT rule.
-
Choose the Kind and fill in the fields:
Field Notes Proto tcp,udpor any.In interface For port forwards and redirects (optional). Not on firewalld. Out interface For masquerade and SNAT. Not on firewalld. Source (IP/CIDR/@alias) Optional; aliases work. Destination Optional. Not on firewalld. Dports Required for port forwards and redirects, for example 2222or8000-8010.Forward to address / To port (optional) Target of a port forward. To local port Target of a redirect. Source address The fixed address of an SNAT rule. Comment Allow forwarding On by default: also accepts the translated traffic when the forward policy is DROP. -
Save the rule. Use the arrows to order rules and Del to remove one.
Deploy the host to apply the change.
How NAT is rendered
Section titled “How NAT is rendered”- iptables: rules go into FireHawk’s own chains in the
nattable (FIREHAWK_PRE,FIREHAWK_OUT,FIREHAWK_POST), jumped to first from the builtin chains. Forward accepts go toFIREHAWK_FORWARD. - nftables:
nat_prerouting,nat_outputandnat_postroutingchains inside theinet firehawktable, created only when NAT rules exist. - firewalld: forward-ports and masquerade in the default zone (rich rules when a source is given), removed and re-added on each deploy.
Drift detection compares the rules in these chains, and only checks that the jumps to the nat chains exist, not their position: Docker legitimately reorders the nat table.
IP forwarding
Section titled “IP forwarding”When a rule forwards traffic to another machine, FireHawk enables net.ipv4.ip_forward and persists it in /etc/sysctl.d/90-firehawk.conf. The file is removed again when no NAT rule needs it.
Forwarding to a machine on the same LAN
Section titled “Forwarding to a machine on the same LAN”Example: the host 10.0.0.1 forwards port 2222 to 10.0.0.5:22, and clients are in 10.0.0.0/24.
- Port forward (DNAT): Proto
tcp, Dports2222, Forward to address10.0.0.5, To port22. - Masquerade: Out interface the LAN interface, Destination
10.0.0.5, Dports22.
