Request: DNS rewrites planned?

Just curious and a relaxed request: Is it planned to introduce DNS rewrite capability? To answer not just 0.0.0.0 but something configurable to certain requests? Thanks for your work, very much appreciated.

Testing pi-hole 5.0 on a dietpi, where almost everything is working great, just one small hiccup because it is not using lighthttpd. One

usermod -a -G pihole www-data

later, this was fixed.

1 Like

That can already be achieved now by injecting additional host records into dnsmasq, or simply by editing /etc/hosts (see also implemented FR Domain Redirect).

1 Like

In this topic, @anon55913113 came up with a way to achieve this, using only dnsmasq conf file entries. repeating the example:

host-record=safe.duckduckgo.com,50.16.250.179
cname=duckduckgo.com,www.duckduckgo.com,safe.duckduckgo.com
cname=duck.com,www.duck.com,safe.duckduckgo.com
1 Like

This can also be done via CLI, as detailed in the linked FR above, e.g.:
pihole -a hostrecord home.mydomain.de 192.168.1.10

moderator edit: pihole -a hostrecord may have side effects, read the entire discussion before using this command!

1 Like

It seems like you can’t add two records to the same IP though, which is disappointing...

If I add the following for example:

pihole -a hostrecord app1.loadbalancer.example.com 192.168.1.10
pihole -a hostrecord app2.loadbalancer.example.com 192.168.1.10
pihole -a hostrecord app3.loadbalancer.example.com 192.168.1.10
pihole -a hostrecord app4.loadbalancer.example.com 192.168.1.10

Only the last one actually works, the rest are all overwritten.

Did you use the cname option shown in a previous reply?

No, I just added multiple entries to /etc/dnsmasq.d/01-pihole.conf and that worked, since that’s what the command above does basically as per this.
I’m just saying, the command doesn’t work properly.

dschaper@nanopineo:~$ head -n20 /etc/dnsmasq.d/01-pihole.conf
# Pi-hole: A black hole for Internet advertisements
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
# Network-wide ad blocking via your own hardware.
#
# Dnsmasq config for Pi-hole's FTLDNS
#
# This file is copyright under the latest version of the EUPL.
# Please see LICENSE file for your rights under this license.

###############################################################################
#      FILE AUTOMATICALLY POPULATED BY PI-HOLE INSTALL/UPDATE PROCEDURE.      #
# ANY CHANGES MADE TO THIS FILE AFTER INSTALL WILL BE LOST ON THE NEXT UPDATE #
#                                                                             #
#        IF YOU WISH TO CHANGE THE UPSTREAM SERVERS, CHANGE THEM IN:          #
#                      /etc/pihole/setupVars.conf                             #
#                                                                             #
#        ANY OTHER CHANGES SHOULD BE MADE IN A SEPARATE CONFIG FILE           #
#                    WITHIN /etc/dnsmasq.d/yourname.conf                      #
###############################################################################

I can confirm that pihole -a hostrecord only writes or alters a single host-record= line to 01-pihole.conf.

Pihole v5 will allow you to add Custom DNS entries via its UI.

With v4, you still could alter /etc/hosts, or create a separate file (named e.g. /etc/dnsmasq.d/50-hostrecords.conf) and manually add several lines. That way, they would be safe from being overwritten on Pihole updates (as Dan pointed out for manual edits of 01-pihole.conf).

It does, this is the expected behavior, quoting man pihole:
Screenshot from 2020-04-23 12-57-25
where it says an IPv4/IPv6 address.

This was added a long time ago

I just checked the description there - it is doing exactly what it is supposed to do.

Furthermore, the help confirms this:

$ pihole -a hostrecord -h
Usage: pihole -a hostrecord <domain> [IPv4-address],[IPv6-address]
Example: 'pihole -a hostrecord home.domain.com 192.168.1.1,2001:db8:a0b:12f0::1'
Add a name to the DNS associated to an IPv4/IPv6 address

Options:
  ""                  Empty: Remove host record
  -h, --help          Show this help dialog

Note that many of the -a options should not be used directly. They are used internally by the pi.hole/admin interface (hence the a). Their behavior might change at any time and without further notice when this is necessary for the proper function of the dashboard.
We are trimming the dashboard to use less and less CLI commands in the backend, so be prepared that these internal commands may simply disappear at some point. Again, without further notice.

Doing such involved DNS configuration should not be an everyday task. It is also not something inexperienced users shouldn't do, probably. So going to your Pi-hole and modifying some config file for this seems acceptable.

@DanSchaper is right when citing

Even more, your changes will likely overwritten by the first settings change you do on the dashboard. Hence, you should put your lines in a separate file to avoid headaches:

edit: Added man page screenshot + marked unnecessary comments appropriately.

58 users think that pihole -a hostrecord is useless. Even when it originally fixed an issue a user had.

We'll finally remove this option with v5.0 to avoid further confusion, sorry, I wasn't aware of that it was causing such an immense pain. We don't get pinged when you react with :+1: to an issue so we don't feel the "level of suffering" a feature creates.

For users of this feature:

  • We will not remove existing host records.
  • The Custom DNS page is an adequate replacement. It can be accessed from the dashboard.
  • If you cannot use the dashboard, please add your records to /etc/pihole/custom.list or /etc/hosts and run pihole restartdns reload afterwards.
2 Likes

Done.

This isn't a Feature Request, there's no votes involved?

I'm missing something here. The feature was added (a long time ago). New functionality has since been added in V5.0 that makes this feature superfluous, and it has been removed.

1 Like

"We're sorry guys, this feature got down-voted very often and we missed it. We'll remove it to avoid further confusion."

He was referring to 58 upvotes for a comment that said the option doesn't make sense.
"This option makes zero sense if it's only for one record"

Maybe he mixed up up/downvotes or translated upvotes for negativ comment into downvotes internally :slight_smile:

Great, not sure where the 5 votes for discourse comes in to play other than to complain that yet another thing we don't do right, but hey, we get that a lot.

I think they do (most often).

Yes, 58 voted for "this doesn't make sense". I translated this into "58 don't like the current implementation".

Where is the confusion now? I'm not sure if I'm missing something, but I don't think so.

GitHub is the repository for the Pi-hole code, where the development work is actually completed.

Yes, many.

GitHub is the definitive location.