IPv6 Prefix change - help note

Started by stanthewizzard, November 13, 2024, 06:32:37 PM

Previous topic - Next topic
Hello to all

This topic can help poor soul like me.

My ISP changes the prefix of my ipv6 fiber.

Solution

dhcpv6
Range should be only the suffix

DHCPv6 Static Mappings for this interface.
also only suffix

But big issue with the dns servers (that are static in the settings and in my case those dns are from DHCPv6 Static Mapping)

Then
vi /usr/local/bin/update_dhcpv6_dns.sh

!/usr/bin/bash

ALIAS1="AD1"
ALIAS2="AD2"

IPV6_ADDR1=$(pfctl -t "$ALIAS1" -T show | grep ":" | head -n 1 | sed 's/^[[:space:]]*//')
IPV6_ADDR2=$(pfctl -t "$ALIAS2" -T show | grep ":" | head -n 1 | sed 's/^[[:space:]]*//')


if [ -z "$IPV6_ADDR1" ]; then
    echo "Error for ($ALIAS1)."
    exit 1
fi

if [ -z "$IPV6_ADDR2" ]; then
    echo "Error for  ($ALIAS2)."
    exit 1
fi



cp /conf/config.xml /conf/config.xml.bak


sed -i "" "/<dhcpdv6>/,/<\/dhcpdv6>/{
    s#<dnsserver>.*</dnsserver>#<dnsserver>$IPV6_ADDR1</dnsserver>#;

    /<dnsserver>/ {
        n
        s#<dnsserver>.*</dnsserver>#<dnsserver>$IPV6_ADDR2</dnsserver>#
    }
}" /conf/config.xml


grep -A 5 "<dhcpdv6>" /conf/config.xml

pluginctl -s dhcpd6 restart

ADDR2."


Then

vi /usr/local/opnsense/service/conf/actions.d/actions_dhcpv6update.conf

[wake]
command:/usr/local/bin/update_dhcpv6_dns.sh
type:script
description:DHCPv6 UPDT prefix DNS servers
message:UPDT DNS Servers DHCPv6


And last
add a cron from GUI

Problem is solved and shoudn't be wipped by opnsense updates

;)