GO திசைGoDisai

Story 10 · Pi-hole

The Television That Would Not Stop Shouting

“If every device in the house asks the same one question before it does anything, the best place to answer it is the house itself.”

20 min read · by Syed Jafer K

1. Forty Seconds of Soap

Meenakshi lived in a second-floor flat in Madurai with her husband Arvind, their daughter Kavya, and Arvind's mother. The family had one fibre connection, one router and a great many screens. There were two phones, two laptops, a tablet for Kavya's school work, a smart television, and a small speaker that played devotional songs every morning.

The trouble began with the television. Arvind's mother liked to watch an old serial in the evening, and in the middle of every episode the screen was taken over by an advertisement for a soap. It was forty seconds long and it could not be skipped. The same soap, the same jingle, three times in an hour.

"I will pay for the serial," Arvind's mother said. "I will not pay again to be shouted at."

Meenakshi had other worries. The tablet had a game that showed a full screen advertisement after every level, and Kavya's eight year old patience ended exactly where the level did. The laptop browser had a blocker, but the television did not, the speaker did not, and the tablet game did not. Blockers live inside one browser. Most of the house did not run one.

Her cousin Bharath, who worked at a small hosting company, listened to all this on a video call. "You are trying to fix ten devices," he said. "Fix the one thing they all share."

"The router?"

"Nearly. Something just before it. A small server that answers one question for the whole house. Its name is Pi-hole."


2. What Pi-hole Is

Pi-hole is a network wide ad and tracker blocker. You install it once on a small machine in your home, you tell your router to use it, and every device on the network is protected. That includes the ones that cannot run an extension, such as the television, the speaker and the game on the tablet.

It is free and open source, and the project asks supporters for donations to keep it going. It does not need powerful hardware. The documentation asks for about half a gigabyte of memory and a few gigabytes of disk, so an old Raspberry Pi, a spare laptop, a small virtual machine or a NAS box will all do.

Question Answer
What does it do Blocks the lookups that lead to ads and trackers, for every device on the network
Where does it run A Raspberry Pi, an old PC, a virtual machine, a NAS, or a Docker container
What does it need About 512 MB of memory and 2 to 4 GB of disk, a static address, and a supported Linux
Do the devices need software No, they only need to use Pi-hole as their DNS server
What does it cost Nothing, apart from the machine and its electricity
Does it work on mobile data Only if you add a VPN back to home, a point we come to near the end

A word on the name. The Pi in the name comes from the Raspberry Pi, where it began. Today it runs on plenty of other machines. The hole is where unwanted traffic goes to disappear.


3. The One Idea You Need First, DNS

Bharath drew it on a paper napkin during the call, and Meenakshi kept the napkin.

Computers talk to each other by number, but people remember names. When a phone opens news.example.com, it first asks a DNS server, "What number is this name?" The server replies with an address, and only then does the phone connect.

Ads work the same way. A web page asks for its own pictures from its own server, and it asks for the advertisement from a different name, something like ads.adnetwork.example. That is a separate lookup. And a separate lookup can be answered differently.

Pi-hole sits in the middle and keeps a long list of names that belong to ad networks and trackers. When a device asks for a name on the list, Pi-hole does not answer with the real address. It answers with nothing useful. The device tries to load the advertisement from nowhere, fails in a few milliseconds, and the page simply carries on without it.

phone      "Where is news.example.com?"        Pi-hole      not on a list, so it asks upstream and passes the real answer back
phone      "Where is ads.adnetwork.example?"   Pi-hole      on a list, so it returns a blank answer, and nothing is downloaded

This is why the television and the tablet game get fixed too. They also have to look names up. They never knew that anyone was listening.

Two things follow from this and Bharath said both out loud.

  • Pi-hole blocks names, not individual advertisements. It cannot remove a banner that is served from the same name as the page itself.
  • Pi-hole does not watch your pictures, your passwords or your messages. It sees only the questions, which is exactly the part it needs to see.

4. A Home for It

Pi-hole must be switched on whenever the family wants the internet. If its machine is off, the house has no name lookups and nothing opens. That one fact decides where it should live.

Meenakshi had an old laptop in a cupboard, with a cracked hinge but a perfectly good battery and disk. Arvind found a spare network cable. The laptop would sit on the shelf beside the router, lid closed, and never be touched.

Bharath told her to do three things before the install.

  1. Install a supported Linux. The documentation lists Debian, Ubuntu, Raspberry Pi OS, Fedora, CentOS Stream, Alpine and Armbian, as long as they are actively maintained versions. She chose Ubuntu Server.
  2. Give the machine a fixed address. Pi-hole needs one, because the whole house will be told to look for it there. The cleanest way is a DHCP reservation in the router, which tells the router to always hand the same address to this machine. She reserved 192.168.1.10.
  3. Use a cable. A wired connection is more dependable than Wi-Fi for the one machine everything else depends on.

Keep the machine boring. Do not use this laptop for anything else. The more a machine does, the more chances there are for it to be switched off on a busy evening.


5. The Install

The project provides a one line installer.

curl -sSL https://install.pi-hole.net | bash

Bharath did not love that line, and the project itself says plainly that piping to bash is a debated practice. He asked her to read the script before running it, which is easy because it is only text.

git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole
cd "Pi-hole/automated install/"
sudo bash basic-install.sh

The installer is a text screen with a few questions. In order, it asks which network connection to use, which upstream DNS provider Pi-hole should ask for names it does not block, whether to include a starter blocklist, and whether to switch on query logging. Meenakshi accepted the starter blocklist, picked an upstream provider from the list and kept the logging on for now.

The upstream provider matters more than it looks. Pi-hole blocks names but it still has to find the real addresses for everything else, and whoever answers those questions sees every site the house visits. Bharath said it is a trust choice, and that Pi-hole lets her change it at any time in the settings. She noted it and moved on.

When the installer finished, it printed the address of the admin page and a way to set the password. In the current version the web interface is built into Pi-hole itself, so there is no separate web server to install. If you ever need to set or change the admin password, run this.

sudo pihole setpassword

She opened a browser on her phone and visited http://192.168.1.10/admin. A dashboard appeared, with a total of zero queries and a green status.

If the page does not open. Pi-hole's web interface uses ports 80 and 443. If another web server on the machine already holds them, Pi-hole moves to 8080 and 8443, and the address changes to match. The installer tells you which one it picked.


6. Making the House Use It

A dashboard with zero queries means nothing is using it yet. This step is where most people stop and wonder why it does not work. Installing Pi-hole is not enough. Each device has to be told to ask it.

There are three ways, and Bharath listed them from best to worst.

Way How Good for
Change the router's DHCP settings Tell the router to give Pi-hole's address as the DNS server to every device that joins Almost everyone, because it covers the whole house with one change
Use Pi-hole as the DHCP server Switch off the router's DHCP and let Pi-hole hand out addresses Routers that will not let you change the DNS server
Set each device by hand Type Pi-hole's address into each device's network settings One or two special devices only

Meenakshi's router had a field for the local DNS server in its home network settings. She typed 192.168.1.10 there and saved.

Devices pick the new setting up when they renew their address, so the change is not instant. The simplest way to speed it up is to turn the Wi-Fi off and on again on each device. Within a few minutes the dashboard woke up. The counter climbed from zero to ten, then to hundreds.

There is a second way to use the router, and it is worth knowing why Bharath warned her away from it. The router can use Pi-hole as its own upstream resolver instead of handing out Pi-hole's address. That works, but then Pi-hole sees every question as coming from the router, so the dashboard shows one client and nothing else. Per device views and per device rules stop working. Distribute the address through DHCP instead.

Never point Pi-hole back at the router and the router back at Pi-hole. Each will pass the question to the other forever. This is a DNS loop. Pi-hole's upstream must be a real outside resolver.


7. The First Evening of Quiet

At seven o'clock Arvind's mother sat down with her serial. Meenakshi watched from the kitchen door.

The first episode began. The soap advertisement did not appear. There was a short moment where the television seemed to wait for something, then it simply went on with the story.

"They have stopped sending the soap," said Arvind's mother, satisfied.

Meenakshi laughed and went to look at the dashboard. The numbers explained it.

  • Total queries. Every name lookup from every device in the last day.
  • Queries blocked. How many were refused because they were on a list, and the share of the total.
  • Top blocked domains. The ad and tracker names asked for most often.
  • Top clients. Which device asks the most questions.

The television was the loudest client in the house, and a good part of its questions were to names it had no business contacting. The speaker was also asking a strange number of questions at three in the morning, which became a conversation for another day.

"What is it doing at three in the morning?" she asked Bharath.

"Asking for the weather, most likely. Or telling someone it is still alive. You will never know which, unless you look at the query log. That is the whole point of having one."


8. Blocklists, and Why Bigger Is Not Better

Pi-hole is only as good as the lists it follows. A blocklist is a plain text file of names, published by someone who keeps it up to date. Pi-hole downloads the lists you choose and merges them into one database it calls gravity.

You add a list in the admin page, under the lists section, by pasting its web address. Then you update gravity so the new names are downloaded and applied.

pihole -g

By default Pi-hole refreshes gravity on its own once a week, so you rarely need this by hand.

On the first Saturday Meenakshi did what most beginners do. She found a website with fifty lists and added all of them. By Sunday the dashboard said that a third of all queries were blocked, and she felt very pleased. By Monday Kavya's school portal would not open.

The cause was a list that was too aggressive. It had blocked a name that the school's learning platform needed for its login. This is the cost of a huge blocklist. The more names you block, the more likely it is that one of them is something you need.

