I'm currently analizing this (youtube ad blocking) script, the result is raising some questions.
1. I'm a bit confused about the pihole restartdns
command.
According to the help
restartdns Full restart Pi-hole subsystems
Add 'reload' to update the lists and flush the cache without restarting the DNS server
Add 'reload-lists' to only update the lists WITHOUT flushing the cache or restarting the DNS server
pihole restartdns reload-lists
should update the lists, however if I add entries to a file (/etc/hosts.youtube) and execute that command, I still get the real IP address, as opposed to the configured address (using dig or nslookup).
When I use pihole restartdns reload
, the configured IP address is returned.
The help entry says reload-lists
should update the lists but apparently, only reload
does that.
When I use reload-lists
, there are no pihole.log entries, when I use reload
, the following messages appear in the log (which is what I want, but expected to happen using reload-lists
:
May 8 10:04:45 dnsmasq[12831]: read /etc/hosts - 15 addresses
May 8 10:04:45 dnsmasq[12831]: read /etc/hosts.youtube - 166 addresses
May 8 10:04:45 dnsmasq[12831]: read /etc/localdns.list - 40 addresses
May 8 10:04:45 dnsmasq[12831]: read /etc/pihole/custom.list - 0 addresses
May 8 10:04:45 dnsmasq[12831]: read /etc/pihole/local.list - 4 addresses
What am I missing?
2. cname blocking
The script from the topic, mentioned earlier, ads entries to /etc/hosts.youtube. I've already changed /usr/local/bin/pihole restartdns reload-lists
into /usr/local/bin/pihole restartdns reload
, to overcome the first problem (see above)
The script ads the following entries (example):
173.194.182.198 r5.sn-4g5e6nzs.googlevideo.com
This is an entry for the A record, dig result:
pi@raspberrypi:~ $ dig +noidnin +noidnout r5---sn-4g5e6nzs.googlevideo.com
; <<>> DiG 9.11.5-P4-5.1-Raspbian <<>> +noidnin +noidnout r5---sn-4g5e6nzs.googlevideo.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29317
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1472
;; QUESTION SECTION:
;r5---sn-4g5e6nzs.googlevideo.com. IN A
;; ANSWER SECTION:
r5---sn-4g5e6nzs.googlevideo.com. 30 IN CNAME r5.sn-4g5e6nzs.googlevideo.com.
r5.sn-4g5e6nzs.googlevideo.com. 30 IN A 74.125.13.234
;; Query time: 3 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri May 08 10:20:12 CEST 2020
;; MSG SIZE rcvd: 106
When you start a youtube video, a request is made to r5---sn-4g5e6nzs.googlevideo.com
, which is a cname for r5.sn-4g5e6nzs.googlevideo.com
since r5.sn-4g5e6nzs.googlevideo.com
is in /etc/hosts.youtube, I hoped the cname blocking feature would also notice there is a configured address for the A record, but apparently, the cname feature doesn't do that. Is this intentional (works as designed - block only) or is there something I'm missing?
Thank you for your clarifications.