HOWTO: Using Pi-hole DNS to block ads. The struggle continues… (2024)

This article is a work in progress. Updated: 2020-05-02. This isturning into a bit of a catch-up on the state of DNS for me.

Day 03 and 04 of #100DaysToOffload.

Intro

The war against ads continues. https://pi-hole.net/ looks like areasonable, good, new?, open source entry in the war against ads. Get‘yer source/install for linux at https://github.com/pi-hole/pi-hole

Per Paul Vixie

not even non-technical users need a “public DNS” to shield themselvesfrom a lot of known-evil internet sites. check out @The_Pi_Hole orhave your 12yo child or cousin install it.

..but I always make things harder.

HOWTO: Using Pi-hole DNS to block ads. The struggle continues… (1)

What

  • It’s a local DNS server to block adds.

Why

  • Blocking ads is a moral good.
  • I’ve not done home network hacking for a while.
  • I’m moving into a bit of a more “don’t track me” frame of mind.

When

  • Now, because I’m home more during corona-virus.

How

  • Set up local server.
  • First on a Linux laptop that (usually) does not go off the net.
  • Then maybe on an old pogoplug or laptop.

Install It

Here’s what I did to instlal

[ ] basic install
On a Linux server, the basic install issimple:
 sudo bash basic-install.sh
[ ] Static IP
But you will want a Linux box with a static IPaddress. This may involve, e.g., convincing your wirelessrouter to hand out a the same static IP to a static IP
[ ] Tell other systems to use this IP for DNS
Again,probably configuring your wireless router to specify your localIP as the DNS server for DNS assignments via DHCP assignments.You could also do this by configuring the individual devices touse it.
[ ] Remember your admin password
Make note of the admin password during install
[ ] hit the local admin web server
Its a very nice. It willbe at a something like http://192.168.86.230/admin/index.php.

Test It

[ ] Look something up by hand
Use dig(1) or host(1). Notethe SERVER in the response below that shows where the answercame from. If it’s your IPS’s DNS or Google, try again(something’s not configured right). In my case 127.1 is right.
$ dig www.uu.net; <<>> DiG 9.11.3-1ubuntu1.11-Ubuntu <<>> www.uu.net;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54721;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1;; OPT PSEUDOSECTION:; EDNS: version: 0, flags:; udp: 512;; QUESTION SECTION:;www.uu.net.INA;; ANSWER SECTION:www.uu.net.299INCNAMEglobal.mci.com.global.mci.com.959INCNAMEwac.C449.edgecastcdn.net.wac.C449.edgecastcdn.net. 3599INCNAMEgp1.wac.v2cdn.net.gp1.wac.v2cdn.net.3599INA152.195.32.39;; Query time: 59 msec;; SERVER: 127.0.0.1#53(127.0.0.1);; WHEN: Fri May 01 19:16:11 EDT 2020;; MSG SIZE rcvd: 146
  • Check the query logs via the UI to make sure your target domainshowed. Be aware of caching. It may only show up the firsttime you query.

  • Find your favorite 90s-era web site,go hit it, and watch the counters

  • If the counters go crazy and you don’t see the expectedplethora of ads, you win. If not dig deeper.

  • If you are alreadyusing ad-blockers or browsers such as Brave that block ads, youmay have to test with something else (Firefox, Chrome, etc.)

  • Browser and other apps are getting cagey about using not usingthe system DNS, using DOH, and otherwise not acting like youexpect them too. Editing /etc/resolv.conf is not the wholegame anymore.

dig
for making/testing queries by hand
Wireshark
Use Wireshark to see what’s going on on the wire,who you’re talking to, etc.

The things you learn

  • pi-hole can apparently function as a DHCP server itself.

  • You can choose your upstream DNS servers from a list withoptions for IPv4, IPv6, DNSSEC/no DNSSEC, filtered/unfiltered.

  • Quad9 is one of the choices. It looks to be really useful foradding malware blocking to your domain. Seehttps://www.quad9.net/faq/ for a useful bit of education.

  • The logs are at /var/log/pihole.log

  • Possibly use Marcus Ranums’s principal of “Artificial Ignorance”to grep out the known and see what’s left:

     $ cat pihole.log.1 | egrep -v microsoft.com\|google\|amazon\|in-addr\|linkedin\|dropbox\|facebook\|messenger\|ubuntu\|github\|brave\|basicattention\|yahoo\|disqus\|twitter\|akamai\ | sed 's/.*: //' | sort | uniq -c | sort -rn | head 334 reply min-api.cryptocompare.com is <CNAME> 334 reply ccc-api.cloudapp.net is 40.115.22.134 334 query[A] min-api.cryptocompare.com from 127.0.0.1 238 forwarded min-api.cryptocompare.com to 8.8.4.4 143 cached min-api.cryptocompare.com is <CNAME> 101 query[A] no-thanks.invalid.lan from 127.0.0.1 101 query[A] no-thanks.invalid from 127.0.0.1 101 forwarded min-api.cryptocompare.com to 8.8.8.8 100 reply hfq2h9152m63.statuspage.io is <CNAME> 100 query[A] rpt.cedexis.com from 127.0.0.1
     $ cat pihole.log.1 | egrep -v microsoft.com\|google\|amazon\|in-addr\|linkedin\|dropbox\|facebook\|messenger\|ubuntu\|github\|brave\|basicattention\|yahoo\|disqus\|twitter\|akamai\|compuserve\|aol | sed 's/.*: //' | sort | uniq -c | sort -rn | tail -20 1 cached imap.gmail.com is 2607:f8b0:400d:c0f::6d 1 cached imap.gmail.com is 2607:f8b0:400d:c07::6d 1 cached imap.gmail.com is 2607:f8b0:400d:c00::6d 1 cached imap.gmail.com is 2607:f8b0:4004:c08::6d 1 cached imap.gmail.com is 2607:f8b0:4004:c08::6c 1 cached imap.gmail.com is 172.253.63.109 1 cached imap.gmail.com is 172.253.63.108 1 cached hosts-file.net is 3.234.198.254 1 cached encrypted-tbn0.gstatic.com is 172.217.13.78 1 cached dig is NXDOMAIN 1 cached content-signature-2.cdn.mozilla.net is <CNAME> 1 cached beacons-handoff.gcp.gvt2.com is 172.217.15.99 1 cached beacons.gvt2.com is 172.217.13.227 1 cached beacons.gcp.gvt2.com is <CNAME> 1 cached beacons4.gvt2.com is 216.239.32.116 1 cached beacons2.gvt2.com is 216.239.38.117 1 cached beacons2.gvt2.com is 216.239.36.117 1 cached beacons2.gvt2.com is 216.239.34.117 1 cached beacons2.gvt2.com is 216.239.32.117 1 cached article.smartasset.com is <CNAME>

    What is this stuff?