Bharath gave her a simple rule.

  • Start with the default list. Live with it for two weeks.
  • Add one list at a time, and only a well known one from a maintainer who explains what the list is for.
  • Watch the query log after each change, so you can tell what each list is really doing.
  • Keep a short list of exceptions. When something breaks, you allow the name, you do not delete the whole list.

9. When Something Breaks, the Allow List

The school portal was a good lesson because the fix is quick once you know where to look.

  1. Reload the broken page, so that its lookups are fresh.
  2. Open the query log in the admin page and find the lines in red, which are the blocked ones, from Kavya's tablet.
  3. Find the name that belongs to the school or its login service. This is the part that takes some thought, because a page often uses several names.
  4. Choose Allow next to that line.

The page worked on the next reload. The allow list is separate from the blocklists and it wins over them, so you can keep a large list and still make careful holes in it.

She added two more exceptions over the next month. One was a name her bank's app used for reading its own statements. The other was an offer link from a shop that Arvind actually wanted to open. She wrote each one in a small notebook with the date, so she would remember why it was there.

There is also the opposite action. If you notice a name that you want blocked and the lists do not know about it, you can add it to the deny list yourself. And for patterns, Pi-hole accepts regular expressions, so a single rule can cover a family of names.

Not every advertisement can be stopped this way. A video service that serves its adverts from the same name as the video cannot be blocked without blocking the video. Some television apps and some streaming sites work this way. Pi-hole is honest about this. It is a tool for names, and it is not magic.


10. Different Rules for Different People

After a month Meenakshi wanted something Pi-hole could do and her browser blocker never could. Kavya's tablet needed stricter rules than the adults' phones. The tablet should block adult sites and the game networks, while the laptops should only block ads.

Pi-hole calls this groups. You put a device in a group, and you attach lists to the group. The default group follows the default lists, and you can make a second group, say Kids, with its own extra lists.

For this to work Pi-hole must see each device as itself. This is why, in section 6, the router needed to hand out Pi-hole's address through DHCP and not use it only as an upstream. A device whose questions arrive from the router is invisible to groups.

The other side of that is hostnames. By default Pi-hole's dashboard shows devices by address, such as 192.168.1.34, which is hard to read. Pi-hole can ask the router for the names behind those addresses, and many routers answer. When the names appear, the dashboard stops saying 192.168.1.34 and starts saying Kavya tablet, which is far more useful.


11. What Pi-hole Remembers, and Who Can See It

Meenakshi was not entirely comfortable at first. If Pi-hole logs every name every device asks for, then the cupboard laptop holds a diary of the family's days.

That is true, and it is worth thinking about on purpose. Pi-hole gives you control over it.

Privacy setting What it keeps
Show everything Both the device and the name asked for, the most detail
Hide the domains The device, but not what it asked for
Hide the domains and the clients Only counts, with no names at all
Anonymous mode Statistics only, and the query log is disabled

Pi-hole also trims old entries on its own. By default it keeps the query history for a limited number of days, and you can change that in the settings.

The family agreed to a middle path. The log stays on, the admin page is protected by a password, and Arvind and Meenakshi are the only people who know it. Meenakshi told Kavya, kindly, that she could see the names her tablet asked for. Kavya shrugged and said she would stop asking for the game.

Keep the admin page inside the house. It is made for the home network. Do not forward ports on your router to reach it from outside. If you need to see it away from home, use a VPN.


12. When Pi-hole Itself Is Down

This is the chapter's hardest lesson, and it arrived on an ordinary Tuesday.

A power cut in the building ended with the router coming up before the cupboard laptop did. For about four minutes nothing in the house could open any website. Phones said "no internet" even though the fibre light was green.

Arvind was convinced that the fibre line had failed. It had not. The line was fine. The one thing that answered names was still starting.

This is the price of putting the whole house behind one machine. It is a single point of failure, so it needs a little respect.

  • Set two DNS servers in the router if you can. Put Pi-hole first and a normal outside resolver second. Some devices will use the second one at random, so blocking becomes patchy, but the internet always works. Many families choose this for the first month, while they get used to the setup.
  • Run two Pi-holes if the house depends on it, one on a spare Raspberry Pi and one on a laptop, with the same lists. They do not need to talk to each other.
  • Make the machine start by itself after a power cut. Most laptops and mini PCs have a setting in the firmware to power on when electricity returns.
  • Know the rescue. If the Pi-hole machine fails, set the router's DNS back to the router's own setting, and the house comes back in a minute. Write this on a sticky note and stick it to the router.

The note on the router, in Meenakshi's handwriting, reads, Internet not working? Check the cupboard laptop first. If dead, delete 192.168.1.10 from DNS.


13. Keeping It Healthy

