Iptables is a tool used to configure the Linux kernel firewall. This quick start guide lists some commonly used iptables commands, enabling system administrators to quickly master the usage of iptables.
Listing all active rules:
iptables -L -v
Disabling and flushing iptables:
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -F
Blocking all traffic:
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
Allowing SSH, HTTP, and HTTPS, while blocking other traffic:
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -j DROP
For more information, refer to the official CentOS and Ubuntu documentation.
23-02-2024 02:02:07
22-02-2024 03:19:32
22-02-2024 03:16:03
22-02-2024 03:14:03
22-02-2024 03:11:58