Skip to content

Instantly share code, notes, and snippets.

@jberger
Created February 11, 2020 17:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jberger/b603c0175a0f0bd3ba3f05fa5e5dbcfc to your computer and use it in GitHub Desktop.
Save jberger/b603c0175a0f0bd3ba3f05fa5e5dbcfc to your computer and use it in GitHub Desktop.
#!/bin/bash
PID=$(pgrep -f 'ssh -D')
CMD=$1
if [[ $CMD == '--stop' ]]
then
if [[ ! "$PID" ]]
then
echo 'socks proxy is not running';
exit 1;
fi
sudo kill $PID;
exit 0;
fi
if [[ $CMD == '--flush' ]]
then
echo 'flush dns and reload networking';
# flush several times
sudo route -n flush; sudo route -n flush; sudo route -n flush;
# restart en0
sudo ifconfig en0 down; sudo ifconfig en0 up;
exit 0;
fi
if [[ $PID > 0 ]]
then
echo 'socks proxy is already running';
exit 1;
fi
ssh -D 1337 -q -C -N -f sg1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment