Firewall Rule Generator
Build firewall rules for any major platform — or paste a rule and get a plain-English explanation.
Client-side only — nothing leaves your browser
sudo ufw allow in from any port 22 proto tcp comment "Allow SSH"Always test new rules on a console you can recover from. Locking yourself out of a remote server with a bad firewall rule is a common — and avoidable — failure mode.
About Firewall Rules
A firewall rule is a single decision the firewall makes about a packet: who it's from, who it's to, what protocol and port it uses, and what to do with it (allow, drop, reject). Different platforms write these rules in very different syntaxes — UFW reads like English, iptables uses a wall of flags, nftables uses a programming-language-style ruleset, and the cloud providers each have their own JSON or CLI dialect — but the underlying concepts are nearly identical. This generator lets you describe a rule once and emit it in the syntax you need, and the Explain mode goes the other direction: paste any rule, get plain English back.
Firewall Rule Actions Explained
Every firewall rule terminates in an action (sometimes called a target, verdict, or disposition). The most common ones:
| Action | What it does | Sender sees |
|---|---|---|
| allow / accept | Pass the packet through to the destination. | Normal connection. |
| deny / drop | Silently discard the packet with no reply. | Connection timeout. |
| reject | Discard the packet and send back an ICMP error (or TCP RST). | "Connection refused" immediately. |
| log | Write to the firewall log without taking a verdict. | Nothing — usually paired with another rule. |
Drop is friendlier to your server (no work to send a reply, no information leaked) but rougher on legitimate users who'll wait for a long timeout. Reject is friendlier to clients — they fail fast — but tells attackers the port exists. The standard advice is drop on internet-facing rules, reject on internal rules where the slow timeout would just frustrate developers.
Same Rule, Eight Syntaxes
How "allow inbound SSH (TCP 22) from 203.0.113.0/24" looks in each system:
| Platform | Rule |
|---|---|
| UFW | sudo ufw allow in from 203.0.113.0/24 to any port 22 proto tcp |
| iptables | sudo iptables -A INPUT -s 203.0.113.0/24 -p tcp --dport 22 -j ACCEPT |
| nftables | sudo nft add rule inet filter input ip saddr 203.0.113.0/24 tcp dport 22 accept |
| firewalld | sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.0/24" port port="22" protocol="tcp" accept' |
| Windows | New-NetFirewallRule -DisplayName "Allow SSH" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 22 -RemoteAddress 203.0.113.0/24 |
| AWS | aws ec2 authorize-security-group-ingress --group-id sg-... --ip-permissions 'IpProtocol=tcp,FromPort=22,ToPort=22,IpRanges=[{CidrIp=203.0.113.0/24}]' |
| GCP | gcloud compute firewall-rules create allow-ssh --direction=INGRESS --action=ALLOW --rules=tcp:22 --source-ranges=203.0.113.0/24 |
| Azure | az network nsg rule create --resource-group rg --nsg-name nsg --name allow-ssh --priority 1000 --direction Inbound --access Allow --protocol Tcp --source-address-prefixes 203.0.113.0/24 --destination-port-ranges 22 |
Firewall Rule Best Practices
- Default deny. The base policy should drop everything, then explicitly allow the few protocols and sources you need. Allow-by-default firewalls are not firewalls.
- Most specific rules first. Most firewalls evaluate top-down and stop at the first match. Put narrow rules (allow SSH from one IP) above broad ones (deny SSH from anywhere).
- Scope sources tightly. "Allow SSH from anywhere" is a recipe for brute-force noise. Use your office CIDR, a VPN range, or a single jump host instead of 0.0.0.0/0.
- Always allow loopback. Many services bind to 127.0.0.1 and break in subtle ways if you accidentally drop loopback traffic.
- Allow established/related early. A stateful
ct state established,related acceptrule near the top of INPUT lets reply traffic pass without re-evaluating every later rule. - Test before you persist. On a remote box, schedule a rollback (
at now + 5 min << restore.sh) before applying — if the new rules lock you out, the server reverts itself. - Comment every rule. Six months from now, "why is port 8443 open from this random /24?" will be a mystery. Every generator above supports comments — use them.
Frequently Asked Questions
What is a firewall rule?
What is the difference between inbound and outbound firewall rules?
What is the difference between drop and reject in firewall rules?
In what order are firewall rules evaluated?
Are firewall rules stateful?
Related Tools
iptables to nftables
Convert iptables rules to nftables. Translates chains, NAT, conntrack, and common matchers.
rsync Command Builder
Build rsync commands visually. Local or remote source/destination, flag toggles, exclude patterns, and presets.
rsync Flag Explainer
Paste any rsync command and instantly see what every flag does, with risky-flag warnings.
Docker Compose Generator
Build docker-compose.yml visually. Add services, volumes, networks, env vars — with live YAML and lint warnings.
Dockerfile Generator
Build Dockerfiles from form inputs. Multi-stage builds, healthchecks, and best-practice hints inline.
Need to manage SSH connections?
SSH Workbench lets you connect, browse files, and manage servers visually.
Try SSH Workbench Free