Remember this one?
There was, and probably still is, a problem with changing IPv6 addresses. My IPv6 address changes, whenever I (or my provider) reset my cable modem.
In the original topic, there is a script (run with cron regularly) to correct the IPv6 entry.
Here is the pihole v5 version of that script. The challenge is to change the IPv6 address of the pi in the sqlite3 database, if you defined your pihole as a client.
Using GUA: Replace the first few digits (‘2a02’ in my case) in the grep command to match your own!!!
Using LUA: Replace ‘2a02’ in the grep command with ‘\<fc\|\<fd
’ (see @DL6ER script in the original topic)
#!/bin/bash
# get current IPv6 address
CURRENT_IPV6_ADDRESS=$(ip -6 a | grep '2a02' | awk -F " " '{gsub("/[0-9]*",""); print $2}')
# read configured IPv6 address from /etc/pihole/setupVars.conf
file=/etc/pihole/setupVars.conf
OLD_IPV6_ADDRESS=$(grep 'IPV6_ADDRESS=' "$file" |sed 's/^IPV6_ADDRESS=//')
# read/compare previous IPv6 address from file
if ! grep -q "$CURRENT_IPV6_ADDRESS" $file; then
sed -i.bak "s/$OLD_IPV6_ADDRESS\b/$CURRENT_IPV6_ADDRESS/g" "$file"
sudo sqlite3 /etc/pihole/gravity.db "update client set ip = \"$CURRENT_IPV6_ADDRESS\" where ip = \"$OLD_IPV6_ADDRESS\";"
# required, see group management documentation
pihole restartdns reload-lists
# running pihole -g will automatically update /etc/pihole/local.list
/usr/local/bin/pihole updateGravity
fi
The script was tested with both database v10 (current) and database v11 (see here).