OpenVPN: How to use per-VPN scripts on route-up?

Hey there,

previously, I had some scripts in my vpn configuration file that was called via route-up.

Since a month, openvpn uses the route-up script handler itself (diff ) so my script does not get executed anymore.

I could not find documentation on how I can now achieve the same?

route-up /etc/openvpn/routes-guest.sh
route-pre-down /etc/openvpn/routes-guest.sh

(and as I have multiple VPN per AP with different scripts, I need to be able to call different scripts for each vpn...)

It is OpenVPN 2.4 manual, now version 2.5 is actual: https://openvpn.net/community-resources/reference-manual-for-openvpn-2-4/

Thanks for your answer, but this does not answer my question.

A month ago, the snippet I posted worked (inside ovpn config file) to execute my scripts on route addition/deletion.

Since a month, the OpenWRT scripts override the openvpn script handlers by executing some hotplug stuff. But I digged into it and found the solution:

You can create scripts in /etc/hotplug.d/openvpn.

I basically copied my script in there, putting some logic around:

[ "${INSTANCE}" = "vpn1" ] && {
    logger -t hotplug "Device: ${INSTANCE} / Action: ${ACTION}"

    if [ "$script_type" == "route-up" ]; then
      ip route add default via $route_vpn_gateway dev $dev table vpn1tbl proto static
    elif [ "$script_type" == "route-pre-down" ]; then
      ip route del default via $route_vpn_gateway dev $dev table vpn1tbl proto static
    fi

    
} 

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.