Created
December 9, 2017 03:20
-
-
Save tankhuu/318b965260e1efe62d32699e22a0d420 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Using Dnsmasq for local development on OS X ## | |
## DNS & DHCP ## | |
# Installation | |
# Update your homebrew installation | |
brew up | |
# Install dnsmasq | |
brew install dnsmasq | |
# Configuration | |
# Copy the default configuration file. | |
cp $(brew list dnsmasq | grep /dnsmasq.conf.example$) /usr/local/etc/dnsmasq.conf | |
# Copy the daemon configuration file into place. | |
sudo cp $(brew list dnsmasq | grep /homebrew.mxcl.dnsmasq.plist$) /Library/LaunchDaemons/ | |
# Start Dnsmasq automatically. | |
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist | |
# Add domain to configuration | |
echo "address=/dev/127.0.0.1" | sudo tee -a /usr/local/etc/dnsmasq.conf | |
# Apply new configuration | |
sudo launchctl stop homebrew.mxcl.dnsmasq | |
sudo launchctl start homebrew.mxcl.dnsmasq | |
# Test DNS Configuration | |
dig domain.com @127.0.0.1 | |
# Answer should be | |
# ;; ANSWER SECTION: | |
# domain.com. 0 IN A 127.0.0.1 | |
# Change dns request to dnsmasq | |
sudo mkdir -p /etc/resolver | |
sudo tee /etc/resolver/devnewhire >/dev/null <<EOF | |
nameserver 127.0.0.1 | |
EOF | |
sudo launchctl start homebrew.mxcl.dnsmasq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment