Migrating to new 'Custom DNS' tool

This isn't a problem, so much as a question. With Pi-Hole 4, I had local DNS running alongside the software. I set it up by running:

echo "addn-hosts=/etc/pihole/lan.list" | sudo tee /etc/dnsmasq.d/02-lan.conf

. . . and then putting the entries in /etc/pihole/lan.list and running sudo pihole restartdns after each change.

In Pi-Hole 5, there's a tool for local DNS within the software itself. (Thank you, this is awesome!) Is there any easy way to migrate the entries from the /etc/pihole/lan.list file into the new system? I can go through line by line, of course, but I just wondered, given that I have about 300 entries in my lan.list.

You should be able to just-copy paste your content into the file /etc/pihole/custom.list.

Hmm. For some reason it only reads some of the entries when I do that. I can't see a pattern. There must be something about the way my list is formatted?

It seems they need to be separated by single spaces:


sudo sed -i 's/ \+/ /g;s/\t\+/ /g;' /etc/pihole/custom.list

to have it auto-reformated for you.

And, obviously, make a backup before trying this :wink:

Thank you. I tried that, but doesn't make a difference. Only 22 of the 151 lines I'm entering are showing up. If I do it manually, they show up fine in the file. Mysterious.

Could you check if there is anything extra in the lines that do NOT show up?
Like spaces at the beginning or end of the lines. Or maybe comments or something else?

This is working now. I'll be perfectly honest: I don't know how or why. One of the entries on the list would just not show up, and including it was messing up the whole file. But if I add it through the GUI, it adds to the list nicely. Bizarre, but all set. Thanks for your help!

1 Like

If you are using comments (#), it won't process file correctly.
That's only thing that bothers me: I've just set my hosts file, nice, tidy, commented, now, just a bunch of hostnames and IP's... it would be nice to have groups here as well.

Feature requests are welcomed.

1 Like