# Custom redirect IP address

**URL:** <https://discourse.pi-hole.net/t/custom-redirect-ip-address/15010>\
**Category:** Feature Requests\
**Created:** [December 10, 2018, 10:02am UTC](https://discourse.pi-hole.net/t/custom-redirect-ip-address/15010 "2018-12-10T10:02:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kuro68k](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/k/a698b9/32.png) [@kuro68k](https://discourse.pi-hole.net/u/kuro68k)\
**Post date:** [December 10, 2018, 10:02am UTC](https://discourse.pi-hole.net/t/custom-redirect-ip-address/15010/1 "2018-12-10T10:02:24Z")

</div>

For blocking some services such as YouTube it would be helpful to be able to configure the redirect domain/IP address when using regex filtering with FTLDNS.

At the moment BLOCKINGMODE only has options for using PiHole's IP and built in web server, but for YouTube and doubtless other services that causes problems. To effectively block YouTube ads we need to redirect all YouTube ad servers via regex to googlevideo.com (or one of its IP addresses).

Simply blocking these servers causes the YouTube app to keep trying different ones endlessly and the video does not play. Redirecting to the PiHole web server does not work because YouTube uses HTTPS and probably pinned certificates too.

---

<div class="post-metadata">

**Author:** ![DanSchaper](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/danschaper/32/91_2.png) [@DanSchaper](https://discourse.pi-hole.net/u/DanSchaper)\
**Post date:** [December 10, 2018, 10:06am UTC](https://discourse.pi-hole.net/t/custom-redirect-ip-address/15010/2 "2018-12-10T10:06:01Z")

</div>

How would this work, redirect blockthisdomain.com to googlevideo.com's IP address (which is all we can do, we only deal with IP addresses) and any response from googlevideo.com will be rejected by the client as the certificate from googlevideo will not cover blockthisdomain.com?

---

<div class="post-metadata">

**Author:** ![kuro68k](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/k/a698b9/32.png) [@kuro68k](https://discourse.pi-hole.net/u/kuro68k)\
**Post date:** [December 10, 2018, 10:34am UTC](https://discourse.pi-hole.net/t/custom-redirect-ip-address/15010/3 "2018-12-10T10:34:55Z")

</div>

For whatever reason redirecting the YouTube ad server domains to googlevideo.com works. That domain coordinates the video servers in some way, and must be returning a response that the app is happy with (maybe just any HTTPS 404 with a valid Google cert, who knows).

The problem is that there are thousands of YouTube ad server domains and backlisting them manually is aiming for a constantly moving target. A regex works great but because it can't redirect to googlevideo.com it breaks the YouTube app.

---

<div class="post-metadata">

**Author:** ![jfb](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/jfb/32/4332_2.png) [@jfb](https://discourse.pi-hole.net/u/jfb)\
**Post date:** [December 10, 2018, 1:45pm UTC](https://discourse.pi-hole.net/t/custom-redirect-ip-address/15010/4 "2018-12-10T13:45:44Z")

</div>

It sounds like you need a proxy to inspect the requested domain, compare to a regex filter, and return the domain you need.

---

<div class="post-metadata">

**Author:** ![kuro68k](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/k/a698b9/32.png) [@kuro68k](https://discourse.pi-hole.net/u/kuro68k)\
**Post date:** [December 10, 2018, 1:54pm UTC](https://discourse.pi-hole.net/t/custom-redirect-ip-address/15010/5 "2018-12-10T13:54:56Z")

</div>

In the olden days yes, I would have used a proxy. But because it's HTTPS and you can't install your own certs on most smart TVs a proxy isn't going to work.

---

<div class="post-metadata">

**Author:** ![jfb](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/jfb/32/4332_2.png) [@jfb](https://discourse.pi-hole.net/u/jfb)\
**Post date:** [December 10, 2018, 4:23pm UTC](https://discourse.pi-hole.net/t/custom-redirect-ip-address/15010/6 "2018-12-10T16:23:53Z")

</div>

If it can't be done with a proxy, how would Pi-Hole do it?

---

<div class="post-metadata">

**Author:** ![kuro68k](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/k/a698b9/32.png) [@kuro68k](https://discourse.pi-hole.net/u/kuro68k)\
**Post date:** [December 10, 2018, 4:43pm UTC](https://discourse.pi-hole.net/t/custom-redirect-ip-address/15010/7 "2018-12-10T16:43:34Z")

</div>

Sorry, I thought you meant an HTTP proxy. A proxy inspecting DNS requests... Well it's possible but PiHole is so close to being able to do it. With dnsmasq you can redirect as explained [here](https://github.com/pi-hole/pi-hole/wiki/FAQs#can-i-redirect-a-domain-to-a-different-domain-333), but not with FTLDNS which is needed for the regex.

Looking at `dnsmasq_interface.c` it looks like IPV4\_ADDRESS is used for this redirect, so the first thing to do is manually try setting this to a googlevideo.com IP address and see if it has the desired effect. Then we can think about how to proceed - I suppose the ideal solution would be to have a per-regex redirect rather than a global one.

I'll give it a try. Unfortunately I don't have my main development machine at the moment so building PiHole to test patches could be tricky. I'm running it on a Pi, I guess I could build on that.

---

<div class="post-metadata">

**Author:** ![kuro68k](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/k/a698b9/32.png) [@kuro68k](https://discourse.pi-hole.net/u/kuro68k)\
**Post date:** [December 14, 2018, 5:43pm UTC](https://discourse.pi-hole.net/t/custom-redirect-ip-address/15010/9 "2018-12-14T17:43:46Z")

</div>

Okay, well the good news is that my plan works and the redirect does as I expected. The bad news is that the regex is a killing YouTube again and need improvement.
