Skip to content

Instantly share code, notes, and snippets.

@JimmyRittenborg
Last active February 8, 2021 16:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JimmyRittenborg/f66498780d5a64551b90bc3aa5e0e4e1 to your computer and use it in GitHub Desktop.
Save JimmyRittenborg/f66498780d5a64551b90bc3aa5e0e4e1 to your computer and use it in GitHub Desktop.
Hot to use dnsmasq to resolve to all your local *.dev sites on macOS
#!/bin/bash
if test ! $(which brew); then
echo "Installing homebrew"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
echo -e "\n\nChecking for brew updates..."
echo "=============================="
brew update
echo -e "\n\nInstalling and configuring dnsmasq..."
echo "=============================="
brew install dnsmasq
# To have launchd start dnsmasq now and restart at startup:
sudo brew services start dnsmasq
# Configure dnsmasq
sudo tee /usr/local/etc/dnsmasq.conf >/dev/null <<EOF
address=/.dev/127.0.0.1
EOF
# Have MacOS resolve .dev at our dnsmasq nameserver ar 127.0.0.1
sudo tee /etc/resolver/dev >/dev/null <<EOF
nameserver 127.0.0.1
EOF
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment