Skip to content

Instantly share code, notes, and snippets.

@nippe
Last active September 22, 2016 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nippe/68cf2f5225ff14f115036e498aa1ceb2 to your computer and use it in GitHub Desktop.
Save nippe/68cf2f5225ff14f115036e498aa1ceb2 to your computer and use it in GitHub Desktop.
addresses=(
local.viaplay.se
local.viaplay.dk
local.viaplay.fi
local.viaplay.no
local.mtg-api.com
)
for i in "${addresses[@]}"
do
# echo "address=/$i/127.0.0.1"
sudo echo -e "address=/$i/127.0.0.1\n$(cat /usr/local/etc/dnsmasq.conf)" > /usr/local/etc/dnsmasq.conf
done
echo "Checking if /etc/resolver folder exists"
if [[ -d /etc/resolver ]];
then
echo "Directory already exists."
else
echo "No it did not, creating it"
sudo mkdir -p /etc/resolver
fi
echo "Writing files to /etc/resolvers for redirect to local dns"
for j in ${addresses[@]}
do
echo "nameserver 127.0.0.1" | sudo tee /etc/resolver/$j
done
echo "Reloading dnsmasq config"
sudo launchctl stop homebrew.mxcl.dnsmasq
sudo launchctl start homebrew.mxcl.dnsmasq
echo "Dnsmasq is up and running."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment