0

If I put the entry into /etc/hosts.deny, would it block all requests from that IP address to my machine (like iptables do), or would it only block access for some applications like SSH?

h22
  • 254
  • 2
  • 9

2 Answers2

5

Iain's Reading Manuals As A Service at your erm service ...

It depends

If you put

ALL: 192.0.2.1, example.com

It will block access to ALL suitably compiled services for the listed hosts.

If you put

sshd: 192.0.2.1, example.com

then access to sshd will be blocked for the listed hosts, providing the sshd has been suitably compiled.

For a service to take advantage of hosts.deny|hosts.allow, it has to be tcpwrapper aware, not all services are.

In general you and check to see if a service is tcpwrapper aware like by looking for libwrap in the output of ldd for the binary e.g.

ldd /usr/sbin/sshd | grep libwrap
libwrap.so.0 => /lib64/libwrap.so.0 (0x00007fae25ae7000)

so in this case sshd is tcpwrapper aware.

user9517
  • 115,471
  • 20
  • 215
  • 297
1

If you are talking about a standard linux distro, then it depends on the application. The question being about port 80, I'd be inclined to answer no, as most webservers I'm aware of (most notably, apache) are not compiled against the tcpwrapper library - which is what makes applications aware of hosts.{allow,deny} directives.

Webservers have - of course - their own way of shutting out unwanted clients. If you do not want to depend on app-specific methods, however, a low level firewall (such as the mentioned iptables) is the surest way.

Alien Life Form
  • 2,309
  • 2
  • 21
  • 32