Skip to content

Instantly share code, notes, and snippets.

@funkenstrahlen
Created January 26, 2013 10:21
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save funkenstrahlen/4641550 to your computer and use it in GitHub Desktop.
Save funkenstrahlen/4641550 to your computer and use it in GitHub Desktop.
some aliases for sshuttle
# sshuttle helpers
#
# To load, you can add a line in ~/.bashrc:
# source ~/.bashrc.d/sshuttle_helpers
#
# or add a few lines to load all files in ~/.bashrc.d
# for f in ~/.bashrc.d/*; do
# source $f;
# done
#
# set default SSH server:
# user@hostname or a host in ~/.ssh/config
TNL_SERVER=default_ssh
# tunnel all traffic, including DNS.
alias tnl='sshuttle --dns -vr $TNL_SERVER 0/0'
# returns a list of IP addresses from given domain(s).
#
# Examples:
# dns2ip google.com
# dns2ip netflix.com movies.netflix.com
#
function dns2ip() {
dig +short $* | sed "/[^0-9\.]/d" # use sed to remove non-IPv4 line e.g. alias
}
# tunnel specified domain(s) only.
#
# Examples:
# tnlonly google.com
# tnlonly netflix.com movies.netflix.com
#
function tnlonly() {
sshuttle -vr $TNL_SERVER `dns2ip $*`;
}
# tunnel all traffic including DNS, except the specified domain(s).
#
# Examples:
# tnlbut youku.com
# tnlbut youku.com weibo.com
#
function tnlbut() {
sshuttle --dns -vr $TNL_SERVER `dns2ip $* | sed "s/^/-x/"` 0/0; # use sed to append '-x' prefix
}
# vpn to a ssh server.
#
# Examples:
# vpnto my_office_server # host in ~/.ssh/config
# vpnto user@123.123.123.123
#
function vpnto() {
sshuttle -HNvr $1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment