Assume I have a VM running on OSX with private IP which can be accessed from the host machine.

I was wondering how can I map a pseudo domain, *.app.dev, to the private IP on my host machine so that on my host machine I can resolve the domain *.app.dev to

The purpose of this setup is to have virtual environment for development and not pollute my host machine with unnecessary packages and services.

edit: I realize that /etc/hosts can accomplish non wildcard domain names, I should have been more clear and mention wildcard domain names.


You can do this with dnsmasq.

Dnsmasq is a very small DNS server usually used as a proxy. It offers a lot of ways to manipulate DNS lookups, one of which is to respond to all DNS queries for a domain with a single IP.

The example dnsmasq.conf file has specific example for this:

# Add domains which you want to force to an IP address here.
# The example below send any host in double-click.net to a local
# web-server.

The following 2 lines are all that you would need to get running


(You can change the server parameter to whatever upstream server you want. Or use resolv-file to use a resolv.conf file)

Then just configure your system to use as a DNS server.

| improve this answer | |

The easiest way is to add the following line to /private/etc/hosts:  app.dev 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.