aboutsummaryrefslogtreecommitdiff
path: root/etc/local.d/radvd.hook
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2022-02-23 20:19:37 -0500
committerMitchell Riedstra <mitch@riedstra.dev>2022-02-23 20:43:27 -0500
commit12192865c3ca0e1c2139afabab508e0087b14982 (patch)
tree26ea5454dc976e87186e369685a1ac987bab2a61 /etc/local.d/radvd.hook
downloadalpine-home-router-1.0.tar.gz
alpine-home-router-1.0.tar.xz
Diffstat (limited to 'etc/local.d/radvd.hook')
-rwxr-xr-xetc/local.d/radvd.hook42
1 files changed, 42 insertions, 0 deletions
diff --git a/etc/local.d/radvd.hook b/etc/local.d/radvd.hook
new file mode 100755
index 0000000..8137d0b
--- /dev/null
+++ b/etc/local.d/radvd.hook
@@ -0,0 +1,42 @@
+#!/bin/sh
+# Brutally simply hook for dhcpcd assuming you only have a single interface with
+# delegated prefixes, which is the case for most home routers.
+
+# This writes out a radvd conf for the interface and prefix in question and
+# blindly restarts the daemon.
+
+write_radvd() {
+
+if [ -z "$new_delegated_dhcp6_prefix" ] ; then
+ echo "Cannot continue without delegated prefix"
+ exit 1;
+fi
+
+conf="interface $interface {
+ AdvSendAdvert on;"
+
+for prefix in $new_delegated_dhcp6_prefix ; do
+conf="$conf
+ prefix $prefix
+ {
+ AdvOnLink on;
+ AdvAutonomous on;
+ AdvRouterAddr on;
+ };
+"
+done
+
+conf="$conf
+};"
+
+echo "$conf" > /etc/radvd.conf
+
+/etc/init.d/radvd restart
+}
+
+case "$reason" in
+DELEGATED6)
+write_radvd
+;;
+esac
+