What's new

Running script when connected to VPN

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

page_fault

Occasional Visitor
Hello all,

I was wondering if there was a way to run a script after a VPN connection is successful. I would like to run a custom iptables script when I connect so only certain IP's on my network are routed through the VPN.

Thanks.
 
Ok I got it working I put my script in openvpn-event in /jffs/scripts and it works and executes when the interface goes up for tun11. Thanks. It should work for you if you put the script included in that thread in that location and tweak it a bit for your own use.
 
Last edited:
Ok I got it working I put my script in openvpn-event in /jffs/scripts and it works and executes when the interface goes up for tun11. Thanks. It should work for you if you put the script included in that thread in that location and tweak it a bit for your own use.
You got it working on your first shot? Nice work! Which script did you use? There are a few openvpn-event ones there.
 
Hi!
I have set up a manual file with individual IPs. If I call it openvpn-event (#! /bin /sh
sh /jffs/scripts/x3mRouting/load_MANUAL_ipset_iface.sh 0 AMAZON-MY), it does not work (liststats: - 0ON-MY
). What am I doing wrong? Many thanks for your help!
 
I thought openvpn-event gets called for a server when the VPN server starts or stops, not when a connection is made. To run a script when a connection is made to the server, put a call to the script in the custom configuration box: client-connect <script>..

In this respect I think it is different than the client, where openvpn-event gets called when the VPN client starts.

Edit: Nevermind. I had read the <very old> messages in this thread and thought we were talking about a server.
 
Thanks! The Script is workin when my VPN connects. But it writes a wrong ipset:
It should write AmazonMy on 0, but it writes 0ONMY
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top