Use IPv6 ULA addresses for Pi-hole

Many users have reported that frequently changing IPv6 addresses cause page load to be slow or even prevent from working at all. The issues can be fixed by updating the IPv6 address in /etc/pihole/setupVars.conf followed by a run of pihole -g.

However, this solution turns out to be very inconvenient since it might be necessary to change the IPv6 address on a regular basis (maybe even multiple times a day). An alternative approach we are currently looking into is the usage of ULA addresses which should not be changing, even though the upstream GUA address may change.

Usually, there exists a setting in the router for enabling ULA addresses in the local network. Examples of how the corresponding settings look like on some routers are posted in this thread. As before, copy the address and replace it in your /etc/pihole/setupVars.conf

Hint: The following code snipet might come in handy

IPV6_ADDRESS=$(ip -6 a | grep '\<fc\|\<fd' | awk -F " " '{gsub("/[0-9]*",""); print $2}')
echo ${IPV6_ADDRESS}
sed -i.setupVars.bak "/IPV6_ADDRESS/d;" "/etc/pihole/setupVars.conf"
echo "IPV6_ADDRESS=${IPV6_ADDRESS}" >> "/etc/pihole/setupVars.conf"
pihole -g
11 Likes
Verstehe IPv6 nicht so ganz
Why do blacklisted domains show IPv4 as "Pi-holed" but not IPv6 in the query log?
3 Tage pihole, naja
Slow / No Web Page Loading
Pi hole with Mac OS X not loading webpages (IPv6)
Link-Local-IPv6 as default
FritzBox und IPV6
Ipv6 in settings ist falsch
Issues with IPv6 connectivity
Deutsche Telekom, IPv6 and AAAA Querries
Dns server ipv6 address
Pi Hole, Speedport, IPV6 - ich weiß nicht weiter
Hosts + local.list of PIHOLE?
Webpages are really slow or even not loading. windows 10, chrome
Pi-hole v3.1 Has Been Released
Local host querying api.github a lot
Ipv6 error
Merkwürdiges Verhalten von Pi-Hole
What is setupVars.conf and how do I use it?
More web site slow
Certain pages won't load in Safari
Why does my IPv6 address disappear after a little while?
PiHole unable to resolve DNS
I'm having trouble with my DNS and I don't know where to start troubleshooting
HTTPS Slow, all known commands/patches have been applied without success :'(
PiHole has 2 ip addresses
Pihole blocking 0% of queries
IPv6 and privacy
Pi hole enabled but not blocking ads
Pi hole enabled but not blocking ads
Been having a couple problems on "Installation Complete" and DNS
Some websites are failing to load
Unbound: Connnection times out
Not able to update to release 4.0
High CPU, High RAM, not working, dnsmasq issues? - Solved
Probleme mit Blacklist´s unter IPv6
Pihole stops responding after a little while
Queries time out - but actually take up to 3 minutes before Pi-hole resolves them
Comp missing from top client list (total)
[fixed] Pi-Hole newbie with DNS issues
[fixed] Pi-Hole newbie with DNS issues
[fixed] Pi-Hole newbie with DNS issues
[fixed] Pi-Hole newbie with DNS issues
Unable to access pihole admin interface
PiHole Stats increasing and decreasing erratically
Sporadische Internetausfälle Pihole + Raspi4 + Fritz 7490
pihole sur reseau ayant 2 routeurs
Problems with changing ipv6 adress and Pi-Hole. Anyone has a hint?
Can't connect to admin page
PiHole randomly stop serving DNS
FRITZ!Box und mehrere IPv6 Adressen
Internet Only Working on Pihole, No Ad-blocking
Domain names not getting resolved when pinging but IP Address works
Unexplained pi-hole fail
Posting debug -- Pihole doing nothing -- please help.
While using Pi-hole as only DNS, nothing is loading
Pihole multiple errors upon reinstall
No ipv6 address shown
DHCP Not working (docker)
DHCP Not working (docker)
Fresh Pihole is just forwarding everything!?
can't update blocklist
Debugging Tool does not use Ping6 correctly
Pi-hole error installing in ubuntu 18.04.3
Ads not blocked - IPv6 problem?
Why Some Pages Load Slow When Using Pi-hole And How To Fix It (for versions < v4.0)
Must repair Pihole everyday or not working
Pi-Hole Not Working (not resolving DNS)
Pihole stops working until reinstallation
Does Pi-hole require a static IPv6?
IP mismatch and gateway not responding - Networking Configuration Issues
Why do some sites take forever to load when using Pi-hole? (for versions < v4.0)
Can't get pihole to work on br0 interface
Automatically handling IPv6 address changes in pihole beta5
Bedeutungen der Warnungen im Debug Log
Sudo problema
Fierfox or chrome connecting to sites not visited
Ads galore on devices after installing. Is this to be expected? Does it need to run a few days?
Ununterbrochene Abfragen komme nicht ins Netz
Only my router is using Pi-hole
Total Queries Clients
Pihole mit Vodafone Station DSlite
IPv6 and PiHole DHCP server
IPv6 mismatch
Does this log show incorrect settings or implementation?
Does this log show incorrect settings or implementation?
Can someone please check my debug log?
Best solution for an IPv6 issue with one device
Pi hole not blocking ads on PC, works on mobile
Leider funktioniert das ganze nicht
Raspberry Pi B+ Help with installing
Raspberry Pi B+ Help with installing
iOS Apps mit Internetzugriff sehr langsam
Pi Hole no longer resolving for network clients
Why do I keep seeing Ads, been trying to set Pi-Hole for 10 hours now
Pi Hole blockt nach Update auf 5.0 nichts mehr / und kein Balkendiagramm
Install Fail on DO 18.04 LTS Droplet
I can't access the admin page of Pi-hole using the dns name
PiHole falls off network after reboot
Incorrect Hostnames
Mobile ads and wayward clients (Unifi UDM Pro)
Ein Gerät für das Internet sperren (nur 4 augewählte Domains zulassen)
Weird Dashboard behavior. It's fixed, but wish I understand what happened
Pi-Hole doesn't work
(solved) Pi-hole works on clients but not on the Raspi4 itself
IPv6 upstream DNS servers not selectable
Pi-hole IPv6 Setup Questions
Pi-hole + Unbound + PiVPN = No ad blocking?
Inconsistent/broken IPv6 DNS resolution
iOS 14.01 kills pihole
IPV6 Adresse aktualisiert sich selbstständig
Keine Internet verbindung
Just installed - Seeing tons of <hostname>.lan and <hostname>.lan.lan in Query Logs
Two Pi-holes in Parallel IPv4 & IPv6 config
Pi-hole with IPv6
Pihole blockt nach einiger Zeit keine Werbung mehr
Issues regarding ipv6
Pi hole blockt "gefühlt zuwenig"
Pi-hole Reverse DNS queries every hour
Blocked https links stall for 20 seconds
Group assigment
5Ghz Internet Ausfall - PiHole FRITZ!Box 6591, FRITZ!Repeater 2400
No internet after changing DNS to Pi Hole
Ensuring IPv6 setup and configuration to eth0
Router requires multiple DNS entries
No internet on LAN
Router is the only recognized domain
Internetverkehr wird alle paar Wochen komplett geblockt
Pi-hole is not blocking ads
NSlookup is not working on client machines
How do I mitigate my ISP changing my IPv6 address?
PiHole shows no activity
Every 2 minutes 0.debian.pool.ntp.org queries by both Raspberry Pi's in my network
Pi Hole stopped receiving DNS queries
Ipv4 and ipv6 Missing?
Clients don't use Pi-hole
Pihole does not report the actual traffic
Pihole does not Block Queries, 0% Blocked displayed. But I dont see many Ads either
Speedport Smart 4 und IPv6
Pi-hole not blocking ads
"FTL offline" and "Lost connection to API"
IPv6 Address Change
Trouble sending queries to link-local (IPv6)
No DNS resolving with use of de IPv6 LLA of the server
"FTL offline" and "Lost connection to API"
Can't connect to web interface (I have no idea what I'm doing)
Trouble setting up IPv6 with Pi-Hole
Pi-hole won’t work unless dns service is manually restarted after each boot
Web Interface not showing any queries
Pihole is not working - Help
Pi-hole funktioniert nicht
Pihole macht nicht was er soll
How can I start IVP6
IPv6 setup and Fritzbox
If you have a firewall enabled on your Pi open port 443 if you get timeouts, it might help
Temporary failure in name resolution
Pihole works after restarting dns but stops blocking ads after a few minutes
Websites timing out
Pi Hole seems not to block ads although it's active
Trouble blacklisting and blocking ads
Blacklist problem
Fails loading https sites on iOS

Deutsche Telekom - Speedport W 723V

1 Like

Deutsche Telekom - Speedport W 724V

1 Like

A post was split to a new topic: IPv6 ULA and Fritzbox

Fritzbox Cable 6490 (Firmware 6.51) Thanks @Dmx !

This option is also available in the Fritzbox 7490 and @Erdnussknacker suggests that it should be available on all Fritzboxes running FRITZ!OS firmware greater equal version 6.50.

4 Likes

A post was merged into an existing topic: IPv6 ULA and Fritzbox

So I started getting IPv6 from my ISP recently. And here's how I got ULA working with pi-hole and pfsense router.
I get IPv6 by DHCP6 on the WAN interface with "Use IPv4 connectivity as parent interface" & "Send IPv6 prefix hint" checked, and a prefix size of 64. On the LAN side it's set to track-interface (wan).

  1. Set ULA in RA subnet (pfsense)
    In Services > DHCPv6 > RA, under Advertisements, add a subnet fd00:: and prefix /64
    Note: We don't need DHCPv6 server. It's disabled by default - it's ok to leave it as it is.
  2. Set static pihole IPv6 (ULA)
    On the pihole, set a static IPv6 (Debian in my case) fd00::20/64 without any gateway or DNS. Refresh your interface "ifdown ens160; ifup ens160" and check your IP with ifconfig. Ideally you should see an fe (link-local),fd(static ULA)and 2000 (GLA) IP, and you should be able to ping6 google.
  3. Check connectivity
    Now you should be able to ping pihole's IPv6 (fd00::20) from your computer.
  4. Add pihole ULA in pfsense DNS
    In pfsense System > General, assuming you have already entered pihole's IPv4 address there, add pihole's IPv6 address as well with the gateway as none. RA will send the LAN interfaces' IPv6 to clients (which changes on boot).
    Note: This is assuming that you have DNS forwarder enabled.
  5. A reboot maybe required to realize the setting done in step 1 and/or 4
