Split question: this other one here is for Windows.
Linux: Fastest way to disable internet (keeping LAN) from command line?
I think the easiest way to deactivate internet (not LAN) in Linux is to remove the default gateway, so, assuming LAN is 10.0.2.0/24 and gateway is 10.0.2.1 :
`sudo /sbin/route del default gw 10.0.2.1`
To reactivate internet:
`sudo /sbin/route add default gw 10.0.2.1`
But, even when this a simple line, it requires to discover the default gateway IP first:
I am going to build some general purpose shell scripts that need to enable/disable internet(but keep LAN working), so it seems I am going to need some (¿
grep, maybe?) operations to filter and detect the exact gateway IP number (it could be 10.0.2.1, 127.0.0.1, 127.0.50.1, 192.168.0.1 ... etc), unless I achieve to find a simpler command line.
Any ideas, please?