Pi-hole asks for very little. A small routine is enough.

pihole status         # is the DNS service running
pihole -g             # refresh the blocklists now
pihole -up            # update Pi-hole to the latest release
pihole tcpdump        # watch queries as they arrive, handy when debugging

The exact commands can differ a little between versions, so check pihole help on your own machine.

Besides those commands, Meenakshi followed four habits.

  • Update the operating system and Pi-hole every month or two. Pi-hole handles the traffic of every device in the house, so it deserves the same care as the router.
  • Use Teleporter before big changes. This is the backup and restore feature in the settings. It saves the lists, groups, exceptions and settings into one file. She keeps the file in her own cloud storage.
  • Review the exceptions notebook every few months. Some are no longer needed.
  • Keep the machine cool and dusty free. A closed laptop in a cupboard heats up faster than you might expect.

For those who prefer containers, Pi-hole also ships an official Docker image, which keeps the install tidy and makes it easy to move to another machine. The idea is the same. Run it on a machine that is always on, give it a fixed address, and point the router at it.


14. Taking It on the Road

Pi-hole protects devices that use the home network. The moment Meenakshi walked out of the flat, her phone was on mobile data and the protection stopped.

The fix is a small VPN that connects the phone back to the house. When the phone is away, it sends its questions through the tunnel to Pi-hole at home, and the advertisements disappear in the market as well as in the kitchen. The Pi-hole project describes pairing it with WireGuard for this reason.

It takes some care to set up. The home router must allow one carefully chosen incoming connection, and the VPN must be kept updated like any other server. Bharath told her not to rush into this. For the first months the home setup was already enough, and she could revisit mobile data when she had learned to trust the system.

The honest tradeoff. A VPN to home exposes one port to the internet. That is a small risk if you keep the software current, and a large one if you forget. Do it only when you are ready to maintain it.


15. Small Habits That Keep It Safe

  • Give Pi-hole a fixed address. A moving address is the quickest way to break the whole house.
  • Read the installer before you run it when you can. It is text, and it takes ten minutes.
  • Start with the default blocklist and add others one at a time.
  • Write down every exception, with the date and the reason.
  • Do not expose the admin page to the internet.
  • Keep a plain backup of the settings with Teleporter.
  • Tell the family it exists. When something fails to load, the first question should be "is it Pi-hole?" and not "is the internet down?"

16. Epilogue: The Quiet Evening

Six weeks later the whole family sat in the front room. The television played the serial. The soap advertisement had never come back. Kavya was on the tablet and no longer begged for a game that interrupted her. Arvind's mother had stopped mentioning the soap, which in that house counted as the highest praise.

Meenakshi sat with her phone and looked at the dashboard for old times' sake. The blocked share had settled at around one in five queries. It was not the dramatic number from her first Saturday, and it was much more honest, because every blocked name now belonged there.

She had learned a few things. Pi-hole had not made the internet quiet by shouting louder than the advertisements. It had simply declined, politely and from the cupboard, to ask for them.

On her last call with Bharath she said, "It is strange. All it does is refuse to answer a question."

"That is often the strongest thing a server can do," said Bharath. "Now tell me, since the whole house goes through that laptop, who has the key to it?"

She looked at the cupboard. The door did not even close properly.

"I will fix the door," she said.


Quick Reference Cheat-Sheet

I want to... Do this
Install Pi-hole Run the installer on a supported Linux with a fixed address
Open the dashboard Go to http://<pi-hole address>/admin
Set the admin password sudo pihole setpassword
Protect the whole house Give Pi-hole's address as the DNS server in the router's DHCP settings
See each device separately Hand out the address through DHCP and do not use Pi-hole only as the router's upstream
Add a blocklist Paste its address under lists in the admin page, then run pihole -g
Fix a page that broke Find the red line in the query log and choose Allow
Give children stricter rules Put their devices in a group with extra lists
Back up the settings Use Teleporter in the settings
Update pihole -up
Rescue a dead Pi-hole Remove its address from the router's DNS and the house returns

Key takeaways

  1. Pi-hole answers name lookups for the whole network and refuses the names of ad and tracker servers, so even a television gets protected.
  2. Installing is half the job. Each device must be told to ask Pi-hole, and the best place to do that is the router's DHCP settings.
  3. It blocks names, not advertisements. Ads served from the same name as the content cannot be removed this way.
  4. More blocklists are not better. Add them one at a time and keep an allow list for the exceptions.
  5. Groups need per device visibility, so distribute Pi-hole through DHCP.
  6. It is a single point of failure. Plan for a power cut with a second DNS server, a second Pi-hole or a note on the router.
  7. Keep the admin page inside the house and decide on purpose what the log remembers.

Self-hosting is not always about running the thing people see. Sometimes it is a quiet little machine in a cupboard, declining to answer questions that nobody should have asked.