View Full Version : hosts.deny vs iptables

14th April 2008, 11:18 PM
Having trouble and I'm sick and tired of asian countries trying to hack my server. I would like to either add a list to my hosts.deny file or add iptable rules. My question, is there a way to easily add all ip addresses of asian coutries to my iptable filter. Also I'm not quite sure the correct way to add a list of ip addresses to my hosts.deny file. This is what I'm thinking:

ALL : x.x.x.x,

Will this work?

Find a great selection of BMX, Skateboard and Motocross stuff at http://www.xoutfitters.com

14th April 2008, 11:33 PM
Wouldn't it be easier to install something like denyhosts or fail2ban (both in repositories) to automatically ban ips which try to ssh (both) or ftp (fail2ban only) your server with invalid credentials more than a certain amount of times?

This way you do not have to look for many many many ips and/or ip spaces to ban.

If you still want to manually restrict ip ranges via hosts.deny you really should use sth. like this:

ALL: 127. 192. this should prevent logon from networks starting with "127" (e.g. localhost) and "192". Note the space between "127." and "192." (a comma would work as well).

You can also look through the manual via:
man hosts_access

15th April 2008, 12:32 AM
I'm thinking that hostsdeny only works on ftp, ssh. I don't even want asian countries to send me any requests for ANY PORT.

You can find all your Motocross gear here at http://www.findmotocrossparts.com

15th April 2008, 12:38 AM
So, hosts.deny would look like:

ALL : 58. 59. 60. 61. 116.