Hosts file on server with dynamic DNS?

5,812

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:

  1. Just leave it out.

  2. You can replace it wherever you want to. it's just an alias. You can even replace it with www.google.com (and www.google.com on your machine will point up to your own machine).

Share:
5,812

Related videos on Youtube

hpy
Author by

hpy

Updated on September 18, 2022

Comments

  • hpy
    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
    hpy almost 13 years
    Thanks. I really appreciate your clear explanation and especially direct answers!