A few years ago I wrote a iptables tutorial explaining the basics of the topic. This post is just a small cheat sheet of most simple and effective commands that I end up using very frequently. I am assuming that we are operating for IP 1.1.1.1 and using INPUT chain of the iptables.
- Block an IP
iptables -A INPUT -s 1.1.1.1 -j DROP
- Block an IP range
iptables -A INPUT -s 1.1.1.1/24 -j DROP
- List current rule set
iptables --list
- List current rules set with numbers
iptables --line-numbers --list
- Delete a rule by rule
iptables -D INPUT -s 1.1.1.1 -j DROP
- Delete a rule by number
iptables -D INPUT 7
- Save iptables rules to a file
iptables-save > iptables.dat
- Load iptables rules from a file
iptables-restore < iptables.dat
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.