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'm trying to get wildcard DNS enabled on my laptop using dnsmasq. I realize that this has been asked and answered more than once on this forum, but I can't get the solution to work for me.

Steps taken so far:

  • Installed dnsmasq
  • Set address=/example.dev/127.0.0.1 in dnsmasq.conf
  • Set listen-address=127.0.0.1 in dnsmasq.conf
  • Ensured nameserver 127.0.0.1 is in /etc/resolv.conf
  • Set prepend domain-name-servers 127.0.0.1; in /etc/dhcp3/dhclient.conf
  • Created a vhost for example.dev
  • Restarted apache and dnsmasq

Note: example.dev is not set in /etc/hosts

My vhost for example.dev

<VirtualHost *:80>
        ServerName example.dev
        DocumentRoot /home/jkendall/public_html/example/public
        ServerAlias *.example.dev

        # This should be omitted in the production environment
        SetEnv APPLICATION_ENV development

        <Directory /home/jkendall/public_html/example/public>
                DirectoryIndex index.php
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>

The setup above will server example.dev locally without any problem. It will also serve test.example.dev, but test.example.dev returns the default apache "It works!" index.html from /var/www rather than my index.php in /home/jkendall/public_html/example/public.

The solution in this Server Fault thread suggests that

address=/.example.dev/127.0.0.1

would resolve my problem, but when I try to use that solution, restarting dnsmasq results in a failure with the error message

dnsmasq: error at line 62 of /etc/dnsmasq.conf

For grins, I moved my project over to /var/www/example and modified the vhost appropriately. I got the same result as described above.

At this point I'm not sure what other steps I can take to resolve the issue. Thoughts?

share|improve this question
add comment

2 Answers 2

up vote 0 down vote accepted

It seems I've been laboring under a fundamental misunderstanding of dnsmasq, vhosts, and dns. dnsmasq was doing exactly what it was supposed to do, routing requests for example.dev to 127.0.0.1. While I did have vhosts set up, and set up properly, there was no local DNS server to respond and direct those requests to the proper place.

What finally solved my problem was installing bind9, creating a zone for example.dev, and then adding an A record for the wildcard subdomain.

Here are the details:

  • Installed bind9 via Synaptic Package Manager
  • Added a zone to named.conf.local
  • Copied /etc/bind/db.local to /etc/bind/example.dev
  • Edited the new zone file appropriately for my needs.
  • Tested
  • Danced a victory dance

Here's my named.conf.local

zone "example.dev" {
    type master;
    file "/etc/bind/example.dev";
};

Heres my db.example.dev

;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     localhost. root.localhost. (
                       201005173       ; Serial
                        604800         ; Refresh
                         86400         ; Retry
                       2419200         ; Expire
                        604800 )       ; Negative Cache TTL
;
@       IN      NS      localhost.
@       IN      A       127.0.0.1
example.dev     IN      A       127.0.0.1
*       IN      A       127.0.0.1
@       IN      AAAA    ::1

I will not be providing an example of the victory dance.

share|improve this answer
add comment

I have the exact same setup as you described in your question with one addition: In my Apache vhost Listen 80 and NameVirtualHost *:80 is set. This should connect the apache to port 80 - where you browser is listening and this might be the part, that your initial setup is missing.

If you can restore your initial setup (yes I know, it was 1/2 year ago) you also need to test, if dnsmasq is working properly by calling dig example.dev | grep SERVER (which should return ;; SERVER: 127.0.0.1#53(127.0.0.1).

share|improve this answer
add comment

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.