Skip to content
~/ufw-/-iptables-rule-generator
$

UFW / iptables Rule Generator

Visually build firewall rules for UFW or iptables — configure actions, ports, protocols, source/destination IPs, then copy the generated commands.

Output Format

Presets / Templates

Rules (1)

Rule #1
sudo ufw allow in proto tcp from any to any

Generated Commands

# Enable UFW (if not already enabled)
sudo ufw enable

# Set default policies
sudo ufw default deny incoming
sudo ufw default allow outgoing

# Apply the rules below:
sudo ufw allow in proto tcp from any to any

# Check status
sudo ufw status verbose

Quick Reference

UFW Basics

  • ufw enable
  • ufw disable
  • ufw status verbose
  • ufw reset
  • ufw delete <rule-number>
  • ufw default deny incoming
  • ufw default allow outgoing

iptables Basics

  • iptables -L -n -v
  • iptables -F
  • iptables -P INPUT DROP
  • iptables -P OUTPUT ACCEPT
  • iptables -D INPUT <rule-number>
  • iptables-save > /etc/iptables/rules.v4
  • iptables-restore < /etc/iptables/rules.v4

What are UFW and iptables?

UFW (Uncomplicated Firewall) and iptables are Linux tools for controlling network traffic at the kernel level. UFW provides a simplified command-line interface on top of iptables, making it easier to allow or deny traffic by port, protocol, and IP address without writing raw netfilter rules.

How to use this generator

Choose between UFW and iptables output, then add rules by specifying the action (allow/deny), port or port range, protocol (TCP/UDP), and optional source or destination IP. Use the built-in presets for common setups like web servers, SSH access, or database ports, then copy the generated commands to your terminal.

Why generate firewall rules visually?

Firewall misconfigurations are a leading cause of security incidents and accidental lockouts. Building rules visually lets you review every rule before applying it, reducing the risk of exposing sensitive services or accidentally blocking legitimate traffic.