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, Alias

104.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

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct