Hosts file on server with dynamic DNS?
Some context:
When a program asks your machine to resolve a hostname into a IP address it looks into your /etc/hosts
and, if not found, it then makes a DNS query.
You don't need to keep a non-loopback IP address on it. You can just usually keep the localhost
entries and an alias.
See, that's my /etc/hosts
contents:
[braga@coleman ~]$ cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
127.0.0.1 coleman.jazz coleman
::1 localhost6.localdomain6 localhost
coleman.jazz
or coleman
(named for the musician, Ornette Coleman) is just an alias for my machine.
Direct answers:
Just leave it out.
You can replace it wherever you want to. it's just an alias. You can even replace it with
www.google.com
(andwww.google.com
on your machine will point up to your own machine).
Related videos on Youtube
hpy
Updated on September 18, 2022Comments
-
hpy over 1 year
I am setting up a RHEL-based server that is associated with dynamic DNS from DynDNS, with a domain of, say, "abc.dyndns.org" that is dynamically updated with the server's IP address.
I have read that in order to ensure access to your server's services, you need to have at least the following in your /etc/hosts:
127.0.0.1 localhost.localdomain localhost
xxx.xxx.xxx.xxx redhatbox.yourcompany.com redhatbox
Where "xxx.xxx.xxx.xxx" is whatever IP address your server has, and "redhatbox" would be the name of the computer. So here are my questions:
(1) Because my server has an IP that is dynamically assigned by my ISP's DHCP, there is no one IP I can put in place of xxx.xxx.xxx.xxx, what should I do in this case?
(2) Should I simply replace "redhatbox.yourcompany.com" with my DynDNS domain "abc.dyndns.org"? And replace the "redhatbox" alias with "abc"?
If anyone can explain all this for a novice like me that would be great. Thank you very much for your detailed answers and patience.
-
hpy almost 13 yearsThanks. I really appreciate your clear explanation and especially direct answers!