Aww
The biggest thing to remember is that sets (inside ipset) can store an ip address, an ipaddress plus netmask, an ipaddress plus netmask plus port. This makes it extremely powerful. An example
ipset -N blacklist_ipaddress iphash
ipset -A blacklist_ipaddress 213.221.160.1
ipset -A blacklist_ipaddress 213.221.160.2
in iptables you just have the following:
iptables -A INPUT -m set –set blacklist_ipaddress src -j DROP
You can also create different sets, so as well as having the set blacklist_ipaddress you could also do this at the same time...
ipset -N blacklist_netaddress nethash
ipset -A blacklist_netaddress 213.221.160.0/24
ipset -A blacklist_netaddress 44.10.5.0/16
iptables -A INPUT -m set -set blacklist_netaddress src -j DROP
Or if you want to ban an ip address for a specific length of time:
ipset -N blacklist_tempbans iptree --timeout 86400 (create a set with a default ban time of 24 hours)
ipset -A blacklist_tempbans 213.221.160.1,600 (ban this ip for just 10 minutes)
ipset -A blacklist_tempbans 213.221.160.2 (ban this ip for the set default which is 24 hours)
ipset -A blacklist_tempbans 213.221.160.4,3600 (ban this ip for an hour)
iptables -A INPUT -m set -set blacklist_tempbans src -j DROP