Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm inexperienced with server administration and in the process of learning how to properly assign a domain name to a server. I'm trying to figure out if I should enter the server's hostname into the DNS zone file as a subdomain, or if this is not necessary.

Here's an overview of what I've done so far, starting from registering the domain and pointing it at the server's IP:

  • I've set the server's hostname to "foo" (not actually foo, but it will do for the purpose of the question).
  • I've edited /etc/hosts so it contains a line " foo.thedomain.tdl foo".
  • I've added "domain thedomain.tdl" and "search thedomain.tdl" to /etc/resolv.conf.
  • I've set up reverse DNS for the server to be "thedomain.tdl".

Following a reboot, the output of hostname, hostname -d and hostname -f are "foo", "thedomain.tdl" and "foo.thedomain.tdl", which as I understand is how it should be.

What I'm wondering now is whether I should be doing the following: Add a foo subdomain to the DNS config for thedomain.tdl, so that "foo.thedomain.tdl" is also resolvable from outside the server. Is this necessary/expected for correct operation of services such as mail (send and receive) or HTTP down the line?

If anyone has good general tutorial-with-context style documentation on domain/DNS config and implementation on actual servers to recommend I'd also appreciate it. Thanks!

share|improve this question

2 Answers 2

The hostname should be in DNS. Regardless of "server" or "client" or whatever else.

share|improve this answer

There are servers, and there are servers.

There are servers which belongs to an Autonomous System, and there are servers that just have an IP assigned, whose AS belongs to another provider (who "rents" the IP for you).

If you have your own AS, then it's best practice to have the DNS reflecting your servers and clients, with proper reverse lookup resolutions. But, if you just have a bunch of DNS servers, webservers, and database servers, maybe there's no need to advertise name resolution outside of DMZ for the database server, just for the webservers and dns servers, and maybe you'll end up having more services being served at one physical server.

In any case, it is IMO a good option not use resolution relying on /etc/hosts, because if you ever need to migrate servers from one provider to another, to have a centralized way of changing your application behaviour by just updating name resolution in one central point (DNS) instead of changing several /etc/hosts file, it's more practical.

In the other hand, you don't necessarily HAVE to be paranoid about it. Only your name servers and webservers should have DNS names, and you can always set resolution using /etc/hosts to other servers.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.