Os dois são bem diferentes em suas funções.
-
/etc/hosts
é usado como um DNS local na sua instância localapache
ounginx
conforme o caso para mapeardomain names
para aip address 127.0.*.*
.From "man hosts": hosts - static table lookup for hostnames. So when we request a domain in our browser say "mydoman.com", our system checks in the /etc/hosts files to resolve this "domain name" to an "IP address". If we have that entry in the "/etc/hosts" file then the page content is served up from our machine files else it look out on the inter- net to resolve that name.
-
/etc/host.allow
e/etc/hosts.deny
são usados comoiptable
para controlar o acesso às origens externas da máquina ou da rede. Note que ambos iptables e acesso ao host não podem ser usados simultaneamente. É seu ou usando o mecanismo de controle de acesso do hostiptables
, ou o seu usando o mecanismoaccess control library
Example hosts file entries are # # hosts.allow This file describes the names of # the hosts that are allowed to use # the local INET services, as decided # by the '/usr/sbin/tcpd' server. # # Only allow connections within the virginia.edu # domain. ALL: .virginia.edu # # hosts.deny This file describes the names of # the hosts that are *not* allowed # to use the local INET services, as # decided by the '/usr/sbin/tcpd' # server. # # deny all by default, only allowing hosts or # domains listed in hosts.allow. ALL: ALL
Fontes:
man hosts, man hosts_access, virginia.edu