Yep. You can do this, /etc/resolver
is your friend.
$ man 5 resolver
:
domain
Domain name associated with this resolver configuration. This option is normally not required by the Mac OS X DNS search system when the resolver configuration is read from a file in the /etc/resolver directory. In that case the file name is used as the domain name.
Simply put you can place nameserver 127.0.0.1
inside a file you create called /etc/resolver/dev
You'll need to reload/restart. It'll then direct any requests to *.dev
to your local nameserver.
Your network connection DNS remains on automatic, so it will cope with any changes in your environment.
Edit: I've just found http://serverfault.com/a/164215/163311https://serverfault.com/a/164215/163311 and http://www.echoditto.com/blog/never-touch-your-local-etchosts-file-os-x-again which have a few more details and include dnsmasq
setup details.