What's new

Question on where to put VPN routing rules

  • 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!

So I was reading on user scripts page in Merlin's wiki. For openvpn-event, it says:

openvpn-event
Called whenever an OpenVPN server gets started/stopped, or an OpenVPN client connects to a remote server. Uses the same syntax/parameters as the "up" and "down" scripts in OpenVPN.

Does this mean openvpn-event doesn't get called when an OpenVPN client disconnects from a remote server?
 
You should se:
vpnclient3-route-pre-down
vpnclient3-route-up
vpnclient3-down
If you don't I not know why.
 
For the sake of completeness, here are screenshots of my OpenVPN client configuration, plus the openvpn-event script from john9527. I'm really at a loss for why the down script isn't getting called.

Code:
#!/bin/sh

scr_name="$(basename $0)[$$]"

case "$dev" in
"tun11")
vpn_name="client1"
;;
"tun12")
vpn_name="client2"
;;
"tun13")
vpn_name="client3"
;;
"tun14")
vpn_name="client4"
;;
"tun15")
vpn_name="client5"
;;
"tun21")
vpn_name="server1"
;;
"tun22")
vpn_name="server2"
;;
*)
vpn_name=""
;;
esac

# Call appropriate script based on script_type
vpn_script_name="vpn$vpn_name-$script_type"

# Check script state/use nvram to save last script run
vpn_script_state=$(nvram get vpn_script_state)
nvram set vpn_script_state="$vpn_script_name"
if [ "$vpn_script_name" = "$vpn_script_state" ]; then
echo "VPN script" $vpn_script_name "already run" | logger -t "$scr_name"
exit 0
fi

if [[ -f "/jffs/scripts/$vpn_script_name" ]] ; then
sh /jffs/scripts/$vpn_script_name $*
else
echo "Script not defined for event: "$vpn_script_name | logger -t $scr_name
exit 0
fi

exit 0
 

Attachments

  • Screen Shot 2017-01-19 at 14.24.54.png
    Screen Shot 2017-01-19 at 14.24.54.png
    270.3 KB · Views: 281
  • Screen Shot 2017-01-19 at 14.25.02.png
    Screen Shot 2017-01-19 at 14.25.02.png
    94.9 KB · Views: 584
if [[ -f "/jffs/scripts/$vpn_script_name" ]] ; then <<<=== only thing I can think off is ";" is moved out one step.
Remove "explicit-exit-notify 5" there was a timing problem when using that.
 
Remove "explicit-exit-notify 5" there was a timing problem when using that.

Success! That had to be it...it's working now!

Are there any consequences to removing that from my config? It was part of the config file from my VPN provider.
 
Success! That had to be it...it's working now!

Are there any consequences to removing that from my config? It was part of the config file from my VPN provider.
It's there to help your ISP to close down its end of the tunnel faster.....you should be able to add explicit-exit-notify back on the 380.65 code.

Also, Merlin added two commits yesterday, for his next 380.65 build that should fix the ability to access the passed arguments correctly ($1 should work as well as $dev).
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

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