Copied to clipboard

iptables

iptables is a command-line tool used to manage network traffic control rules and security policies on Linux systems.

Example

  • Reject all traffic: iptables -P INPUT DROP
  • Allow all traffic: iptables -P INPUT ACCEPT
  • Allow loopback traffic: iptables -A INPUT -i lo -j ACCEPT
  • Allow HTTP traffic: iptables -A INPUT -p tcp --dport 80 -j ACCEPT
  • Allow SSH traffic: iptables -A INPUT -p tcp --dport 22 -j ACCEPT
  • Allow DNS traffic: iptables -A INPUT -p udp --dport 53 -j ACCEPT
  • Allow ICMP traffic: iptables -A INPUT -p icmp -j ACCEPT
  • Show current rules: iptables -L
  • Flush all rules: iptables -F
  • Zero all counters: iptables -Z