0

I have a domain test.dev bound to 127.0.0.1 in /etc/hosts. How can I bind all the subdomains, e.g. any.th.ing.test.dev to 127.0.0.1 as well?

2 Answers 2

1

This is actually dead-simple with dnsmasq:

# install dnsmasq
sudo apt-get install dnsmasq
# map anything ending in .dev to 127.0.0.1
echo address=/dev/127.0.0.1 | sudo tee /etc/dnsmasq.d/dev
# restart to make it read new config
sudo service dnsmasq restart
# verify it's working
host gsdf.gsd.fg.sdf.g.dev                               
# gsdf.gsd.fg.sdf.g.dev has address 127.0.0.1
0

/etc/hosts (where you'd make an edit) doesn't allow wildcards. This leaves you with two choices:

  1. Do without automatic subsdomains and just edit /etc/hosts each time you want a new one.

  2. Push all your DNS through a crazy DNS proxy (per this answer) and change your network settings to the proxy. This will likely slow anything that makes a DNS query down a little but should let you do anything you like with domains.

I personally settle for just setting them myself. It only takes 10 seconds. But you might have different, stranger requirements.


Edit: Just had an idea. If you have a real domain (with real DNS hosting) you could set *.local.mydomain.com to point to 127.0.0.1 and that should work.

3
  • It looks like people are using bind9 to solve the problem? Do you have any experience with it?
    – Fluffy
    Jan 11, 2012 at 12:09
  • I'd lump that in with the crazy DNS proxy - which is essentially what it would be, just harder to configure. I don't have any experience with BIND9 but there is a help page. You'll need to make sure you're using the forwarders setting to make sure DNS queries that your local DNS can't resolve are passed onto your ISP. But yes, certainly an option.
    – Oli
    Jan 11, 2012 at 12:28
  • So from that help file, you want to mix the "Caching Server configuration" and "Primary Master Server configuration".
    – Oli
    Jan 11, 2012 at 12:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .