I was recently setting up an MTA on a VPS, and while configuring it I realized I’m quite confused about the concept and implementation of hostnames in Unix.
I have a solid understanding of the DNS, and I’m familiar with its predecessor, the hosts file, but I have no experience with classic, internal networks, as I have always worked with servers directly connected to the Internet.
There are a lot of contradictory explanations out there if one searches the subject, so, first of all, I would like to ask for a thorough introduction to hostnames (not just simple, but complex, multi-level names), completely independent of the DNS and the Internet, and then for an explanation of their relationship to the DNS, and the perplexing “fully qualified domain name” term (is this the same as in DNS, or something else).
I would also like to know which files and commands on a typical Unix box (or at least on Debian/Ubuntu) are playing a role in managing hostnames, especially:
- the role and correct setup of
/etc/hostname(simple or complex name? is this something with an A record?) - the role and correct setup of
/etc/hostsin regard to setting the hostname (is it not just for resolving? what names and where to point?) - any other files
- how to apply changes to the hostname without restart?
More detailed answers are preferred over ones that try to simplify the subject, since there’s a lot out there from the latter type, which is the source of the confusion.