10

I'm looking for a command (or command line program) to toggle (disable/enable) internet access to the outside world in Windows XP machines. It should temporarily block internet access but leave the LAN working.

I looked for ways to change the DNS, but browsers like Chrome keep their own cache. The machines are configured via DHCP.

16

It's probably the best to remove the default route to disable internet access:

route delete 0.0.0.0 mask 0.0.0.0

And to re-enable, add it back again:

route add 0.0.0.0 mask 0.0.0.0 192.168.1.1

but replace the 192.168.1.1 with the correct IP of your router (you can find out while the internet is still working by typing route print and checking the entry for 0.0.0.0).

  • The only catch is that if you have more than one local subnet, the computers will not be able to talk to computers in other subnet(s). – David Jul 7 '14 at 22:12
  • Another catch, on Windows 8, when you restart the machine, it automatically restores the connection – I.G. Pascual Feb 11 '15 at 8:52
  • After entering route delete 0.0.0.0 mask 0.0.0.0 in command prompt, I was still able to access the internet just fine... (Win7 64bit) – zigojacko Dec 9 '15 at 15:36
  • Just like what @I.G.Pascual said, when you restart the machine, it automatically restores the connection. . .(Win10 x64) – Seynal Dec 11 '17 at 9:37
  • 1
    @Seynal if you want to persistent this rule, need add -p when delete. – Bill.Zhuang Apr 12 '18 at 6:23
3

This is a popular result on Google so I just wanted to provide an alternative answer for those using Virtual Machines via VirtualBox.

  • Make sure your virtual machine is turned off.
  • Go to VirtualBox -> File -> Preferences -> Network -> Host-Only Networks -> Click the add button (The host-only network should be set automatically by VirtualBox)
  • Machine -> Settings -> Network -> Change "Attached to" setting to "Host-Only Adapter". (it should autofill the host-only network name for you)

That's it...the Virtual Machine will now be able to utilize the Host Network but will not have access to the internet.

  • Michael's solution works up to a point. With a VirtualBox XP machine while all the network files are available, the network attached printer doesn't work even though it shows up under printers. I.e., any attempt to print to the display network printer gets stuck in the print queue. – user342094 Jul 10 '14 at 14:50
  • Worked great for me. This is very handy to start suspicious programs in a restricted environment so they can't phone home. – Martin Hansen Jul 19 '16 at 16:20
2

You should log into the router and tell it to disconnect from the internet. Unless you only want to deny specific computers access?

  • Even if its only specific machines, there are methods with routers that are not cheap consumer grade routers... – Austin T French Apr 23 '13 at 13:58

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