/etc/hosts, /etc/hosts.allow, /etc/hosts.deny
/etc/hosts
The /etc/hosts
file acts as a local database to provide information for DNS resolutions, in the form of mapping hostnames (or fully qualified domain names - FQDN) to IP address values.
The following is the general format for each line in the file
Eg. Mapping hostname jarrettgxz.com
to the IP address value of 8.8.8.8
Multiple hostnames can be included for each IP address value
The second line maps the hostnames
example.com
andexample2.com
to the IP address10.10.10.10
.
/etc/hosts.allow and /etc/hosts.deny
The /etc/hosts.allow
and /etc/hosts.deny
files are used to allow or restrict access to local services for specific IP addresses or hostnames.
General format of entry
Note that
/etc/hosts.allow
takes precedence over the/etc/hosts.deny
file
Eg. Allow or deny access all traffic to the sshd service
Eg. Allow or deny access to all traffic from *.example.com
: test.example.com
, 1.example.com
, etc. to the sshd service
Eg. Allow or deny access to all traffic from 192.168.1.*
: 192.168.1.1
, 192.168.1.88
, etc. to the sshd service
Last updated