Smart Deals - promotions, discount codes and sales

iptables Rules Generator

Fast, accurate, and free online iptables Rules Generator tool that runs directly in your browser.

Secure (SSL)
Client-Side Processing
100% Free
Instructions
  • 1
    Enter data
    Enter content, paste text or load a file from disk.
  • 2
    Click the button
    The tool will immediately process your data in the browser.
  • 3
    Get the result
    Copy the finished text or save the file to your device.
function runTool() {
  return "Result ready in 0.1s";
}

raw: # IPv4 (iptables-restore) *filter -A INPUT -i eth0 -s 203.0.113.0/24 -p tcp -m tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -m comment --comment "Allow SSH from the office network" -j ACCEPT COMMIT

Rate this tool:

Related tools

Other tools you may find useful

iptables rule generator - Linux firewall for everyone

iptables is a tool for configuring a firewall in Linux. The syntax can be difficult - the generator creates ready-made rules for typical scenarios: IP blocking, port opening, NAT redirection and security policies - without having to remember the parameters.

iptables generator iptables rules Linux firewall iptables iptables block IP port

Basics iptables

Tables: filter (default), nat, mangle, raw. Chains: INPUT (incoming), OUTPUT (outgoing), FORWARD (forwarding). Default policy: ACCEPT or DROP. Rule: iptables -A INPUT -p tcp --dport 22 -j ACCEPT. Options: -A (append), -I (insert), -D (delete), -L (list), -F (flush). Save: iptables-save > /etc/iptables/rules.v4.

Common iptables rules

Open the SSH port: iptables -A INPUT -p tcp --dport 22 -j ACCEPT. Block IP: iptables -A INPUT -s 192.168.1.100 -j DROP. Allow HTTP/HTTPS: iptables -A INPUT -p tcp -m multiport --dports 80,443 -j ACCEPT. Loopback: iptables -A INPUT -i lo -j ACCEPT. Established connections: iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT. DROP all: iptables -P INPUT DROP.

NAT and port forwarding

Masquerade (internet sharing): iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE. Port forwarding: iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080. DNAT: iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.1.10:80. Enable forwarding: echo 1 > /proc/sys/net/ipv4/ip_forward.

nftables – successor to iptables

nftables: since Linux 3.13, default in Debian 10+, CentOS 8+. Better syntax: nft add rule inet filter input tcp dport 22 accept. Migration: iptables-translate (converts rules). Tables and chains: more flexible. Performance: better optimized. Distributions: Ubuntu 20.04+ uses nftables via iptables-nft (wrapper). Check: systemctl status nftables vs iptables.

FAQ

How to block brute-force SSH attacks over iptables?

Limit the number of connections: iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --set. iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 60 --hitcount 5 -j DROP. Alternative: Fail2ban (automatically blocks IPs after X number of failed attempts). UFW (Ubuntu): ufw ssh limit (built-in rate limiting).

How to list and remove iptables rules?

List: iptables -L -n -v (with line numbers and statistics). iptables -L --line-numbers (rule numbers). Delete by number: iptables -D INPUT 3 (delete 3rd rule in INPUT). Remove specific: iptables -D INPUT -p tcp --dport 80 -j ACCEPT. Clear all: iptables -F (flush) or iptables -F INPUT (INPUT only). Restore defaults: iptables -P INPUT ACCEPT.

How to permanently save iptables rules?

Ubuntu/Debian: apt install iptables-persistent. Save: netfilter-persistent save. Load: netfilter-persistent reload. Manually: iptables-save > /etc/iptables/rules.v4. Load at boot: iptables-restore < /etc/iptables/rules.v4 in /etc/rc.local. CentOS/RHEL: service iptables save. Systemd: create unit service with iptables-restore.

What is the difference between iptables and UFW?

UFW (Uncomplicated Firewall): frontend for iptables, simpler interface. iptables: full control, more difficult syntax. UFW: ufw allow 22/tcp. iptables: iptables -A INPUT -p tcp --dport 22 -j ACCEPT. When UFW: production servers, basic rules. When iptables: complex NAT, load balancing, advanced filtering. Ubuntu: UFW by default. CentOS 8+: firewalld (different

Install Webp.pl Have the tools in your own pocket!