0

I need a way to disable and then enable internet access via command line while still remaining connected to wifi.

  • Which network do you mean? Your LAN? – A.B. Aug 26 '15 at 16:30
  • any kind of internet access, I would like to restrict my ability to use the internet between the hours of 1pm - 5pm. While remaining connected via wifi. (the reason for this is that connecting to my router is usually a bit troublesome but the connection is good if I remain connected) – ubuntu_uk_user Aug 26 '15 at 16:32
  • Hnn, pull the cable from the wall? – A.B. Aug 26 '15 at 16:37
  • Nice idea, but I don't think there is a terminal command for this. – ubuntu_uk_user Aug 26 '15 at 16:38
6

Removing your default gateway should do the trick, you'll still be able to reach everything in your subnet, but not outside of it. IIRC this should work, cannot try it atm, replace the IP with your routers IP (in the same subnet):

 sudo route del default gw 192.168.1.1

Edit: To undo it, this should work:

 sudo route add default gw 192.168.1.1

To find your default gateways IP:

route -n|grep "^0.0.0.0"
  • Thanks for the response, this doesnt seem to be working: SIOCDELRT: No such process – ubuntu_uk_user Aug 26 '15 at 16:36
  • You'll need to use the correct IP address. It should be in the second column of 'route -n|grep "^0.0.0.0"' – Jakob Lenfers Aug 26 '15 at 16:41
  • i was copying the wrong ip – ubuntu_uk_user Aug 26 '15 at 16:42
  • @JakobLenfers mention in your answer that the IP should be in the same subset. – daltonfury42 Aug 26 '15 at 16:44
0

What you can try is rejecting all packets using firewall rule accept all packets within your network, when you want things normal just remove this firewall rule, make a script and run with cron. For more refer https://help.ubuntu.com/lts/serverguide/firewall.html, I have not tried this yet but will try it later. Let me know if you try it before me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.