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.

Me, and a small group of developers have just moved to a new office, and I'd like to set up dnsmasq on our development server, so when we deploy web apps there, we don't have to edit our own hosts files. We have a router at 192.168.3.1 which we don't have access to. I figured I'd install a DNS server on the development box, and we all record it's IP as a secondary DNS server. Unfortunately I'm strugling to make this work.

The name of the devel server is devbox, it's IP is 192.168.3.99, and it's running the latest Ubuntu Server (Karmic)

My computer is running Ubuntu Desktop (Karmic)

What I'd like to achieve

Let's say I have three websites, website1, website2, website3, running on the development box. I'd like to access them by the urls:

http://website1.devbox
http://website2.devbox
http://website3.devbox

So I have configured Apache on the devel box, installed dnsmasq, and put the following lines into it's hosts file:

192.168.3.99 website1.devbox
192.168.3.99 website2.devbox
192.168.3.99 website3.devbox

and edited my own resolv.conf file to include the devel box as a nameserver:

nameserver 192.168.3.99 

It's working fine, I can access the sites. The problem is that it doesn't scale well. I'd like all the domains ending with .devbox forwarded to the development box, and this is what I'm struggling with.

I have tried putting

192.168.3.99 devbox

into the hosts file, and editing the line in dnsmasq.conf:

# Add local-only domains here, queries in these domains are answered
# from /etc/hosts or DHCP only.
local=/devbox/

But I cannot get it working. If I try any url that is not explicitly present in the development box's hosts file, the dns lookup fails.

Is the local directive for something else? Am I looking at the wrong place?

share|improve this question
add comment

migrated from superuser.com Apr 27 '10 at 17:09

This question came from our site for computer enthusiasts and power users.

1 Answer

up vote 4 down vote accepted

Refer to the DNSmasq documentation, especially the dnsmasq manpage and sample configuration file. The local keyword tells DNSmasq to perform those domain lookups with local data. This affects requests send to DNSmasq for foo.localnet and bar.localnet, for example. I don't think this is what you want.

# Add local-only domains here, queries in these domains are answered
# from /etc/hosts or DHCP only.
local=/localnet/

To force host/subdomain lookups to resolve to a specific address, you'd probably want to use the address keyword. The second example below should allow web1.devbox and web2.devbox and web73872.devbox to all resolve to the address specified.

# Add domains which you want to force to an IP address here.
# The example below send any host in doubleclick.net to a local
# webserver.
address=/doubleclick.net/127.0.0.1

# for your example
address=/devbox/192.168.3.99

I use DNSmasq at home to handle simple DNS stuff for my LAN; in that case, local and the associated domain and expand-hosts keywords are appropriate. The DNSmasq server is my primary nameserver, so all requests go through it; any nonlocal addresses are passed back to the ISP's nameserver. You might consider that configuration if possible.

share|improve this answer
    
an answer on another question indicates that address=/.devbox/192.168.3.99 might be more suitable syntax for your purposes. –  quack quixote Apr 27 '10 at 19:14
    
Gee, I should have just read the parts that I pasted in from the config, it was obvious that it's not what I need. The address directive solved the problem, thank you! –  K. Norbert Apr 28 '10 at 7:24
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.