[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Setting up bind9/DNS



On 6/28/19 12:44 PM, Dennis Wicks wrote:
Greetings,

I have apache2 installed on my local machine with a bunch of virtual hosts that I use for test and development of html, wordpress, etc. It works fine to access the virt hosts locally, but I want to access them from other systems on my local network; windows/IE of various versions, smart phones, tablets, laptops, etc.

They all can access my base host name because my DSL modem/router has DHCP and DNS in it and when it sets up an address with DHCP it puts an entry in its DNS and everything is fine. (All systems on the local net use the modem/router for dns.) But nothing like this happens with the virtual hosts!

I was thinking that I could setup a nameserver on my machine with enries in it for the virtual hosts and have my local network address in the list of nameservers in my modem/router, and that is where I need the help.

I have installed bind9, running on buster. So how do I set up the name server and populate it with the info for my virtual hosts? Pointers to forums, cookbooks, etc. would be appreciated as well as hints and tips!

TIA!
Dennnis

First you will need to read about Apache virtual hosts here:

http://httpd.apache.org/docs/current/vhosts/name-based.html

Basically what happens is the browser sends the name that it is trying to reach in its header and Apache uses that info to direct that request to the appropriate directory.  All the different names will point to the same address ... the address of your host.  To use bind for this then all your hosts on your network will have to use the bind DNS server as their DNS server.  I use a debian box as my router/firewall so it is easy for me to change DNS entrys for my home network.  

It might be easier if your router would allow you to add entries to its DNS server.  If not then you could use each machines hosts file to put in your private addresses.  You will have to make up your own names.  Example:

host1.home

cookbook.home

forum.home

These would all point to the address of host1 but Apache would be able to direct the requests to different directories under /var/www depending on the name used.  I use this method on a VM at digital ocean to serve 4 or 5 different web sites from the one address.  

Your apache config might look like this:

<VirtualHost *:80>
    ServerName host1.home
    DocumentRoot "/var/www/host1"
</VirtualHost>

<VirtualHost *:80>
    ServerName cookbook.home
    DocumentRoot "/var/www/cookbook"
</VirtualHost>

etc...

Make sure all the files under /var/www are owned by www-data and group www-data (chown www-data.www-data files). 

--


...Bob

Reply to: