Networking – Creating Alias to Domain Name with /etc/hosts

hostnamehostsnetworking

I have a domain setup to point to my LAN's external IP using dynamic DNS, because my external IP address changes frequently. However, I want to create an alias to this host, so I can access it with home. So I appended the following to my /etc/hosts:

domain.com home

However, it doesn’t seem to like the domain name. If I change it to an IP:

0.0.0.0 home

… then it works, but of course this defeats the purpose of dynamic DNS!

Is this possible?

Best Answer

The file /etc/hosts contains IP addresses and hostnames only. You cannot alias the string "home" in the way that you want by this method.

If you were running your own DNS server you'd be able to add a CNAME record to make "home.example.com" an alias for "domain.com", but otherwise you're out of luck.

The best thing you could do is use the same DNS client to update a fully-qualified name.

Related Question