Skip to content

Instantly share code, notes, and snippets.

@subfission
Last active July 1, 2018 21:54
Show Gist options
  • Select an option

  • Save subfission/19167b77b115ea5185027b077be8784b to your computer and use it in GitHub Desktop.

Select an option

Save subfission/19167b77b115ea5185027b077be8784b to your computer and use it in GitHub Desktop.
Linux/MacOS bash completion for host domain banning
# Ban domain with hosts entry. usage: hostban target_domain
hostban() {
( "$#" -ne 1 ) && (echo "ERROR: Missing host to ban!"; echo "usage: hostban target_domain"; exit 1)
[ "$(whoami)" != "root" ] && (return $(sudo ban_host "$1"))
echo "0.0.0.0 $1" >> /etc/hosts
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment