Block Connection when VPN Disabled

Got a problem with Viscosity or need help? Ask here!

top_hat101

Posts: 3
Joined: Fri Mar 22, 2013 12:07 pm

Post by top_hat101 » Mon May 13, 2013 2:57 pm
Hello all.

Is there a way with Viscosity to block any network connection when the VPN is disabled?

Eric

User avatar
Posts: 906
Joined: Sun Jan 03, 2010 3:27 am

Post by Eric » Mon May 13, 2013 4:03 pm
Hi top_hat101,

While there isn't a way built into Viscosity, you can achieve this using Viscosity's scripting support. The easiest way to achieve this is to bring your main adapter down when you disconnect, and back up before you connect.

To do so, you will need to create two batch scripts. Open a text editor (like notepad) and enter the following, replacing Ethernet with the name of your primary network adapter you use to connect to the internet:

netsh interface set interface name="Ethernet" admin=DISABLED

Then save the file as 'disconnected.bat' or similar. Then you will need to make a second batch script, saving it as beforeconnect.bat for example, with the following contents:

netsh interface set interface name="Ethernet" admin=ENABLED

Then, edit your connection, go to the advanced tab and set the beforeconnect.bat script as the Before Connect script, and the disconnected.bat script as the Disconnect script and save your connection.

The only downside to this is unfortunately these commands require Administrator privileges to work, so you will need to run Viscosity with Administrator rights for these scripts to function properly.

Regards,

Eric
Eric Thorpe
Viscosity Developer

Web: http://www.sparklabs.com
Support: http://www.sparklabs.com/support
Twitter: http://twitter.com/sparklabs
2 posts Page 1 of 1