1 Like

For all users of the Speedport Hybrid router by Deutsche Telekom: take a look at the above screenshot for the Speedport W 724V, it's the same as for the Hybrid.

Home network -> Home network (LAN) -> Name and address of the router -> Use local IPv6 address (ULA)

What is the suggested way if the router does not have the option to turn on ULA? I'm having a "Connect Box" from my ISP (UPC). :frowning:

1 Like

I wonder this as well. I have an Arris gateway from Spectrum and am using the Pi-hole as a DHCP server. Is there any way the Pi can handle this, or does it need to be the gateway?

Anyone know how to do this with a Ubiquiti Edgerouter-X? I have one of those behind a XB3 set to bridge mode and I appear to be getting IPv6 and really slow page loads sometimes.

If you have slow page loads, take a look at our guide for IPTables rules and see if those help. I have an ER-X SFP and just have a few rules to handle things. I'm not sure offhand how to set up ULA but I do know it's possible, but done via command line when setting up the DHCP server portion.

1 Like

Literally following the same guide you linked. I'll skip to that section if you think that's the issue though.

I noticed my IPv6 GUA changes, whenever I reboot my router and found @DL6ER script here, unfortunately, this script runs 'pihole -g' (and restarts dnsmasq or FTLDNS), even if the IPv6 address didn't change, so I improved the script.

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)

#!/bin/bash

# read current IPv6 address from file
CURRENT_IPV6_ADDRESS=$(ip -6 a | grep '2a02' | awk -F " " '{gsub("/[0-9]*",""); print $2}')

