Skip to content

Instantly share code, notes, and snippets.

@kossoff
Created October 31, 2014 13:47
Show Gist options
  • Save kossoff/15253757d471429081b7 to your computer and use it in GitHub Desktop.
Save kossoff/15253757d471429081b7 to your computer and use it in GitHub Desktop.
Script for add & remove fake domains in Dnsmasq
#!/bin/sh
HOSTS="$HOME/Work/dnsmasq.hosts"
if [ $# == 2 ] || [ $# == 3 ]; then
case $# in
2 )
echo Remove $2 from hosts
sed '/$2/d' $HOSTS
;;
3 )
echo Add URL $3 with IP $2 to hosts
echo $2 $3 >> $HOSTS
;;
esac
sudo launchctl stop homebrew.mxcl.dnsmasq
sudo launchctl start homebrew.mxcl.dnsmasq
else
echo "Usage: $0 add IP DOMAIN or $0 remove DOMAIN"
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment