2

I'm learning about setting up my own web and mail servers, and I've been confused about this question for days, and articles online (including Server Fault) seems to be so inconsistent with their use of the term 'subdomain' and 'hostname'.

From my understanding:

  1. A host name uniquely identifies a computer in a network
  2. A domain and subdomain must have a DNS A record which points to one or more hosts

Let's say my web server is at 1.2.3.4, I have my host name set to development (confirmed by running hostname in bash shell), and I'm setting A records like so:

@   -> 1.2.3.4
www -> 1.2.3.4
mx  -> 1.2.3.4
mx  -> 9.8.7.6

Then I have the www and mx subdomains pointing to my web server whose hostname is development. The mx subdoman also points to two hosts (for redundancy).

Why do I need a hostname? My machine can already be identified using its IP address.

I read somewhere that says a hostname is important because it gets sent in some messages. But if my server is both a mail server, and a file server, and a database server, and etc, what should I set my hostname to be? I certainly don't want someone receiving my mail to see a from address of development. And a machine can only have one hostname right? Should I set my computer's hostname to abc.example.com or just abc?

Main Question

How to set hostname if hosting multiple servers on the same machine?

  • a server is a machine physical or virtual. – c4f4t0r Jan 29 '15 at 15:08
  • @c4f4t0r Are you saying my mail server can have one host name, my file server can have another host name? – dayuloli Jan 29 '15 at 15:09
  • 1
    try to find the different between dns and hostname – c4f4t0r Jan 29 '15 at 15:41
2

The hostname is a convenience for uniquely identifying the host on your network. It's an entirely internal name that can be anything you want. The hostname doesn't have to be related to any of its DNS names.

For example, your host named abc can have DNS records that point to it as www.example.com, mail.example.com, and so on.

If you run local DNS within your LAN, you can also give your host a local DNS name of abc or abc.localdomain, so you can type http://abc into your browser. Again that just helps you to identify the host within your LAN.

  • But how come (if hostname has nothing to do with DNS records), one time I tried sending an email to myself from my server, and it arrived saying it's from dayuloli@development. dayuloli is my username on the server, and development is my machine's hostname – dayuloli Jan 29 '15 at 15:12
  • 2
    because the email used hostname - do a small experiment: Try to resolve the fqdn and then try to resolve the hostname only. – thanasisk Jan 29 '15 at 15:16
  • An example of why a unique identifier is needed is reverse DNS. RFCs state that PTR records should point at the unique canonical name of the device associated with a given IP address. A server could be providing numerous functions each with their own A record (www, mail, etc.), but those are all logical aliases. The uniquely identifying name for that device would be the hostname. – Andrew B Jan 29 '15 at 16:04
0

To answer your question - the hostname should be whatever is meaningful to you or your organisation.

Hostname

The hostname is used only by the host. It's used by the system and services as a default (human-readable?) identity when no context-specific identity has been specified.

It might be used in a log file; it's probabaly used on your shell to give you an indication of which host you're administering; as you've pointed out, the default domain name for your mail server is your hostname, but this will need to be configured.

DNS

In your situation DNS is used by anything on the internet, trying to find its way to your server. That's all - a name referring to an IP address. You have multiple records pointing to the same server which can be used by applications and services to decide what to do with requests, which website to display for example, or which mailbox to deliver an email to. You need to tell the serveices what the domain names should mean to them, but they don't really mean anything to the host itself.

It would be wrong to say that the two are unrelated because often there will be a DNS infrastructure that is managed internally (on a LAN or WAN), or a de-centralised name discovery method like NetBIOS or MDNS. In these cases, the hostname would be used to identify or register the host within that naming service. However, from what you describe of your environment they seem to have no relation at present.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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