Last active
February 13, 2018 16:26
-
-
Save aib/1881c25137724b47f916aec3e87028de to your computer and use it in GitHub Desktop.
Selective IP routing for those who live in interesting times
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
update_gist() { | |
GITHUB_USERNAME=aib | |
GIST_ID=1881c25137724b47f916aec3e87028de | |
python -c "import json, sys; json.dump({ \"files\": { sys.argv[1]: { \"content\": sys.stdin.read() } } }, sys.stdout)" $(basename "$0") <"$0" | curl -f -s -H "Accept: application/vnd.github.v3+json" -H "Content-Type: application/json" -u "$GITHUB_USERNAME" -X PATCH "https://api.github.com/gists/$GIST_ID" -d@- >/dev/null | |
} | |
if [ -z "$1" ]; then | |
printf "Usage:\n" >&2 | |
printf "\t%s <interface>\n" "$0" >&2 | |
printf "\t%s update\n" "$0" >&2 | |
printf "\n" >&2 | |
exit 1 | |
fi | |
if [ "$1" == "update" ]; then | |
update_gist | |
exit | |
fi | |
DEV="$1" | |
add_route() { | |
/sbin/ip route add "$1" dev "$DEV" | |
} | |
# Wikipedia | |
add_route 52.174.55.168 | |
add_route 91.198.174.192 | |
add_route 208.80.154.224 | |
# Imgur | |
add_route 104.16.108.18 | |
add_route 104.16.109.18 | |
add_route 104.16.110.18 | |
add_route 104.16.111.18 | |
add_route 104.16.112.18 | |
add_route 151.101.12.193 | |
add_route 151.101.16.193 | |
add_route 151.101.36.193 | |
add_route 151.101.60.193 | |
add_route 151.101.120.193 | |
add_route 151.101.112.193 | |
add_route 152.101.112.193 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment