To make your development domains point to localhost you could edit
etc/hosts and add a line
And every project you’re going to start you’ll add more line. Such as:
This come very tedious and time consuming. Well time is very important to me so I like things automated. You might use dnsmasq.
This work very well if you work at home and never move your computer to other WiFi networks. I like to have the idea I could travel anywhere with my MacBook and use WiFi from friends, library or just at workplace. But when I do that, I need to configure DNS Server in my Network Preferences everytime. That my friend, is also tedious.
And I have this solution for this challenge is adding a file to /etc/resolver
and name it to dev.
Make sure you are
root use this code below and put in dev
Install dnsmasq trough brew
brew install dnsmasq mkdir -pv $(brew --prefix)/etc/ echo 'address=/.dev/127.0.0.1' > $(brew --prefix)/etc/dnsmasq.conf sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist sudo mkdir -v /etc/resolver sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/dev'
cat > /opt/local/etc/dnsmasq.conf <<-EOF resolv-file=/etc/resolv.dnsmasq.conf address=/.dev/127.0.0.1 listen-address=127.0.0.1 port=53 no-dhcp-interface= bind-interfaces addn-hosts=/var/www/_conf/adblock_hosts bogus-nxdomain=220.127.116.11 bogus-nxdomain=18.104.22.168 log-queries log-facility=/var/log/dnsmasq #conf-file=/opt/local/etc/dnsmasq.itunes.conf # keep nameserver order of resolv.conf strict-order EOF
cat > /opt/local/etc/dnsmasq.itunes.conf <<-EOF #### itunes Hack server=/ax.init.itunes.apple.com/22.214.171.124 #### iTunes Hack address=/itunes.apple.com/126.96.36.199 address=/edgesuite.net/188.8.131.52 address=/itunes.com/184.108.40.206 address=/csrrun.naturalmotion.com/127.0.0.1 #address=/cloudcell.com/127.0.0.1 address=/testflightapp.com/127.0.0.1 #address=/#/127.0.0.1 EOF
create .dev file
# log as root # creates directory mkdir -p /etc/resolver echo "nameserver 127.0.0.1" > /etc/resolver/dev
Every DOT dev domains will points to your localhost
Add bash aliases
alias dnsmasq.start='sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist' alias dnsmasq.stop='sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist' alias dnsmasq.restart='dnsmasq.stop && dnsmasq.start'
Document not yet finished