Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a few machines set up on my internal 192.168.1.* network and i have one public ip, my router is links all ports to on internal linux machine on my network I want to know how to configure the DNS server on my linux box to forward to internal LAN ip's depending on the host name. EG. computer4. would find my box then forward to on the local network.

This is so i can run multiple web server under one ip. btw, i use Ubuntu.

Thanks Dave

Edit --

Sorry for the confusing question, i may have asked it drunk. What i meant was i have multiple linux boxes behind my routers NAT they all have a local IP I have one public IP which just points to the router (another linux box) i want that to direct to one of the boxes by the subdomain/hostname. For example: -> router -> main box on public ip -> router ->

Hope that help? Can you help me?


share|improve this question
Do you want multiple web servers on a unique machine, or on different machines, depending on the domain name? – ringø Jan 14 '11 at 18:50

You don't need to do this. You can use the virtualhosts feature if you're using Apache.

share|improve this answer
Name-based virtual hosting is not an Apache-only feature, it's part of the HTTP standard. So... I use it with lighttpd, but all current HTTP servers support it. – Jürgen A. Erhard Jan 14 '11 at 19:14
Ah. I didn't think it was Apache-only, but I wasn't sure how many other servers supported it. Also - part of the HTPP standard? Wow. – Harv Jan 16 '11 at 2:00

First, Harv is correct in saying that you can use virtualhosts to make a single apache server serve multiple websites. If you would prefer to use separate physical hosts or server instances (perhaps you'd like run both IIS, aolserver, and apache?) this is also possible.

For both, add an entry in your external DNS for each servername you'd like. For instance, assuming your domain is and this is the zone file for

@        IN    A
www      IN    CNAME
apache   IN    CNAME
vhost    IN    CNAME

This allows external hosts to resolve,,, and All requests on a single port have to be forwarded to a single host: the only way to use multiple hosts would be to have some sort of filter: you could have firewall rules (iptables) or use a proxy like squid.

If you don't wish to have multiple hosts (much easier) just include a section for each in your apache configuration. Given that you use Ubuntu, I think they are usually installed in /etc/apache2/sites-available with a symlink in /etc/apache2/sites-enabled when they're made active. Try this:

cd /etc/apache2/sites-available
cp the-default-site-file-name mysite
cd ../sites-enabled
ln -s ../sites-available/mysite 01mysite

Edit the mysite file to point to a different documents folder and change the ServerName to one of the vhosts

share|improve this answer

I found the wording of this question confusing. I can assume you are asking one of two questions.

1) Can a single web server host multiple sites with one IP? The answer is yes. Use the following link to learn about it:

2) Can BIND be used to resolve names differently for internal machines and external machines? The answer is yes. Have a look at one of these links:

I've used the howto forge article many moons(years) ago. You may need to do further research on BIND "views"

You will need both the parts configured on the one server if the two services are on the same machine. First you need to resolve the host in DNS (properly setup views) And then you need to setup Apache to respond to each requet based on the requested domain.

share|improve this answer

Your Answer


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.