Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Assume I have a VM running on OSX with private IP 10.0.0.1 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 10.0.0.1.

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.

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

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.
#address=/double-click.net/127.0.0.1

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

server=8.8.8.8
address=/app.dev/10.0.0.1

(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 127.0.0.1 as a DNS server.

share|improve this answer
    
Thanks for this answer, (with the help of bhamrick.com/2013/04/18/…) I was able to achieve the desired outcome! –  Bill Oct 27 '13 at 3:44
add comment

The easiest way is to add the following line to /private/etc/hosts:

10.0.0.1  app.dev 
share|improve this answer
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.