Reputation: 587
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):
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
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