Linux iptables & UFW Rule Generator
Generate secure iptables, UFW, and nftables firewall rules with stateful connection tracking and rate limiting — entirely on this device.
Default Traffic Policies
Hardening & Protection Modules
Inbound Port Rules
Do it offline:$
How to use it
- Choose default traffic policies for incoming (INPUT) and outgoing (OUTPUT) traffic (default DROP for incoming is recommended).
- Toggle core security protection modules: Loopback (lo), Established/Related connection tracking (conntrack), SYN flood mitigation, and SSH rate-limiting.
- Add inbound port rules for your application services (HTTP, HTTPS, SSH, databases, WireGuard VPN).
- Optionally restrict sensitive ports (like database or admin endpoints) to specific trusted source CIDR subnets.
- Switch between iptables Bash script, UFW commands, and nftables syntax, then copy the configuration to your server.
Build stateful Linux firewall rulesets with default DROP policies, loopback allowances, conntrack connection tracking, SYN-flood rate-limiting, and multi-format exports for iptables, UFW, and modern nftables.
How it works
Linux netfilter inspects network packets using kernel hooks. iptables and modern nftables allow configuring packet filtering tables (filter, nat, mangle).
A secure stateful firewall starts with default DROP on INPUT and FORWARD chains, only permitting explicitly whitelisted inbound ports.
The conntrack module (-m conntrack --ctstate ESTABLISHED,RELATED) allows inbound packets belonging to existing outgoing connections (such as curl requests or package updates) without needing to open random high ports.
The recent module tracks connection frequency to mitigate automated SSH password brute-forcing by dropping rapid successive connection attempts.
Examples
Every example on this page is executed against the same engine that powers the tool, on every build.
Gotchas worth knowing
Common errors
FAQ
What is the difference between DROP and REJECT in iptables?
DROP silently discards the packet with zero response to the sender, making the host appear unresponsive and slowing down automated port scanners. REJECT actively replies with an ICMP 'port unreachable' or TCP RST packet, immediately informing the client that the port is closed.
How do I make iptables rules persistent across reboots?
On Debian/Ubuntu systems, install iptables-persistent and run 'sudo netfilter-persistent save'. On RHEL/CentOS systems, use 'sudo service iptables save' or configure firewalld / nftables persistent services.
Should I use iptables or UFW?
UFW (Uncomplicated Firewall) is a simplified frontend wrapper designed for Debian/Ubuntu systems that generates iptables/nftables rules under the hood. For standard servers, UFW commands are easier to audit and manage, while raw iptables or nftables scripts offer granular control over custom chains, rate limits, and packet mangling.