Disable internet access but leave LAN working

Solution 1:

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).

Solution 2:

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

Solution 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.