| Linode Forum https://forum.linode.com/ |
|
| ipset on Debian Squeeze https://forum.linode.com/viewtopic.php?f=19&t=9408 |
Page 1 of 1 |
| Author: | bartman [ Wed Sep 26, 2012 9:59 pm ] |
| Post subject: | ipset on Debian Squeeze |
I'm trying to protect my mailserver from cn, ru, etc botnets. Would like to use ipset with iptables to block countries by CIDR network addresses, but can't get it to work with the kernel I'm on (3.5.2-linode45). 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 |
|
| Author: | jebblue [ Thu Sep 27, 2012 12:42 am ] |
| Post subject: | Re: ipset on Debian Squeeze |
I've never used ipset but on Ubuntu with iptables command I do this to ban 1 IP or a whole CIDR: Code: # banip.sh Then in use: Code: # call banip.sh for 1 IP 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. |
|
| Author: | hoopycat [ Thu Sep 27, 2012 7:57 am ] |
| Post subject: | Re: ipset on Debian Squeeze |
Class B! Man, that's old-school stuff right there. 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? |
|
| Author: | bartman [ Thu Sep 27, 2012 12:11 pm ] |
| Post subject: | Re: ipset on Debian Squeeze |
Thanks, guys. Here's the backstory: another of my client's email accounts got hacked yesterday. Between about 1:30am and 9am, 22115 emails were sent through her account from 9351 unique IP addresses; most only sent one or two, and most of these addresses appear to be in eastern Europe and the far east. I run fail2ban on password failures, but that's not effective against these botnets because while a single IP may only attempt a couple times a day, the total number of attempts on an account in a day can be in the thousands. My plan is to block countries' CIDR blocks using ipdeny's (http://www.ipdeny.com/ipblocks/) zone files for the countries to block. Even after aggregating the zone files with a perl script (from http://zwitterion.org/software/aggregat ... addresses/), the list is very big. Enter ipset, which provides a way to give iptables a hashed lookup mechanism for these large blocks of addresses. I want to do it this way for performance reasons and to keep my iptables config manageable as I will also continue to use fail2ban. When trying to use ipset (apt-get install xtables-addons-common) I get this: Code: ipset v4.2: Kernel ip_set module is of protocol version 6.I'm of protocol version 4. Then if I install just ipset (apt-get install ipset) I get this: Code: ipset v2.5.0: ipset kernel/userspace version mismatch help? Thanks, -Bart |
|
| Author: | hoopycat [ Fri Sep 28, 2012 6:18 am ] |
| Post subject: | Re: ipset on Debian Squeeze |
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. |
|
| Author: | bartman [ Fri Sep 28, 2012 5:37 pm ] |
| Post subject: | Re: ipset on Debian Squeeze |
Quote: 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: http://pastebin.com/R3hNXP79). There hadn't been a single failed attempt in the previous month before the botnet sent 22115 emails from 9351 unique addresses (details here: http://pastebin.com/zMdyt1u9). A whois lookup on a sample of these addresses seems to show that the vast majority of them are from a small number of countries. I will appreciate anyone's advice about getting ipset working with iptables on my Debian Squeeze linode. Thanks, -Bart |
|
| Author: | Vance [ Fri Sep 28, 2012 10:07 pm ] |
| Post subject: | Re: ipset on Debian Squeeze |
Run a stock Debian kernel. |
|
| Author: | bartman [ Sun Sep 30, 2012 10:06 pm ] |
| Post subject: | Re: ipset on Debian Squeeze |
Excellent! Thank you, Vance; that's all I needed. Did as described, looks good, testing now. Regards, -Bart |
|
| Page 1 of 1 | All times are UTC-04:00 |
| Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |
|