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
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.
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.
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.
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