1
1
Split question: this other one here is for Linux.
I think the easiest way to deactivate internet (not LAN) in Windows command-line is to remove the default gateway, so, assuming LAN is 10.0.2.0/24 and gateway is 10.0.2.1 :
`route delete 0.0.0.0 mask 0.0.0.0 10.0.2.1`
To reactivate internet:
`route add 0.0.0.0 mask 0.0.0.0 10.0.2.1`
But, even when this a simple line, it requires to discover the default gateway IP first:
In Windows:
route print
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
equivalent 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?
- EDIT: Some people reports that gateway deletion in Windows could also be done like this:
route delete 0.0.0.0
So, apparently, there would be no problem in modifying the deletion script made by @and31415 .
try to omit gateway - it should work so: route delete 0.0.0.0 mask 0.0.0.0 – MolbOrg – 2014-04-22T10:09:22.957
@MolbOrg, it seems there is no need for netmask specification. I have tested it with Windows XP SP3 and Windows 7 SP1. – Sopalajo de Arrierez – 2014-04-22T10:29:12.400