Skip to content

Instantly share code, notes, and snippets.

@jfromaniello
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfromaniello/9d2b0383feed978afdb4 to your computer and use it in GitHub Desktop.
Save jfromaniello/9d2b0383feed978afdb4 to your computer and use it in GitHub Desktop.
Turn internet on and off on ubuntu.

INSTALL

sudo curl -o /usr/local/bin/internet-off \
  https://gist.githubusercontent.com/jfromaniello/9d2b0383feed978afdb4/raw/internet-off

sudo chmod +x /usr/local/bin/internet-off

USAGE

sudo internet-off

CREDITS

Credits to John1024 for his answer:

http://superuser.com/a/710961/125061

#!/bin/bash
GW=$(sudo /sbin/route -n | awk '{if ($1=="0.0.0.0") {print $2} ; q}')
/sbin/route del default gw "$GW"
echo "Use this to turn on internet:"
echo " sudo /sbin/route add default gw $GW"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment