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 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 192.168.1.3. 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.83.22.56.12 would find my box then forward to 192.168.1.4 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 192.168.1.2-10. 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:

domain.com -> router -> main box on public ip

box2.domain.com -> router -> 192.168.1.3

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? –  ring0 Jan 14 '11 at 18:50

3 Answers 3

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 example.com and this is the zone file for example.com:

@        IN    A       my.ip.is.here
www      IN    CNAME   example.com.
apache   IN    CNAME   example.com.
vhost    IN    CNAME   example.com.

This allows external hosts to resolve example.com, www.example.com, apache.example.com, and vhost.example.com. 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: http://httpd.apache.org/docs/2.0/vhosts/examples.html

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: http://www.howtoforge.com/two_in_one_dns_bind9_views http://www.cyberciti.biz/faq/linux-unix-bind9-named-configure-views/

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

 
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.