0

I have a few machines set up on my internal 192.168.1.* network and I have one public IP, my router is linked 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 hostname. 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?

--

1
  • Do you want multiple web servers on a unique machine, or on different machines, depending on the domain name?
    – Déjà vu
    Jan 14, 2011 at 18:50

3 Answers 3

0

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

2
  • 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. Jan 14, 2011 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, 2011 at 2:00
0

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

0

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.

You must log in to answer this question.