Local dns for testing websites using mobile devices


I have no idea where to start from so sorry in advance if this topic has already been discussed.

I usually develop web sites using my laptop as a development server, and recently I needed to test a web site using various mobile devices that can connect via wifi. Having no real AP, I set up a ad-hoc network using my laptop's wireless card and the devices can correctly browse the Internet and access the laptop's web server. The setup is as follows:

  • subnet:
  • gateway to the Internet (wired adsl router/modem):
  • laptop: (eth0, wired if connected to the gateway) and (eth1, wifi if somewhat bridged to eth0)
  • mobile devices (same for all, I only use one of them at any time for simplicity): with default gw

Now, if I open either or from the mobile devices, I correctly get the default host of my Apache configuration. However I usually work with virtual hosts for many practical reasons, one of which being Drupal's peculiar implementation of multi-sites.
For those who don't know how this works, Drupal takes the request's hostname and searches into its sites/ subdirectories for an appropriate configuration file. So, for example, suppose I request www.example.com, then Drupal would search for a config file in the following directories:


So I decided to adopt the following style of virtual hosts: if the website I'm working on will be accessible using www.example.com I set up a sites/www.example.com/ directory and create a virtual host for local.www.example.com so Drupal have no trouble finding it.
I've been told this is suboptimal from a dns point of view since I'd have to create an authoritative entry for example.com and turn Bind on only when I'm supposed to access the local copy, which is weird. However, if this is the only path I can follow, I still have some problems with Bind's configuration, as I couldn't find any guide that tells me in a clear, noob-friendly way, how to set up such an entry.
On the other hand, I was wondering if I could set up an authoritative entry for local, so I could access www.example.com.local and tell in some way (which I don't even know if this is possible) Apache to put www.example.com instead of www.example.com.local in the relevant environment variable.

Anyway, I have a last problem, sort of: when I launch Bind in debug mode with high verbosity, and make as the primary dns for the devices, the output doesn't say anything about requests being made from the devices to Bind, so I'm not even sure it comes into play.

As you can see, I'm a complete noob at these matters, but I'm eager to learn, so any help/pointer will be appreciated.

Best Answer

sorry for the delay, I finally found a solution after lots of experiments. First of all, here's the zone file I use for the local. domain:

$TTL 1800

@       IN      SOA     local. root.porto.local. (
                        2010061500      ; serial
                        7200            ; refresh
                        3600            ; retry
                        604800          ; expire
                        1800            ; default_ttl

                NS      porto.local.

$ORIGIN local.

porto   IN      A
www             IN      A

to which I can add lines like

www.example.com IN      A

which results in the ability to query for www.example.com.local, and that's one thing.

In order to take into account of Drupal's weird behaviour, I actually found a solution that doesn't prevent me from working with the real remote www.example.com while working on a local copy, except that I had to set a zone for local.www.example.com and the host line for www which results in the odd and long www.local.www.example.com... frankly a bit too much to keep my mental health. I'll go for the local. way and s/.local// the database dump I'm going to deploy to the production server.

Thanks to everyone that replied.

Related Topic