From 3cce724dbec4fdffe5f738bc5b0ed63cec6516c1 Mon Sep 17 00:00:00 2001 From: Keve Mueller Date: Sat, 8 Dec 2018 17:33:50 +0100 Subject: [PATCH 1/2] ddns-scripts: Working example to use local_script to derive a SLAAC IPv6 address Signed-off-by: Keve Mueller --- net/ddns-scripts/samples/slaac_sample.sh | 59 ++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 net/ddns-scripts/samples/slaac_sample.sh diff --git a/net/ddns-scripts/samples/slaac_sample.sh b/net/ddns-scripts/samples/slaac_sample.sh new file mode 100755 index 000000000..ea8f24d87 --- /dev/null +++ b/net/ddns-scripts/samples/slaac_sample.sh @@ -0,0 +1,59 @@ +#!/bin/sh +# +# script to determine and return SLAAC ipv6 address using prefix from a locally configured interface and the MAC address of the device +# (c) 2018 Keve Mueller +# +# activated inside /etc/config/ddns by setting +# +# option ip_source 'script' +# option ip_script '/usr/lib/ddns/slaac_sample.sh br-lan AA:BB:CC:DD:EE:FF' +# +# the script is executed (not parsed) inside get_local_ip() function +# of /usr/lib/ddns/dynamic_dns_functions.sh +# +# useful when this box is the only DDNS client in the network and other clients use SLAAC +# so no need to install ddns client on every "internal" box +# +# NB: this will not catch the actual IPV6 used by the host when it is configured to use temporary addresses + +#NB: we need a valid MAC address that is fully expanded with leading zeroes on all positions +format_eui_64() { + local macaddr="$1" + echo ${macaddr:0:1}$(echo ${macaddr:1:1}|tr 0123456789abcdefABCDEF 23016745ab89efcd89efcd)${macaddr:3:2}:${macaddr:6:2}ff:fe${macaddr:9:2}:${macaddr:12:2}${macaddr:15:2} +} + +# expand :: in an ipv6 address specification to the appropriate series of 0: +# result will have 8 ipv6 fragments separated by single colon +# NB: input must be a valid IPv6 address, e.g. ::1 +# NB: numbers are not prepended with leading zeroes +expand_ipv6_colons() { + local ipv6=$1 +# we need :: to be in the middle, so prepend a 0 if the input starts with : and append 0 if it ends with it + if [ "${ipv6:0:1}" = ":" ]; then ipv6=0${ipv6}; fi + if [ "${ipv6: -1:1}" = ":" ]; then ipv6=${ipv6}0; fi +# retain only the real colons + local colons=${ipv6//::|[0123456789abcdefABCDEF]/} +# count them + local num_colons=${#colons} + local filler=":0:0:0:0:0:0:" +# replace the :: with the appropriate substring from filler + local ipv6_x=${ipv6/::/${filler:0:(7-$num_colons)*2-1}} + echo $ipv6_x +} + +# obtain the first ipv6 address of the device passed in $1 +addr_net=$(ip -6 -o addr show dev $1 scope global up | cut -d" " -f 7 | head -1) +#addr_net=$1 +addr=${addr_net%/*} +# TODO: we assume /64 subnet +# get the first 64 bits of the address +prefix=$(expand_ipv6_colons $addr | cut -d: -f -4) +# compute the SLAAC 64 bits from the MAC +suffix=$(format_eui_64 "$2") + +echo -n $prefix:$suffix +exit 0 + +#echo "Should never come here" >&2 +#exit 2 + From c9188f50148f8cd23a2273bf2c9a0c39eb220403 Mon Sep 17 00:00:00 2001 From: Keve Mueller Date: Thu, 11 Apr 2019 13:24:53 +0200 Subject: [PATCH 2/2] ddns-scripts: Bumped PKG_RELEASE Signed-off-by: Keve Mueller --- net/ddns-scripts/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ddns-scripts/Makefile b/net/ddns-scripts/Makefile index bc3784dc0..86c52dce2 100755 --- a/net/ddns-scripts/Makefile +++ b/net/ddns-scripts/Makefile @@ -12,7 +12,7 @@ PKG_NAME:=ddns-scripts PKG_VERSION:=2.7.8 # Release == build # increase on changes of services files or tld_names.dat -PKG_RELEASE:=7 +PKG_RELEASE:=8 PKG_LICENSE:=GPL-2.0 PKG_MAINTAINER:=