31 July 2013

Setup local DNS server to bind ALL subdomains

There is various situation where binding ALL subdomains to a specific applications (local or intranet) can be needed; for instance
working with Tomcat.

Let's say:
 - you want to create a main domain tomcatserver.test (IMPORTANT: avoid .local subdomain which is NOT compatible with some system)
 - bind all subdomains
 - your Internet Provider DNS are and
 - computers are all on network 192.168.0/24
 - the @IP of the server computer is
 - your Tomcat applications can be reached via

Install and configure DNS server

 - install bind, for instance under GNU/Linux Fedora :
yum install bind

 - define configuration of bind (the following option allows use of only IPv4), editing file /etc/sysconfig/named

 - edit the main configuration file /etc/named.conf, and update the following lines to allow access for all computers on network (adapt @IP)
       listen-on port 53 {; };
       allow-query     { 192.168.0/24; };

 - add this line at the end of the same file
include "/etc/named.conf.tomcatserver.test";

 - create the domain configuration file /etc/named.conf.tomcatserver.test
zone "tomcatserver.test" IN {
type master;
file "/etc/named.conf.tomcatserver.test.zone";

 - create the zone file /etc/named.conf.tomcatserver.local.zone (adapt @IP of your server and DNS)
@       IN SOA  @ ns.tomcatserver.test. (
                                        9       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
* IN A

@ IN A
www IN A
* IN A

 - you can add several others information like MX (Mail eXchange) ...

 - register your local DNS server adding this line at begining of /etc/resolv.conf (adapt @IP)

 - [re]start the DNS server
service named restart

Update rules of your Firewall

You must update your Firewall to allow computers of the network to use this DNS server (port 53).

Added a new VirtualHost

Eventually, create a VirtualHost with Proxy mod allowing to 'redirect' request from just created domain, to the Tomcat application.
 - create the file /etc/httpd/conf.d/myTomcatApplication.conf

    ServerName tomcatserver.test
    ServerAlias *.tomcatserver.test
    ProxyRequests Off
    ProxyPreserveHost On
        Order deny,allow
        Allow from all
    ProxyPass /
    ProxyPassReverse /

 - restart your HTTP server
service httpd restart

That's it !
Any computers on local network can now access tomcatserver.test and any *.tomcatserver.test subdomains to reach your Tomcat application, usually available under

No comments:

Post a Comment

Thank you for your visit, let's share your point of view: