I've recently been "forced" to perform some sysadmin work, while this isn't something that I absolutely love doing I've been reading, experimenting and learning a lot.
There is one fundamental aspect of server configuration that I've not been able to grasp - hostnames.
In Ubuntu for instance, one should set the hostname like this (according to the Linode Library):
echo "plato" > /etc/hostname
hostname -F /etc/hostname
File: /etc/hosts
127.0.0.1 localhost.localdomain localhost
12.34.56.78 plato.example.com plato
I assume that plato
is an arbitrary name and that plato.example.com
is the FQDN.
Now my questions are:
- Is it mandatory?
- To what purpose?
- Where is it needed / used?
- Why can't I define "localhost" as the hostname for every machine?
- Do I have to set up a DNS entry for the
plato.example.com
FQDN? - Should
plato.example.com
be used as the reverse DNS entry for my IP?
Also, are there any "best practices" for picking hostnames? I've seen people using Greek letters, planet names and even mythological figures... What happens when we run out of letters / planets?
I'm sorry if this is a dumb question but I've never been too enthusiastic with network configurations.
Answer
These days, a system may have multiple interfaces, each with multiple addresses, and each address may even have multiple DNS entries associated with it. So what does a "system hostname" even mean?
Many applications will use the system hostname as a default identifier when they communicate elsewhere. For example, if you're collecting syslog messages at a central server, the messages will all be tagged with the hostname of the originating system. In an ideal world you would probably ignore this (because you don't necessarily want to trust the client), but the default behavior -- if you named all your systems "localhost" -- would result in a bunch of log messages that you wouldn't be able to associate with a specific system.
As other folks have pointed out, the system hostname is also a useful identifier if you find yourself remotely accessing a number of system. If you've got five windows attached to a systems named "localhost" then you're going to have a hard time keeping them straight.
In a similar vein, we try to make the system hostname matches the hostname we use for administrative access to a system. This helps avoid confusion when referring to the system (in email, conversations, documentation, etc).
Regarding DNS:
You want to have proper forward and reverse DNS entries for your applications in order to avoid confusion. You need some forward entry (name -> ip address) for people to be able to access your application conveniently. Having the reverse entry match is useful for an number of reasons -- for example, it helps you correctly identify the application if you find the corresponding ip address in a log.
Note that here I'm talking about "applications" and not "systems", because -- particularly with web servers -- it's common to have multiple ip addresses on a system, associated with different hostnames and services.
Trying to maintain name to ip mappings in your /etc/hosts
file quickly becomes difficult as you manage an increasing number of systems. It's very easy to for the local hosts file to fall out of sync with respect to DNS, potentially leading to confusion and in some cases malfunction (because something tries to bind to an ip address that no longer exists on the system, for example).
No comments:
Post a Comment