Firewall Rule Builder (UFW & iptables)
Compose allow/deny rules once and get ufw commands, iptables rulesets, first-match simulation and lockout warnings.
Rules and policies
0 rule(s) · 0 error(s)No rules yet. Add one or choose a preset above.
Generated rules
Add a rule to generate commands
Choose a preset to see both dialects at once.
Safety advisories
- Warning: INPUT policy is restrictive and no management-port (22/3389) allow rule exists. Keep an active console session before applying.
Details
Describe a rule once — action, direction, interface, protocol, ports, source, destination and comment — and the builder emits both ufw commands and ordered iptables rules from the same model. A first-match simulator walks your rules in order for a test source, port and protocol, so you can see which rule wins before applying anything. Default policies are included in the output along with an SSH lockout guard, shadow-rule detection and a console-session warning. Presets cover a web server, hardened SSH and a database subnet. Generated scripts are inert text: this tool never executes commands or connects to your machine.
More examples
SSH from the VPN only
allow · in · tcp · 22 · source 10.0.0.0/8 · comment 'SSH from VPN'
→ ufw allow in tcp from 10.0.0.0/8 port 22 comment 'SSH from VPN'
→ iptables -A INPUT -p tcp -m tcp --dport 22 -s 10.0.0.0/8 -j ACCEPTOne rule produces both dialects with the source restriction intact.
Web server defaults
INPUT DROP · OUTPUT ACCEPT · FORWARD DROP
allow 22 from VPN · allow 80,443 from any
→ policy lines first, rules in order, console-session warningThe generated ruleset includes the policy context admins often forget.
First-match simulation
rule 1: deny tcp 22 from 10.0.0.0/8
rule 2: allow tcp 22 from any
test src 10.1.2.3:22 → DROPiptables stops at the first match, so the later allow never applies.
Chunked multiport
ports 3000-3019 → two iptables lines of at most 15 ports eachThe multiport module has a 15-port limit; the compiler splits long lists automatically.
Examples
VPN-only SSH
allow in tcp 22 from 10.0.0.0/8iptables -A INPUT -p tcp -m tcp --dport 22 -s 10.0.0.0/8 -j ACCEPTOne model produces matching ufw and iptables commands with the source restriction.
Shadowed deny
1. allow tcp 80 · 2. deny tcp 80Rule 2 is shadowed by rule 1The simulator and advisory both show that the deny can never apply.
Invalid CIDR
source 10.0.0.0/33Invalid source CIDR — fix before generatingValidation runs before either compiler emits commands.
About this tool
Firewall Rule Builder turns a small rule table into two dialects: ufw commands for humans and ordered iptables rules for scripts. Each row carries action, direction, interface, protocol, ports, source, destination and a comment; both compilers derive from that single model so they cannot drift apart.
The output includes default policies, an optional conntrack starter, a first-match simulator and safety advisories for SSH lockouts, unrestricted management access and shadowed rules. Presets for a web server, hardened SSH and a database subnet are editable rows rather than opaque blobs.
Nothing is executed. Generated scripts are text you review and apply yourself, ideally from an active console session. Internal CIDRs and topology stay in the browser tab.
What this tool does not do
- nftables and firewalld are out of scope; only ufw and iptables are generated.
- IPv6 mode emits ip6tables commands but does not simulate IPv6 CIDR membership.
- Conntrack starter rules are shown in output but are not part of the first-match simulation.
- Generated text is never applied or validated against a live firewall; review before running it.
How to use this tool
Start from a preset
Load web-server, SSH-hardened or database, or add an empty rule and fill in the fields.
Set default policies
Choose INPUT, OUTPUT and FORWARD policies; a restrictive INPUT with no management allow raises a warning.
Choose a dialect
Switch between ufw and iptables. Both show the same rules with dialect-correct flags and quoting.
Test the order
Enter a source IP, port, protocol and direction; the verdict shows the first matching rule or the chain policy.
Export and review
Copy the active dialect or download a full setup script; keep a console session open when applying.
Use cases
VPS hardening
Allow SSH from a VPN subnet, open HTTP/HTTPS and close everything else with policy context.
Bootstrap scripts
Export an ordered iptables script plus ufw equivalents for a new machine.
Learning netfilter
Experiment with first-match semantics and see why rule order matters.
Rule fields
| Field | Example |
|---|---|
| action | allow / deny / reject |
| direction | in / out |
| protocol | tcp / udp / any / icmp |
| ports | 80,443 or 8000-8010 |
| source / destination | 10.0.0.0/8 |
| comment | SSH from VPN |
iptables evaluates top to bottom, so reordering rules changes the verdict.
Common mistakes
Mistake:Applying a DROP policy without an SSH allow rule.
Fix:Keep an active console session and heed the lockout advisory.
Mistake:Expecting a later deny to override an earlier broad allow.
Fix:Reorder rules or narrow the allow; iptables stops at the first match.
Mistake:Putting more than 15 ports in one multiport rule.
Fix:The builder chunks long lists into multiple commands automatically.
Mistake:Assuming ufw governs Docker-published ports.
Fix:Docker inserts its own chains; manage those ports with iptables/nftables.
Frequently asked questions
What is the difference between ufw and iptables?
ufw is a friendly front end that writes netfilter rules for you; iptables talks to the kernel chains directly and gives finer control. This tool emits both from one rule model so the commands stay in sync.
Which rule matches first?
iptables walks the chain from top to bottom and stops at the first match. The simulator highlights that rule and marks later rules as unused; reordering rows changes the verdict immediately.
How do I avoid locking myself out of SSH?
Keep an active console session, add an allow rule for port 22 from your admin subnet before broad denies, and read the in-output warning. The builder flags a restrictive INPUT policy with no management allow and flags management access from anywhere.
How do default policies work?
Policies decide the fate of packets that match no rule. A DROP INPUT policy is a good hardening baseline once required services are explicitly allowed; OUTPUT is usually ACCEPT and FORWARD is usually DROP on a host.
Should I use nftables instead?
On modern distributions nftables is the successor to iptables, but iptables remains widely deployed and ufw still uses it underneath. This tool deliberately covers those two dialects; port the emitted logic to nft syntax if your host uses it.
Does this tool execute the generated commands?
No. Everything is inert text computed in your browser. Your network setup and internal CIDRs never leave the tab, and nothing connects to or changes your machine.
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.gitattributes Generator
Build .gitattributes rules for line endings, Git LFS, GitHub linguist marks and merge drivers — with a one-line explanation for every rule.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
A/B Test Sample Size Calculator
Compute required sample size per variant and test duration from baseline conversion rate, minimum detectable effect, alpha and power.
ABA Routing Number Validator
Validate 9-digit US ABA routing numbers with 3-7-1 Mod-10 breakdown.