Https redirect for subdomains

Hello,
What is best way to achieve this. You tube adds are frequent popping up repeatedly.
I have captured its url. all these are https urls going to sub domain
All these urls are dynamic. They are changing to random values. If these urls are blocked, apps on network does not work. so I planned fake url on one of the server in network. is it possible to redirect all the subdomain request to this server. I made below configuration, but ip of subdomains are different every time.

image

Can Any one suggest the best solution for this ?

This cannot be done at the router level, since it happens at the application layer. You need to do this at the browser level on your computer.

3 Likes

You can add a wildcard redirect in dnsmasq, but I'm not sure how it's going to solve the problem with the ads.

2 Likes

Server, 180 is windows server. It has IIS and it can have proxy etc. server is capable to manipulate the https request and return the status code 200. it may return any value that all clients want which youtube video url will serve. problem is I want to direct all subdomain request that goes to googlevideo.com to this server at router level.

Is this option suitable?

exactly what I was going for, except I didn't think it could be done through the UI.

from the conf file

# Add domains which you want to force to an IP address here.
# The example below send any host in double-click.net to a local
# web-server.
#address=/double-click.net/127.0.0.1
1 Like

config file name ?
Sorry I am not expert.

/etc/config/dhcp

1 Like

image

I have this entry. Shall I make it *.googlevideo.com instead of googlevideo.com or /googlevideo.com

I'd put it in /etc/dnsmasq.conf, with the syntax from the example I posted.

1 Like

Thanks every one. I got it how to redirect to my server and its redirecting. I need to do further work.

image

Machine, 10.0.0.180 is also connected to same network so it can not place request googlevideo.com so I need to exclude this machine from blocked url. and then making request to youtube I have to serve the calling client. So I need way to exclude this machine from the block.

https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1189465#1189465

Adapted the script for openwrt and to run twice a day (sometimes manifest.googlevideo.com would change IPs twice a day), it used to block all YT ads. SurprisedItWorks got tired with the cat and mouse...

did you try it ?
comments say it doesn't work any more ...

Yep, it was great while it lasted. I added lists from other projects that attempted the same (failing), nevertheless the lists were useful.

then why did you post it ?

Configure 10.0.0.180 to use a different DNS server which doesn't have the intercept in place?

@kpise here's the short version script, it won't block all ads as it used to but it still manages to block a few. Simply blocking or redirecting won't work as it will end up blocking videos too. The script must run at least twice a day.

Just tried the script but it fails to print the result of nslookup manifest.googlevideo.com so i had to add it manually, I can't find out what's wrong with it, maybe someone here...

dhcp add these two lines.

list address '/1e100.net/0.0.0.0'
list addnhosts '/tmp/badhosts'

#YT adblocker (ipv4).

cat <<'EOF' >/tmp/adblocker
#!/bin/sh
cd /tmp
D=manifest.googlevideo.com
DD=$(echo $D | sed 's/\./\\./g')
{ curl -kf https://gist.githubusercontent.com/seanhandley/d76c51099a32287c0a9074d5f15ac7d0/raw/2bde83a93e68208585d602df787d782036271438/gistfile1.txt
  curl -kf https://raw.githubusercontent.com/T81/youtube-ads-blocker-ddwrt/master/domainlist.txt
  curl -kf https://raw.githubusercontent.com/jerryn70/GoodbyeAds/master/Extension/GoodbyeAds-YouTube-AdBlock.txt
  curl -kf https://raw.githubusercontent.com/anudeepND/youtubeadsblacklist/master/domainlist.txt | sed '/---/d;s/^/0.0.0.0 &/'
  curl -kf https://raw.githubusercontent.com/tdgomes/Ads-Youtube-PT/master/youtubeads.txt | sed '/---/d;s/^/0.0.0.0 &/'
  curl -kf https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/master/crowed_list.txt | sed '/---/d;s/^/0.0.0.0 &/'
  curl -kf https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/master/youtubelist.txt | sed '/---/d;s/^/0.0.0.0 &/'
} 2>badhosts.log | sed "s/\t/ /g; /^0\.0\.0\.0 /!d; s/ *\#.*$//; s/\r//; / $DD$/d" | sort -u > badhosts
service dnsmasq restart; sleep 5
A='^Address [0-9]+: '; I='[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'
nslookup $D 2>/dev/null | sed -nE "/$A$I/{s/$A($I).*/\1 $D/p;q}" >>badhosts
service dnsmasq restart
EOF
chmod +x /tmp/adblocker
( sleep 90; /tmp/adblocker ) &
root@OpenWrt:/tmp# nslookup manifest.googlevideo.com
Server:         127.0.0.1
Address:        127.0.0.1:53

Name:   manifest.googlevideo.com
Address: 142.250.79.14
root@OpenWrt:/tmp# grep manifest.googlevideo.com badhosts
142.250.79.14 manifest.googlevideo.com
root@OpenWrt:/tmp# wc -l badhosts
107973 badhosts