Windows - Block access when the client looses the connection

Scripts with setup, destroy, and modify routing tables and firewall rulesets for client connections.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
highend
OpenVpn Newbie
Posts: 9
Joined: Fri Sep 23, 2011 9:57 am

Windows - Block access when the client looses the connection

Post by highend » Fri Sep 23, 2011 10:17 am

Hi,

assuming that the openvpn user has local admin rights, is it possible to completely block all internet access when the openvpn client looses it's connection to the vpn server?

This could probably be done with two simple .bat files like:

.opvn config:
up "D:\\Users\\Highend\\scripts\\up.bat"
down "D:\\Users\\Highend\\scripts\\down.bat"

which contain the necessary firewall rules.

My problem is: How can I distinguish a manual (user initiated) disconnect from a --keepalive timeout disconnect?

Manual disconnect shouldn't trigger blocking access (the disconnect is for a reason :) but a connectivity loss because of a server failure / shutdown or anything else that isn't under user control should establish the blocking rules.

Any hints how I could accomplish that?

Tia,
highend

User avatar
janjust
Forum Team
Posts: 2703
Joined: Fri Aug 20, 2010 2:57 pm
Location: Amsterdam
Contact:

Re: Windows - Block access when the client looses the connec

Post by janjust » Fri Sep 23, 2011 12:43 pm

openvpn sets an environment variable 'signal' when calling the down script ; when a users stops openvpn you'd see something like

Code: Select all

signal=sigint
when openvpn shuts down due to a 'ping-restart' you will see

Code: Select all

signal=ping-restart
write your down.bat file to look for this signal and adjust the firewall/routing rules accordingly.

highend
OpenVpn Newbie
Posts: 9
Joined: Fri Sep 23, 2011 9:57 am

Re: Windows - Block access when the client looses the connec

Post by highend » Fri Sep 23, 2011 1:51 pm

Thanks a lot janjust,

Edit:
Ok, it's working flawlessly so far :)

Regards,
highend

benzke
OpenVpn Newbie
Posts: 1
Joined: Wed Aug 29, 2012 8:38 am

Re: Windows - Block access when the client looses the connec

Post by benzke » Wed Aug 29, 2012 8:40 am

Hello,

I would like to know how i can configure these settings. how do i have to do it?

can sombody help me?

thank you verry much!!!

Post Reply