Ubuntu: What is the difference between hosts and hosts.deny?

Question:

The question might seem trivial but for the last 36 months I have lived in the illusion that what I put in the hosts.deny file will stop my computer from visiting those sits. But some sites have still been coming through and establishing connections.

But last week I threw in my whole hosts.deny list into the hosts file and now everything that I wanted to block is blocked.

Why have a hosts.deny if having it in the hosts file does the trick?

What I mean by blocking is

127.0.0.1 somesite.topdomain

I asked a similar question a year or so ago, but by then I had not tried putting everything in the hosts-file and no one seemed to connect the dots.

Solution:1

They're used by different tools. See man hosts;man tcpd.

/etc/hosts.deny is part of the TCP Wrappers package tcpd (see Wikipedia), and acts as an intermediary between an inetd-like daemon, and the target TCP service, and is used as an access control mechanism for Incoming TCP connections.

/etc/hosts is part of how your system looks up URIs and translates hostnames to IP addresses, and is used for Outgoing TCP/IP requests.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com