Tune it

I’m not sure all the devices in the house are using the P-holeproxy. If they are, then they are showing up as the singledevice _gateway. I need to understand this and figure out if Ican get other devices pulling wireless addresses via DHCP fromthe WAP to use the Pi-hole DNS directly. Stay tuned.

POST INCOMPLETE FROM HERE

Migrate

Burn in

Inflict it on others

HOWTO: Using Pi-hole DNS to block ads.  The struggle continues… (2024)

FAQs

Why am I still getting ads with Pi-hole? ›

With a domain blocker such as Pi-hole, you cannot block these ads without blocking the content. The client is using a DNS server other than Pi-hole. This could be due to a setting on the client, use of a VPN service from the client, a router providing an IPv6 DNS server, etc.

How does Pi-hole block ads? ›

Most DNS servers work by translating a URL into an IP address. Pi-hole does that and more. It waits until your computer or device requests a URL for an ad, and then returns no address for that ad. That effectively stops ads from being displayed.

Why use Pi-hole as DNS? ›

The nature of Pi-hole allows it to also block website domains in general by manually adding the domain name to a blocklist. Likewise, domains can be manually added to an allowlist should a website's function be impaired by domains being blocked.

Can Pi-hole block smart tv ads? ›

Network-level blocking allows you to block ads in non-traditional places such as mobile apps and smart TVs, regardless of hardware or OS.

Why is Pi-hole not blocking ads on Facebook? ›

Make sure that all devices on your network are using Pi-Hole as their DNS server. To check this, go to the network settings on each device and make sure that Pi-Hole's IP address is set as the DNS server. If devices are using a different DNS server, Pi-Hole won't be able to block ads.

What are the drawbacks of Pi-hole? ›

One of the main drawbacks of Pi-hole is that it can sometimes block legitimate or useful domains, such as online banking, streaming services, or software updates. This can cause some websites or applications to malfunction or break.

Can DNS block ads? ›

By setting up Private DNS on your Android device with an adblock DNS service, you can enjoy a cleaner, more streamlined browsing experience. Not only does this method help block ads, but it also enhances your privacy and security by preventing your ISP from tracking your browsing activity.

Does Pi-hole block pop ups? ›

Pi-hole is a DNS resolver which either blocks a requested domain or resolves the requested domain to an IP address. It sees none of the subsequent content that loads from the website you are visiting. To block these popups, you will need software on your browser which can inspect the html content.

What port is Pi-hole on? ›

If you want 'pi. hole/admin to resolve', you have to stick to port 80.

Should I enable DHCP on Pi-hole? ›

Why should I use Pi-hole's DHCP? By using Pi-hole's DHCP, you allow Pi-hole to give its dns configuration to each of your clients. This way, every request will be filtered by Pi-hole.

How to set up DNS Pi-hole? ›

All you have to do is change the suggested server in your router's settings, and your entire network should start using your Pi-hole for DNS. Look for a setting called DNS in your router's admin interface. You may be able to find the setting in a section called "Internet", "DHCP", "Internet Connection", or "DDNS".

How to use Pi-hole for local DNS? ›

If you don't already have Pi-Hole setup, you will need install Pi-Hole first. Once Pi-Hole is setup, head over to the local DNS settings under DNS Records at /admin/dns_records. php . Here you can enter a local domain name that will point to a local IP of your choice.

Why am I still getting ads with a VPN? ›

Our Verdict. VPN services do not block ads by default, but some VPNs include ad blockers designed to stop annoying ads and block trackers. However, based on our testing, even the best VPN ad blockers do not block 100% of ads.

How do I stop hidden ads? ›

To stop website ads and pop-ups, open Android settings, tap Apps, then choose the browser you want to customize permissions for. Tap Permissions, then select Notifications. Toggle off to block notification permissions for the Android browser.

Does Pi-hole block pop-ups? ›

Pi-hole is a DNS resolver which either blocks a requested domain or resolves the requested domain to an IP address. It sees none of the subsequent content that loads from the website you are visiting. To block these popups, you will need software on your browser which can inspect the html content.

Top Articles
Latest Posts
Article information

Author: Nathanael Baumbach

Last Updated:

Views: 6485

Rating: 4.4 / 5 (75 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Nathanael Baumbach

Birthday: 1998-12-02

Address: Apt. 829 751 Glover View, West Orlando, IN 22436

Phone: +901025288581

Job: Internal IT Coordinator

Hobby: Gunsmithing, Motor sports, Flying, Skiing, Hooping, Lego building, Ice skating

Introduction: My name is Nathanael Baumbach, I am a fantastic, nice, victorious, brave, healthy, cute, glorious person who loves writing and wants to share my knowledge and understanding with you.