13

I'm using Ubuntu 16.04. I recently started learning DevOps and got a bit crazy with my /etc/hosts and /etc/hostname files. In my frantic attempt to spin up a couple of servers from my local machine I lost track of the default settings, and was just curious to know what they are/were.

As I recall /etc/hosts and /etc/hostname had only one entry, which was the username of my local machine. However I'm not entirely sure.

By any chance does anyone know what the default settings are with a fresh install?

muru
  • 197,895
  • 55
  • 485
  • 740

1 Answers1

22

They are based on what you specified as the hostname when you installed: in my below examples "myhostname" is the name you chose. The defaults look a bit like this:

/etc/hostname

myhostname

/etc/hosts

127.0.0.1 localhost
127.0.1.1 myhostname

The following lines are desirable for IPv6 capable hosts

::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters

Note I don't put the domain part into /etc/hostname - opinion is divided on whether to do this but I've experienced server software that breaks if a FQDN is in /etc/hostname whereas I've so far had no issues caused by only the hostname there.

thomasrutter
  • 36,774