Understand hosts file
I would like understand how work and which is the function
vi /etc/hosts
127.0.0.1 centos-server centos-server
I have a domain dns centos.myserver.com
I needed configure like a this?
IP Address, Hostname, Alias
104.190.173.15 centos.myserver.com centos-server
1 Reply
Hi @jbsystem -
To answer your immediate question:
I have a domain dns centos.myserver.com
I needed configure like a this?
IP Address, Hostname, Alias104.190.173.15 centos.myserver.com centos-server
Yes, that is how you'd want to configure it.
In the "good old days" of the internet -- before DNS and when the number of networks were relatively small -- the etc/hosts file was used for resolving IP addresses to domains. As things got more complicated, though, DNS took over.
In short, "The hosts file, located at /etc/hosts, creates static associations between IP addresses and hostnames, with higher priority than DNS." (From our Getting Started guide.)
I also wanted to point you to our Using Your System's hosts File, which provides more detailed information about different ways you may need to configure your hosts file, depending on your configuration needs.
Best,
Joe