Skip to content

Instantly share code, notes, and snippets.

@olaseni
Last active May 2, 2019 06:07
Show Gist options
  • Save olaseni/d2ed8de0ebc0a9b2ffb3dc84e6e0b024 to your computer and use it in GitHub Desktop.
Save olaseni/d2ed8de0ebc0a9b2ffb3dc84e6e0b024 to your computer and use it in GitHub Desktop.
Blocks/rejects an IP address irrespective of port, for TCP connections
#!/usr/bin/env bash
block() {
# $1 is the remote address you want to block.
route add $1 gw 127.0.0.1 lo
route add -host $1 reject
# Flush the cache.
ip route flush cache
}
for a in $*; do block $a > /dev/null ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment