Adapting ovpn dynamic IPv6 GUA script, help needed

Hi folks!

First a bit of context:
I have a functional Openvpn ipv4 server that can tunnel ipv4/ipv6 on my gl-ar750s router. This router is configured more like a switch or an AP (but with wifi is off). There are only 2 interfaces LAN & LAN6 both configured as DHCP clients to the ISP router. I used a splitted /64 address space between the openvpn server and regular lan services as described in here.

Not surprisingly, the ISP GUA is dynamic. So I studied this guide only to discover that I needed to do some extensive modifications to make it work in my context:

  1. I am not using wan6 but lan6 (easy to correct)
  2. I followed this guide to install the server and to my knowledge it does not store configuration in the UCI managed space as required in the script.
  3. The install directory for my openvpn server is not the one assumed by the dynamic update script

So I came up with this revised version (my script skills may be a bit rusty) that does not require a extra interface and directly updates the server config:

#!/bin/sh

if [ "$INTERFACE" = "lan6" -a "$IFUPDATE_ADDRESSES" = "1" ]
then
    ##################
    # PD fix
    ##################
    # reload interface to update PD to downstream interfaces, refer to bug described here https://forum.openwrt.org/t/delegated-ipv6-prefix-not-updated/56135
    /sbin/ifup lan6

    # wait some time to get IPv6 up
    sleep 30

    source /lib/functions/network.sh
    network_get_ipaddr6 LAN6_PREFIX "lan6"
    LAN6_PREFIX=`echo $LAN6_PREFIX | sed "s/::[0-9,A-F]*//"`
    OVPN6_PREFIX=`cat /etc/openvpn/server.conf | grep server-ipv6 | sed "s/server-ipv6 *//" | sed "s/:8000::\/65//"`
    if [ $OVPN6_PREFIX != $LAN6_PREFIX ]
    then
        cat /etc/openvpn/server.conf.tmpl | sed "s/{IPV6_PREFIX}/$LAN6_PREFIX/" >server.conf
        service openvpn reload
    fi
fi

but the main condition (top if statement) does not seems to trigger the update altough the internal part does update server.conf correctly if executed manually. Any ideas on why it does not get triggered?

update: from my tests so far the line

network_get_ipaddr6 LAN6_PREFIX "lan6"

always has the right address so I wonder if the bug has been fixed because I would remove the "ifup lan6" part.

The internal part of script really works fine but since I do not understand well how the condition

if [ "$INTERFACE" = "lan6" -a "$IFUPDATE_ADDRESSES" = "1" ]

gets its environment variables from in the hotplug deamon context, I can't be be sure why the ipv6 address update is not triggered.

I am parking this issue. In my context of use where ipv4 always work, I'll just put an infrequent cron job that updates if necessary the ipv6 address in the server.conf file and restarts the ovpn server. In case of an urgent need to ipv6 access, I can always run the cron job update script manually.

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