# read/compare previous IPv6 address from file
file=/etc/pihole/setupVars.conf
if ! grep -q "$CURRENT_IPV6_ADDRESS" $file; then
	sed -i.bak "/IPV6_ADDRESS/d;" "/etc/pihole/setupVars.conf"
	echo "IPV6_ADDRESS=${CURRENT_IPV6_ADDRESS}" >> "/etc/pihole/setupVars.conf"
	{
		echo to: <your gmail address>
		echo from: <your gmail address>
		echo subject: pihole IPv6 address change
		echo
		cat /etc/pihole/setupVars.conf
	} | /usr/sbin/ssmtp <your gmail address>
	/usr/local/bin/pihole updateGravity
fi

The script also sends me a mail, whenever the IPv6 address changed, for this to work, you need to follow the instruction in my manual, section 4.9 (install mail) and change 'your gmail address' in the script, with the desired gmail address (needs to be changed 3 times)

In order to automate the IPv6 update, you might want to add it to cron. Create /etc/cron.d/IPv6check, containing:

29 6    * * *   root    PATH="$PATH:/home/pi/" /home/pi/IPv6check.sh

change the time to something appropriate for you, I run it at 06h29

edit
correct wrong SUFFIX in sed -i command, changed from sed -i.setupVars.bak to sed -i.bak
/edit

edit2
When the job runs with cron, pihole -g isn't a valid command. Replaced the command with /usr/local/bin/pihole updateGravity
/edit2

3 Likes

Hello. When running the 4th command: echo "IPV6_ADDRESS=${IPV6_ADDRESS}" >> "/etc/pihole/setupVars.conf" I get a permission denied error, even when using sudo. I’m trying to add the IPV6 address to the config file but having no success. Any ideas? Thanks.

Can't edit the existing entry, so here is the latest version of the script, the echo command is eliminated in this version.

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)

#!/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"
	{
		echo to: <your gmail address>
		echo from: <your gmail address>
		echo subject: pihole IPv6 address change
		echo
		cat /etc/pihole/setupVars.conf | grep 'ADDRESS'
	} | /usr/sbin/ssmtp <your gmail address>
	/usr/local/bin/pihole updateGravity
fi

Remember, the mail portion of the script only works if you setup mail, as explained in my manual , section 4.9 (install mail) and change ‘your gmail address’ in the script, with the desired gmail address (needs to be changed 3 times)

1 Like

Hello. Thanks for your response. This is very very confusing. The script you provided seems to update IPV6 addresses when they change, but the IPV6 address the Pi is using is a fe80 address that from my understanding is the static/LAN IP address. Correct me if I’m wrong, but isn’t that different from adding the ULA to vars.config file???

If you're using a static IPv6 address, you don't need this script.
The script is only intended to overcome changing IPv6 addresses.
As far as I know, setupVars.conf can only contain one IPv6 address. The address is used by pihole-FTL to return the correct address, incase you're using blocking modes that would show a blocking page, e.g. BLOCKINGMODE=IP-NODATA-AAAA or BLOCKINGMODE=IP

1 Like

Thank you for your approach but I encountered a small problem during the implementation :wink:

The GUA also contained the letters FD and therefore I got the GUA and the ULA address.

pi@ns17:~ $ IPV6_ADDRESS=$(ip -6 a | grep 'fc\|fd' | awk -F " " '{gsub("/[0-9]*",""); print $2}')
pi@ns17:~ $ echo ${IPV6_ADDRESS}
2a0a:xxxx:xxxx:xxxx:xxxx:xxxx:xxfd:xxxx fdxx::xxxx:xxxx:xxxx:xxxx

With a small modification, only the ULA are displayed.

pi@ns17:~ $ IPV6_ADDRESS=$(ip -6 a | grep '\<fc\|\<fd' | awk -F " " '{gsub("/[0-9]*",""); print $2}')
pi@ns17:~ $ echo ${IPV6_ADDRESS}
fdxx::xxxx:xxxx:xxxx:xxxx
2 Likes

Ah, yes, I should really have thought about adding an anchor there. I just edited the first message in this thread to use what you proposed.