Linux Commands Reference - Complete Linux Command Guide

Comprehensive Linux command reference with 150+ commands. Search, filter by category, and view detailed usage examples.

Share
Back to commands

iptables

Linux kernel firewall rule management

Syntax

iptables [OPTION]... COMMAND [CHAIN] [RULE-SPEC]

Common Options

-AAppend rule to chain
-DDelete rule
-IInsert rule at head
-LList all rules
-FFlush all rules
-PSet chain policy
-tSpecify table
-jSpecify target action
-pSpecify protocol
--dportSpecify destination port
-sSpecify source address

Common Examples

iptables -L -n -v

List all rules

iptables -A INPUT -p tcp --dport 80 -j ACCEPT

Allow HTTP traffic

iptables -A INPUT -s 192.168.1.0/24 -j ACCEPT

Allow subnet

iptables -P INPUT DROP

Set default drop policy

iptables -F

Flush all rules

iptables -A INPUT -p tcp --dport 22 -j ACCEPT

Allow SSH connections

Related Commands

Related Tools

More Code & Dev Tools