• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 483
  • Last Modified:

hosts.deny not working

I stuck an IP wildcard (180.76.) into my /etc/hosts.deny file, and I rebooted, but it's not working. I'm still seeing access from that subnet in /usr/local/apache/logs/access_log

What more do I need to do?
0
jmarkfoley
Asked:
jmarkfoley
  • 2
  • 2
1 Solution
 
savoneCommented:
Can you post your hosts.deny file?  

Your line should read:

ALL  : 180.76.

That will block access to all services from the 180.76.0.0 network.
0
 
legolasthehansyCommented:
It doesn't work unless TCP wrappers is compiled in for Apache. I would suggest IPtables.
0
 
jmarkfoleyAuthor Commented:
savone: yes, that is what I have. Copy/pasted right from my hosts.deny:

ALL: 180.76.

legolasthehansy: but I thought the host.deny was for everything, not just apache? I.e., it would prevent access from that IP for all services including ftp, http, smtp, pop, etc. ALL should deny everything, right? It doesn't make sense that port 80 would foward anyway.

However, httpd is not specified in inetd, so would that be the problem with hosts.deny?

If I do use ip_tables, would the following be the correct directive?

iptables -A INPUT -s 180.76. -j DROP
iptables -A OUTPUT -d 180.76 -j DROP

hosts.deny would be simpler if that is a viable solution.
0
 
legolasthehansyCommented:
hosts.deny and .allow only work for programs that are tcp wrapped.
Here is how you do it on iptables though
 iptables -A INPUT -s 180.76.0.0/subnet -j DROP

I agree tcpwrappers are easy.. :)
0
 
jmarkfoleyAuthor Commented:
Thanks, iptables appears to have done the trick. I've also added that IP to hosts.deny
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now