Missing var LanPrefix in phpDynDNS.inc. Workaround to use dynamic IPv6 Subhosts

Started by wsxws, July 31, 2020, 03:54:49 PM

Previous topic - Next topic
Hi there,
my dynDNS-Provider offers a way to use subhosts by using only one dnyDNS.
means the router updates its ip for my.host.com and sends the additional info of the lanpref. the dynprovider was given the hostidentifier for another device in lan as subdomain mydev and so updates mydev.my.host.com to the public ipv6 of that device.
to make this work ist is necessary to submit the LanPrefix within the updaterequest.
unfortunately this var ist missing in phpDynDNS.inc so i made a little script as workaraound.

/usr/local/etc/rc.syshook.d/start/94-subhostdyn

#!/bin/bash
# Login
user='myuser'
pass='mypass'
MainHost='myhost.feste-ip.net'
# Host to check (SubHost or MainHost)
CheckHost="mysub.myhost.feste-ip.net"
# Interfaces
LanIf='re0'
WanIf='re1'
updateurl='v6.members.feste-ip.net'
# Vars
LanPref=$(ifconfig $LanIf | grep inet6 | grep -v fe80 | awk -v FS=" " '{ print $2 }' | awk -v FS=":" '{ print $1":"$2":"$3":"$4 }')
WanIP=$(ifconfig $WanIf | grep inet6 | grep -v fe80 | awk -v FS=" " '{ print $2 }')
# Curl-URL
CurlURL="http://"$user":"$pass"@"$updateurl"/nic/update?hostname=$MainHost&myip="$WanIP"&subhostprefix="$LanPref
# Check if SubHost is reachable, otherwise update dynDNS
if ! ping6 -c 1 $CheckHost > /dev/null 2>&1 ; then
     curl $CurlURL
fi;
exit


just change the vars of your need amd make it executable (chmod +x)

if you use feste-ip.net delete the ip in the webpanel everytime you add a new subhost, otherwise the new subhost will not become activated

if you want to do this update cyclic you need to it to the configd

/usr/local/opnsense/service/conf/actions.d/actions_festeip.conf

[start]
command:/usr/local/etc/rc.syshook.d/start/94-festedyn
description:FesteIP Update
parameters:
type:script_output
message:updating Feste-IP.net


service configd restart

now you can add a cronjob for this under System-Settings-Cron.

hef phun ;)