Ubuntu – localhost as hostname confusion

dnslocalhostnetworkingubuntu 12.04

I have a basic understanding about hostname and FQDN. Now I am confused, do I really have to specify a name for my hostname? So for example:

Hostname: somename
Domain: mydomain.com
FQDN: somename.mydomain.com

Now, I see something that the hostname is localhost. What is the difference and impact of that? So my FQDN if localhost is my hostname would be localhost.mydomain.com, right?

Best Answer

localhost is a "special name" which points to the IP address 127.0.0.1 which is supposed to exist on any computer capable of using the Internet, and refers to the machine itself. (Any IP address starting with 127.x.x.x refers to the local machine).

localhost is not the same as localhost.mydomain.com.

The file /etc/hostname appears what your computer thinks its name is. In Debian it appears to link 127.0.1.1 to this name in the /etc/hosts file. [ You could probably set this to a "valid" IP address if you have a statically assigned one ]

Ideally you should not use "localhost" as your hostname as it will (in theory, can't think of any examples as I have not done it) cause issues with some programs.

Related Question