Skip to content

Instantly share code, notes, and snippets.

@elifiner
Last active March 24, 2019 04:54
Show Gist options
  • Save elifiner/a4bbe415eff43df9fa970977d1a7d278 to your computer and use it in GitHub Desktop.
Save elifiner/a4bbe415eff43df9fa970977d1a7d278 to your computer and use it in GitHub Desktop.
Set up dnsmasq for local develoment in RetreatGuru
#!/bin/sh
# This script will set up a DNS server on your OSX that will redirect all programs.test,
# bookingguru.test and rgconnect.test to the correct local IP addresses.
#
# Run it using:
#
# $ curl -s https://gist.githubusercontent.com/elifiner/a4bbe415eff43df9fa970977d1a7d278/raw?$RANDOM | sh -
TLD=test
echo "Setting this up requires sudo, please enter the password below."
sudo -k ls > /dev/null || exit
# create localhost alias IPs and set them to be created on startup
cat << EOF | sudo crontab
@reboot /sbin/ifconfig lo0 alias 127.0.100.1
@reboot /sbin/ifconfig lo0 alias 127.0.100.2
@reboot /sbin/ifconfig lo0 alias 127.0.100.3
@reboot /sbin/ifconfig lo0 alias 127.0.100.4
@reboot /sbin/ifconfig lo0 alias 127.0.100.5
EOF
sudo crontab -l | sed 's/@reboot/sudo/' | while read line; do $line; done
# set up dnsmasq
brew install dnsmasq
echo "# Retreat Guru local development settings" > /usr/local/etc/dnsmasq.conf
echo "address=/$TLD/127.0.0.1" >> /usr/local/etc/dnsmasq.conf
echo "address=/programs.$TLD/127.0.100.1" >> /usr/local/etc/dnsmasq.conf
echo "address=/retreatguru.$TLD/127.0.100.2" >> /usr/local/etc/dnsmasq.conf
echo "address=/rgconnect.$TLD/127.0.100.3" >> /usr/local/etc/dnsmasq.conf
sudo brew services restart dnsmasq
# set up dnsmasq as DNS server for all local domains
sudo mkdir -p /etc/resolver
sudo sh -c "echo nameserver 127.0.0.1 > /etc/resolver/$TLD"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment