Pi-hole 默认的 StevenBlack 列表会拦截 s.youtube.com 导致视频无法播放,需用 pihole allow s.youtube.com(v6)或 pihole -w s.youtube.com(v5)放行;脚本必须在装有 Pi-hole 的机器或容器内运行,Docker 部署请改用订阅链接方式;无法拦截服务端拼接进视频流的广告,也拦不住绕过你 DNS 的设备。
youTube_ads_4_pi-hole
kboghdady活跃维护给 Pi-hole、AdGuard Home 等 DNS 拦截器用的 YouTube 广告域名黑名单,加一条订阅链接就能让全网设备屏蔽 YouTube 广告,每天自动更新。
YouTube ad-serving domain blocklist for Pi-hole (v5 & v6), AdGuard Home, pfBlockerNG and other DNS blockers - add one URL and block YouTube ads on every device on your network. Updated daily.
git clone https://github.com/kboghdady/youTube_ads_4_pi-hole.git
cd youTube_ads_4_pi-hole
sudo ./youtube.shREADME 未说明硬件要求;需运行 Pi-hole、AdGuard Home、pfBlockerNG 等 DNS 拦截器的设备或容器,脚本需在装有 Pi-hole 的机器上运行。
给 Pi-hole 等 DNS 拦截器用的 YouTube 广告域名列表,加一条订阅链接就能全网设备生效
给 Pi-hole、AdGuard Home 等 DNS 拦截器用的 YouTube 广告域名黑名单,加一条订阅链接就能让全网设备屏蔽 YouTube 广告,每天自动更新。
核心能力
- 订阅一条 youtubelist.txt 链接即可拦截 YouTube 广告域名
- 用 ignore.list 过滤会破坏视频播放的域名
- 提供 youtube.sh 脚本把域名逐条写入 Pi-hole 拒绝列表
- 兼容 Pi-hole v5/v6、AdGuard Home、pfBlockerNG 等 DNS 拦截器
- 列表每日或隔日更新,收录约 1.6 万个域名
容易踩的坑
暂无 release 数据(可能没有发版,或尚未同步)。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
🚫 YouTube Ads Blocklist for Pi-hole
A community-maintained list of YouTube ad-serving domains — add one link to Pi-hole and you're done.
Last updated: Nov 8th 2026 - 16,104 domains in the list - works with Pi-hole v5 and v6, AdGuard Home, pfBlockerNG, Technitium and any other DNS blocker that accepts a hosts-style domain list.
📋 Table of contents
- Option 1 · Add the list to Pi-hole (recommended)
- Option 2 · Run the script
- Other DNS blockers (AdGuard Home, pfBlockerNG, Technitium, Blocky)
- What it does and doesn't do
- How it works
- The crowd list (optional)
- Troubleshooting
- Privacy
- Contributing
- Support the project
⚡ Option 1 · Add the list to Pi-hole (recommended)
The easiest way — nothing to install. Pi-hole downloads the list itself and refreshes it every time gravity updates.
- Open the Pi-hole web interface → Lists (Pi-hole v6) or Group Management → Adlists (Pi-hole v5).
- Paste this address into the Address field and click Add:
https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/refs/heads/master/youtubelist.txt - Update gravity so the list takes effect: Tools → Update Gravity, or from the terminal:
pihole -g
That's it. Pi-hole re-downloads the list on every gravity update (weekly by default — run pihole -g any time to get the latest version sooner). The published list already excludes everything in ignore.list, so videos keep playing.
💡 Using Pi-hole's default blocklist (StevenBlack hosts)? It blocks
s.youtube.com, which breaks video playback. Allow it once:pihole allow s.youtube.com # Pi-hole v6 pihole -w s.youtube.com # Pi-hole v5
🧰 Option 2 · Run the script
Prefer to have every domain as an exact entry in your denylist (visible under Domains in the web interface), add your own never-block entries, or pick up new domains every hour instead of at the next gravity update? Use youtube.sh.
Every time it runs it:
- downloads the latest
black.listfrom this repo, - drops everything that matches
ignore.list(so videos keep playing), - adds only the domains your Pi-hole doesn't have yet — the first run takes a few minutes, later runs finish in seconds,
- reloads Pi-hole's lists so the new domains are blocked right away.
It works with Pi-hole v5 and v6, needs nothing beyond what Pi-hole already installs, and re-runs itself with sudo if you forget.
Install
git clone https://github.com/kboghdady/youTube_ads_4_pi-hole.git
cd youTube_ads_4_pi-hole
sudo ./youtube.sh
You should see something like:
YouTube ads blocker for Pi-hole v6
[i] Downloading the latest YouTube ad list...
[+] 15855 domains in the list (0 skipped because of ignore.list)
[i] Adding 15855 new domain(s) to the denylist...
[i] This takes a few minutes the first time - later runs only add what is new
................................................................................
[+] Added 15855 domain(s)
[i] Reloading Pi-hole's lists...
[+] Shared 12 googlevideo.com hostname(s) from your query log - thank you!
[+] All done. Pi-hole is blocking 15855 YouTube ad domains.
Keep it updated automatically
Add the script to root's crontab so it picks up new domains on its own:
sudo crontab -e
Add this line to run it every hour (change the path if you cloned somewhere else):
0 * * * * /home/pi/youTube_ads_4_pi-hole/youtube.sh > /dev/null 2>&1
Tip: crontab.guru explains the schedule syntax if you'd like a different interval.
Options
| Option | What it does |
|---|---|
--dry-run | Show what would change without touching Pi-hole — great for a first look |
--no-share | Don't send googlevideo.com hostnames from your query log (see Privacy) |
--crowd | Also block the unfiltered crowd list (see The crowd list) |
-h, --help | Show the help text |
The same settings live at the top of youtube.sh if you'd rather change them permanently.
To add your own never-block entries, put them in the ignore.list next to the script (one per line — a full hostname or just a part of it, such as n4v7sne7). Your entries are merged with the latest ignore.list from this repo on every run.
🌐 Other DNS blockers (AdGuard Home, pfBlockerNG, Technitium, Blocky)
youtubelist.txt is a plain list of hostnames, one per line, so it works with any DNS-level ad blocker that can subscribe to a domain list — not only Pi-hole. Use the same address everywhere:
https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/refs/heads/master/youtubelist.txt
| Blocker | Where to add it |
|---|---|
| AdGuard Home | Filters → DNS blocklists → Add blocklist → Add a custom list, paste the URL |
| pfBlockerNG (pfSense) | Firewall → pfBlockerNG → DNSBL → DNSBL Groups, add a feed with the URL (format Auto) |
| Technitium DNS | Settings → Blocking → Block List URLs, add the URL |
| Blocky | Add the URL under blocking.denylists in config.yml |
| OPNsense Unbound | Services → Unbound DNS → Blocklist, add it as a custom blocklist URL |
Whatever you use, keep s.youtube.com and the hostnames in ignore.list allowed — they are needed for videos to play.
✅ What it does and doesn't do
It does
- Block the DNS lookups for known YouTube ad-serving hostnames, network-wide, on every device that uses your DNS server — smart TVs, phones, consoles and browsers alike, with nothing to install on them.
- Stop many pre-roll and mid-roll video ads from loading at all, instead of showing a skippable ad.
- Stay current: the list is refreshed every day or two from the hostnames users report (see Privacy).
It doesn't
- Block every ad. YouTube serves ads and videos from the same
googlevideo.comdomains and rotates them constantly; some ads will always slip through, and new hostnames take a day or two to reach the list. - Block ads that are stitched into the video stream itself (server-side ad insertion). No DNS blocker can — that needs a browser extension such as uBlock Origin or SponsorBlock on the device.
- Remove sponsor segments, banners, or ads inside the YouTube app on devices that bypass your DNS (for example, with DNS-over-HTTPS enabled or a hard-coded DNS server).
- Track you. Option 1 sends nothing anywhere; Option 2 shares only the hostnames described under Privacy, and you can turn that off.
For the best result, use this list on your DNS blocker and a browser extension on the devices where you can install one.
🧠 How it works
YouTube serves ads and videos from the same family of domains (*.googlevideo.com), so a normal blocklist can't tell them apart. This project keeps a curated list of the hostnames that only serve ads, and an ignore.list of the ones that break video playback. Both published lists are filtered against ignore.list before every update.
| File | What it is |
|---|---|
youtubelist.txt | The list to add to Pi-hole (Option 1) |
black.list | The same list, downloaded by youtube.sh (Option 2) |
ignore.list | Hostnames (or parts of them) that must never be blocked because they break videos |
crowed_list.txt | Raw, unfiltered domains gathered from the community — see The crowd list |
youtube.sh | The script behind Option 2 |
The list is refreshed every day or two.
👥 The crowd list (optional)
crowed_list.txt contains every googlevideo.com hostname reported by users of the script — including the ones that serve videos. It blocks more ads but is far more likely to break playback.
- As a Pi-hole list:
https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/refs/heads/master/crowed_list.txt - With the script:
sudo ./youtube.sh --crowd(or setINCLUDE_CROWD_LIST=trueat the top of the script)
Only use it if you know how to find and allow a blocked hostname in Pi-hole's query log.
🛠 Troubleshooting
- Make sure
s.youtube.comisn't blocked. Pi-hole's default list (StevenBlack hosts) includes it, and blocking it breaks playback:pihole allow s.youtube.com # Pi-hole v6 pihole -w s.youtube.com # Pi-hole v5 - Get the latest list. Run
pihole -g(Option 1) orsudo ./youtube.sh(Option 2) — the hostname may already have been removed from the list. - Find the culprit. Open the Pi-hole query log while the video fails and look for a blocked
r?---sn-xxxxxxx.googlevideo.comentry. Allow it in Pi-hole, then please open an issue or a pull request adding thesn-xxxxxxxpart toignore.listso everyone benefits. Script users can also add it to their localignore.listand runsudo ./youtube.shagain — it removes the domain from the denylist for you.
pihole-FTL sqlite3 /etc/pihole/gravity.db "DELETE FROM domainlist WHERE type = 1 AND domain LIKE '%googlevideo.com';"
pihole reloadlists # Pi-hole v6
pihole restartdns reload-lists # Pi-hole v5
If you also want the other ad domains gone (doubleclick.net, googlesyndication.com, …), delete by the comment the script writes instead:
pihole-FTL sqlite3 /etc/pihole/gravity.db "DELETE FROM domainlist WHERE comment = 'YouTube ads (youtube.sh)';"
The script has to run on the machine (or in the container) where Pi-hole is installed — it talks to Pi-hole through the pihole command. If Pi-hole runs in Docker, use Option 1 instead.
- Use root's crontab (
sudo crontab -e), not your user's. - Use the full path to the script, e.g.
/home/pi/youTube_ads_4_pi-hole/youtube.sh. - Run it by hand once with
sudo ./youtube.shto see any error messages.
🔒 Privacy
Option 1 sends nothing anywhere — Pi-hole just downloads a text file from GitHub.
To keep the list up to date, the script (Option 2) shares the googlevideo.com hostnames that your Pi-hole has seen in the last 24 hours. That's all it sends — no IP addresses, no client names, no other domains. The hostnames are collected through a Google Form and reviewed before anything is added to the list.
Don't want to share? Run the script with --no-share, or set SHARE_LOGS=false at the top of youtube.sh. Everything else works exactly the same.
🤝 Contributing
- Found an ad domain that isn't blocked? Open an issue / pull request against
youtubelist.txtandblack.list— or run the script with log sharing on and it will reach the list. - A domain breaks video playback? Open a pull request that adds it to
ignore.list. - Something in the script or docs is unclear? Issues and pull requests are very welcome.
☕ Support the project
Keeping the list current takes daily work. If it saves you from a few ads, consider buying me a coffee:
| Coin | Address |
|---|---|
| Bitcoin | 36fD957SDWHJYYzuH2xmceJ6T2qE9vNiV4 |
| XRP | rw2ciyaNshpHe7bCHo4bRWq6pqqynnWKQg |
Thank you! 🙏
