Caesar
Caesar

Reputation: 587

use dnsmasq to point .dev domains to one computer from all local networks to which it is connected

I'm running Apache etc (actually MAMP at the moment, but soon to be replaced by individual Apache, PHP, MySQL...) on my Mac, for testing my websites locally/offline.

I want to be able to test all my local sites (domains *.dev) from any and all of the following, without having to update the hots file on each device (some of which, such as un-rooted phones, don't even allow editing of the hosts file):

  1. Obviously, my Mac itself...
  2. Any device on any local network to which my mac is connected (My Mac doesn't necessarily always have the same IP address)
  3. Any virtual machine running on my Mac (in Parallels) – primarily, various versions of Windows (my Mac does always have the same IP address on Parallels Shared Networking)

Now, I read that dnsmasq may be able to help, and have installed it on my Mac using Homebrew. I set it up to start on startup, and my dnsmasq.conf reads as follows:

address=/.dev/127.0.0.1

This has the effect of allowing any domain *.dev to work on my Mac itself, which is a start.

Next I tried to make it work in a Parallels VM by setting the DNS server to be the local IP address of my Mac. However, this doesn't work – because dnsmasq returns 127.0.0.1 as the IP for any lookup for *.dev, but of course this makes the VM look for the site on the VM itself, rather than on my Mac... which obviously doesn't work.

So I'm a bit stumped. Can anyone give me any tips? Is there a way to set up dnsmasq to do what I want, or should I be looking at another method?

Thanks!

Upvotes: 1

Views: 1394

Answers (1)

the
the

Reputation: 21941

I don't have any experience with Parallels but with Virtualbox you can set up a bridged network connection. I presume Parallels has something similar. This will set up an internal network (e.g. on 192.168.1.*) and you can probably assign fixed IP addresses to that. Like this you can give the Mac a fixed IP address which you can also use in your dnsmasq configuration - but you might want to have two TLDs for this so that .dev can keep pointing to 127.0.0.1 while .devel points to 192.168.1.xx.

Upvotes: 1

Related Questions