CheatSheets
Iptables CheatSheet
CheatSheet
iptables is a Linux kernel-level module allowing us to perform various networking manipulations (i.e., packet filtering) to achieve better network security.
View all current iptables rules:
View all INPUT rules:
Blocking and Unblocking IP Addresses
How to block an IP address using iptables:
To block a range of IP addresses:
How to unblock an IP address:
Blocking and Unblocking Ports
How to block all connections to a port (example with port 25):
How to unblock a port (example with port 25):
Saving iptables Rules
To save all rules so that they are not lost in case of a server reboot:
Or, alternatively:
Deleting iptables Rules
Delete a rule by line number:
- Output all the iptables rules with line numbers:
- Delete the rule using its line number: