Welcome to the Community Site!

You've been redirected here from forum.linode.com. This is your new place to find answers, ask questions, and help others.

Join our Community
X

Hostnames, hosts and all that good stuff

o/

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

node1.mydomain.com and node2.mydomain.com

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

127.0.0.1 localhost

and change to

127.0.0.1 localhost node1 node1.mydomain.com

anything else?

What is these names actually used for?

Possible to screw something up

Should I also enter

node2's ip address node2 node2.mydomain.com

into that same /etc/hosts on node1?

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

6 Replies

@Wizzard:

Should I also enter

node2's ip address node2 node2.mydomain.com

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
catch-22
dfelicia@catch-22 ~ $ hostname -f
catch-22.donsbox.com
dfelicia@catch-22 ~ $ cat /etc/hosts
# IPv4 localhost aliases
127.0.0.1       localhost
207.192.69.157  catch-22.donsbox.com      catch-22
192.168.133.15  jigani.local
192.168.133.149 donsbox.local
dfelicia@catch-22 ~ $ nslookup catch-22.donsbox.com
Server:         207.192.69.4
Address:        207.192.69.4#53

Non-authoritative answer:
Name:   catch-22.donsbox.com
Address: 207.192.69.157

dfelicia@catch-22 ~ $ nslookup 207.192.69.157
Server:         207.192.69.4
Address:        207.192.69.4#53

Non-authoritative answer:
157.69.192.207.in-addr.arpa     name = donsbox.com.

Authoritative answers can be found from:
69.192.207.in-addr.arpa nameserver = ns1.nac.net.
69.192.207.in-addr.arpa nameserver = ns2.nac.net.

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.example.com, bar.example.com, foo.local, and bar.local in you hosts files. The example.com 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

192.168.133.15 foo.local

instead of

127.0.0.1 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

192.168.133.16 bar.local

on the foo machine.

> Just wondering, how come on the foo machine you'd do 192.168.133.15 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.

Reply

Please enter an answer
Tips:

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] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct