Setup local wildcard domains

To make your development domains point to localhost you could edit etc/hosts and add a line
mdstn.com.dev 127.0.0.1

And every project you’re going to start you’ll add more line. Such as:
anotherdomain.com.dev 127.0.0.1

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

nameserver 127.0.0.1

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'

dnsmasq.conf

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=64.94.110.11
bogus-nxdomain=64.62.153.174
log-queries
log-facility=/var/log/dnsmasq
#conf-file=/opt/local/etc/dnsmasq.itunes.conf

# keep nameserver order of resolv.conf
strict-order
EOF

dnsmasq.itunes.conf

cat > /opt/local/etc/dnsmasq.itunes.conf <<-EOF 
#### itunes Hack
server=/ax.init.itunes.apple.com/8.8.8.8
#### iTunes Hack
address=/itunes.apple.com/91.224.160.136
address=/edgesuite.net/91.224.160.136
address=/itunes.com/91.224.160.136
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

file:

Add bash aliases

file: ~/.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