ipset on Debian Squeeze
Messing with the kernel is over my head…can anyone walk me through getting it working? I'm comfortable with the ipset/iptables stuff once I can get ipset to run (been playing on a local machine.)
Thanks,
-Bart
7 Replies
# banip.sh
#!/bin/sh
iptables -I INPUT -s $1 -j DROP
# that ^^^ line with a -D will remove a banned IP or CIDR
iptables-save -c > /etc/iptables.rules
exit 0
Then in use:
# call banip.sh for 1 IP
banip.sh 44.55.66.77
# call banip.sh for 256 IPs probably a small ISP
banip.sh 44.55.44.0/24
# call banip.sh for class B probably a large ISP
banip.sh 44.55.0.0/16
You can find out (usually) what the IP range is for an offending IP using whois on the IP. Sometimes the CIDR is listed. Sometimes just the range is listed so you can use free tools to find the actual CIDR. It might end up being something odd like 44.55.27.11/21.
None of those examples are correct, just showing what the format looks like. /16 is for a Class B though and /24 for Class (I think it's C).
Look online for sites that offer freely downloadable databases of known offending IPs and CIDR ranges.
First, be advised that there is no relationship between source IP address and country of origin. Humans have evolved to detect patterns, even ones that aren't there, and that's what we've done with this whole "geolocation" concept. Also, there are ethical and moral implications for blocking entire countries.
That said, what exactly is ipset, and what exactly is it doing when it doesn't work?
My plan is to block countries' CIDR blocks using ipdeny's (
When trying to use ipset (apt-get install xtables-addons-common) I get this:
ipset v4.2: Kernel ip_set module is of protocol version 6.I'm of protocol version 4.
Please upgrade your kernel and/or ipset(8) utillity.
Then if I install just ipset (apt-get install ipset) I get this:
ipset v2.5.0: ipset kernel/userspace version mismatch
Perhaps ipset or your kernel needs to be upgraded.
help?
Thanks,
-Bart
> Why not just fix the actual problem? Either your client is using a weak password, or they aren't keeping it a secret. This is not a problem iptables can fix.
I understand your sentiment, but I disagree about whether iptables can be a part of the solution to the problem. In this particular case, there's no evidence that her account was bruteforced; I don't believe she would have knowingly shared it, but who knows?
I know this: in the last 30 hours there have been 647 failed attempts on her account, from 601 unique IP addresses (details here:
I will appreciate anyone's advice about getting ipset working with iptables on my Debian Squeeze linode.
Thanks,
-Bart
stock Debian kernel
Did as described, looks good, testing now.
Regards,
-Bart