Hostnames, hosts and all that good stuff


Right well i've got two Linodes setup.

One is running apache + email (dovecot + postfix)

Other is running mysql

I have yet to point my domain at apache node yet as I am still fine tuning things.

One thing that has me stuck / stumped is the whole hostname / host business.

Lets say I am going to call them and

Running ubuntu 8.04.

I don't seem to have a /etc/hostname file, should I create it and just enter

node1 ?

Edit /etc/hosts which currently has localhost

and change to localhost node1

anything else?

What is these names actually used for?

Possible to screw something up

Should I also enter

node2's ip address node2

into that same /etc/hosts on node1?

If someone could push me in the right direction…..

6 Replies


Should I also enter

node2's ip address node2

into that same /etc/hosts on node1?

If someone could push me in the right direction…..

Sounds like a good idea. Make sure that you use private IP addresses in /etc/hosts from the network page. Then the traffic between the nodes won't count against your quota.

and the other stuff is all honkey dorey?

The hostnames you assign to your machines can be whatever you want. I like to add an A record for the name I pick to DNS, but that's optional. For your internal (LAN) addresses, just use /etc/hosts.

For example, here's one of my nodes:

dfelicia@catch-22 ~ $ hostname
dfelicia@catch-22 ~ $ hostname -f
dfelicia@catch-22 ~ $ cat /etc/hosts
# IPv4 localhost aliases       localhost      catch-22  jigani.local donsbox.local
dfelicia@catch-22 ~ $ nslookup

Non-authoritative answer:

dfelicia@catch-22 ~ $ nslookup

Non-authoritative answer:     name =

Authoritative answers can be found from: nameserver = nameserver =

So for LAN (which I use for distcc), I use the .local hostnames. I bind apache, dovecot, etc. to desired DNS name.

To clarify what I was trying to say w/my reply…

You can put DNS names in /etc/hosts on both machines. Not a bad idea, in case DNS fails (unlikely, but known to happen from time to time). In addition, you must put your local (private) names and IPs in /etc/osts. Names are arbitrary. I like to use append .local for easy identification.

So, you might have,, foo.local, and bar.local in you hosts files. The lines have your public (DNS) addresses. The .local lines have your private (LAN) addresses.

Bind mysql to your .local (private) address, and config Apache/whatever to talk to mysql using the .local (private) address.

Configured this way, the bandwidth doesn't count against your quota, not to mention throughput should be better.

Just wondering, how come on the foo machine you'd do foo.local

instead of foo.local

Wouldn't it be better to use it's loopback ip for the internals of the same machine.

I can see the point in doing bar.local

on the foo machine.

> Just wondering, how come on the foo machine you'd do foo.local…

What would be the advantage of mapping foo.local to loopback, given that you have a static private IP for it?

I only map hostnames (other than localhost) to loopback as a last resort. e.g. for DHCP hosts on networks that don't support dynamic DNS, but that run software that needs to resolve hostname to an IP. (e.g. Gnome used to fail if hostname didn't resolve to an IP, prompting RedHat's installer, among others, to map hostname to the loopback address by default; a decision that annoys me, personally. Solaris and other "real" UNIX systems don't do that.)

Mapping your FQN to loopback is known to break Java RMI, among other things.


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct