In Linux, a server can set its own host-name and domain-name through sethostname() and setdomainname().

I just wonder, however, why must a server know its own host-name and domain-name?

To my knowledge:

  1. It is enough for a server to know its own IP address, net-mask, gateway.

  2. Only the DNS servers must know the host-name and domain-name of a certain server.

Any explainations?

  • Having a host name distinguishes it from all other systems. It's very useful for email, or for when you have to identify a system in a rack full of many systems. Email doesn't require use of IP. – Mark Plotnick Feb 26 '15 at 16:44
  • @MarkPlotnick, If the admin can set the host-name and domain-name arbitrarily, then how to ensure its uniqueness? And, how do other servers know the change? – xmllmx Feb 26 '15 at 16:46
  • 1
    You need to coordinate things with your peers if you don't want name conflicts. A domain name can only have one owner. Within a domain, you'd typically have someone or something coordinate host names (for instance, a DNS server that won't let you pick a host name that's already in use). Spammers, of course, don't care about receiving email and will happily re-use someone else's host name and domain names. And at a company, you'll find people who set up their own PC and pick a duplicate name like "gandolf", and an arbitrary unused IP address. Then the admins need to find them and fix things. – Mark Plotnick Feb 26 '15 at 16:53
  • And I should have said "email doesn't require IP if the email remains local to the system or uses something like uucp for transmission. In the first case, you won't need a host name, but in the second case, you will." – Mark Plotnick Feb 27 '15 at 8:03

Your Answer

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

Browse other questions tagged or ask your own question.