Custom Redirects

I know this has been requested before but the provided soultions aren't satisfactory. Pi-hole started as a simple Adblocker but has since evolved into much more; it's now almost a fully featured DNS server.
You can already redirect DNS requests to different IPs by the means of Local DNS Records / /etc/hosts / /etc/pihole/custom.list but what I want/need is the full package, basically Blacklists but instead of redirecting to nothing it redirects to an IP, meaning

  • Regex
  • Group management
  • Comments

Some things to consider:

  • Specify multiple IPs / A records
  • Redirect has higher precedence than Blacklist
  • Automatically read /etc/hosts

Please clarify the features you are requesting.

Pi-hole already reads the /etc/hosts file, for example.

You can do everything you've asked for in the already fully featured DNS server that Pi-hole and FTLDNS is.

You may have to put in your own work to configure it, but considering it cost you nothing to use our software I don't think it's much to require you to do some things yourself.

  • Group management
    My use case is niche but I do think that it's valid. I have two identical devices in my network and I want to keep the first one on a specific firmware. The device checks whether there's an update available by asking a server. So I redirect the request to my own server which responds with "You're good!". But I'd like to keep the second device on the latest firmware (as in ask the real server) and use Pi-hole at the same time but since the current methods redirect that domain for every device that's not possible to achieve.
  • Regex
    The device doesn't always ask the same server for the latest firmware, imagine 01.eu.status.com
    02.eu.status.com
    03.eu.status.com
    which would just be ^\d{2}\.[a-z]{2}\.status\.com$. Yeah I could go ahead and add every fallback domain and every region (just to be safe), but a regex would be so much easier.
  • Multiple IPs
    I want to redirect all those domains to the same server, but I want to specify a fallback server in case the first one goes down.

Google around for dnsmasq configuration files that will do what you ask.

This is such a far off corner case that the time and effort it would take to satisfy a userbase of 1 just isn't going to happen.

What specific device is that?
By intuition, I would try to disable automatic updates on the device.
Isn't that possible?

Okay, maybe I was evaluating the situation wrong. I though that you guys could just use the same code that is being used for blacklists, but instead of redirecting to/responding with nothing, redirect to a specific IP.

This is where you map the name to an IP in /etc/hosts or in the Local DNS records. When that domain name is queried, the client gets that IP in return.

They're PS4s. Automatic updates are already disabled but the device still asks Sony for the latest firmware. I have to keep the first (lower fw) device online because I send my packages to it over FTP. I've already redirected most of the important domains, blacklisted the rest and am keeping the second (updated) device on my ISP's DNS, but I'd like to use Pi-hole for my whole network.

You can do all of this now, you just have to configure it yourself instead of having a web interface to do it.

Yeah, I've done that. But I want the other device to contact the actual server.

Map that IP to the domain name on the local hosts file on that device. The query will be answered locally and never sent to Pi-hole.

Hm, I didn't know that. So I can basically emulate group management just through dnsmasq?

That may be possible (since it's jailbroken), but Pi-hole offers much more control to be honest. Again, it's possible that you can do all of that manually, but Pi-hole could use such a feature to be complete IMHO.

Again, Pi-hole can do all you want right now, you just have to put in the time and effort to configure it.

Well, I can't seem to figure out how to do that with Pi-hole (it looks like I need DHCP?) but my current method consisting of Local DNS Records, blacklisting the regex and whitelisting the redirects works okayish. I'll just have to avoid Pi-hole on my second device; not a big deal.

Don't waste your energy trying to explain it to me because it looks very complicated and I'll probably won't understand it anyway, just please consider it for the future.

Today I randomly had another idea and even though it might not be terribly useful I wanna get it off my head: redirect domain to domain. So instead of just redirecting the host request to an IP address, Pi-hole would actually resolve the target domain and redirect the request domain to that.

That's what CNAME entries do.
Pihole will likely contain the ability to set those in a next version

1 Like

It's been a while since I've looked into this, but I visit this one year old request from time to time to check for new comments. Is this still something that's considered too niche to implement? From my short research it looks like dnsmasq doesn't even understand RegEx to begin with (I found a fork which does though) and I'm not sure how to solve this on my own.
Anyway, even with the original goal of blocking ads, I can still see redirects as being useful. Sometimes you have Javascript which detects if an ad loads, so straight up blocking that with Pi-hole would only trigger their Anti-Adblock. If you instead redirect it to something else, something you control, you could theoretically trick their countermeasures.
Also, as I said in the OP, simple redirects are not exactly what I want. I'd like to combine them with other Pi-hole features, such as Group managment and RegEx matching. Local changes on the device in question are not possible, and I wouldn't want to redirect the requests for every device on my network, so I'm left with not using my Pi-hole network-wide because of that.

This feature request currently has zero votes.