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.

My hosting provider set up an Ubuntu-based virtual private server for me with three public IPs. I want to assign hostnames to those IPs as follows (I'm be using Dyn as my DNS):

  • example.com -> IP_1
  • www.example.com -> IP_1
  • test.example.com -> IP_2
  • admin.example.com -> IP_3

www.example.com will be the production site. test.example.com will be the bleeding edge version of the site, used for testing, and admin.example.com will expose a number of site administration services (e.g. SSH, rsyncd). Both www and test will be locked down to port 80. Both test and admin will only accept traffic from certain IPs.

I'm a little confused about the difference between the hostnames DNS deals with, and the server's hostname (as seen when running `hostname' on the server's command line). Where does the server's hostname come into play?

My guess is that Apache 2 doesn't care what the hostname utility returns, because I can specify listening IP:PORT per VirtualHost. But, are they other services (or limitations) I should be aware of when connecting to my server via "foo.mydomain.com" if the machine's hostname is "randomname"?

share|improve this question
    
Why are you trying to separate the different names to different IPs? You've started your question with a proposed solution without telling us what problem you're trying to solve. You won't get good answers that way. –  David Schwartz Dec 11 '11 at 2:33
    
Motivation added, thanks. –  Chris Betti Dec 11 '11 at 5:12

3 Answers 3

up vote 2 down vote accepted

Hostnames make it easy distinguish between servers. See RFC-1178 Choosing a Name for Your Computer for more details. For what you are doing the server's hostname doesn't really matter. In your case your host will be hosting serveral FQDN (Fully Qualified Domain Names) to enable services. You could add more using addtional DNS CNAME or A records.

As you have a small site ALL of these domains refer to a single host. Larger services like google.com have multiple IP addresses backed by multiple servers. In some cases the IP addresses may belong to load balancers in front of multiple servers.

For an Apache server you should use IP based virtual hosting. You can use Apache ACLs and/or a firewall to restrict access. I use both when I can.

If you add a mail server there are additional rules which should be applied. The FQDN for the mail server should be the same as the name the Server announces. In addition, the IP address should have a PTR record returning that FQDN.

share|improve this answer

server hostname does not matter.. for apache.. your browser will for a http packet and put a http host header in the packet that will have the hostname you are hitting. Apache will then get the packet and check the host header and figure out which virtual host to send the request to based on the

servername or serveralias 

For other things generally it just makes a straight IP connection so whatever your hostname resolves to it just makes a connection to that IP on that port.

share|improve this answer

If you run any outgoing mail server, your smtp helo greeting and fqdn hostname should match, to avoid spam filters.

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.