← Back to list

Pi-Hole — As a life saving AdBlocker

Have you ever found yourself frustrated with ads constantly popping up while browsing websites or using applications? You know the kind —…

Sajan K · 2025-02-22 06:02 · 0 claps · 4.2 min read
#pihole #linux #networking
Open on Medium ↗
Wiki topics: PFI · Personal Finance 🔓 · Open Source

Pi-hole — A Life-Saving AdBlocker

Have you ever found yourself frustrated with ads constantly popping up while browsing websites or using applications? You know the kind — you search for something on Amazon, like a pair of shoes, add it to your cart, and then suddenly, ads for those exact shoes follow you around wherever you go on the internet. Or you check flight prices, and soon after, every website you visit offers you “exclusive flight deals” to the same destination.

If you’re anything like me, you’ve probably accidentally clicked on one of these ads at some point, only to regret it immediately. Well, I’ve found a life-saving solution: Pi-hole.

What is Pi-hole?

Pi-hole is a network-wide ad blocker that acts as a DNS sinkhole. In simple terms, it intercepts and blocks requests to domains that serve ads, trackers, and other unwanted content. Instead of loading these pesky items, Pi-hole returns a blank response, effectively eliminating ads from your browsing experience.

Originally designed to run on a Raspberry Pi (hence the name), Pi-hole can now be installed on a variety of devices, including Linux-based systems, Docker containers, and even cloud-based virtual machines. It works on several supported operating systems, which you can check out here: Pi-hole Supported OS. This flexibility makes Pi-hole perfect for both tech enthusiasts and non-technical users.

My Pi-hole Setup Experience

For my setup, I decided to repurpose an old laptop running Ubuntu 24.04.1 LTS as my Pi-hole server. I began by checking the current network settings on my machine. Here’s what I found

# cat /etc/netplan/50-cloud-init.yaml-bk 
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets: {}
    version: 2
    wifis:
        wlo1:
            access-points:
                MY-WIFI-NAME:
                    password: MY_WIFI_PASSWORD
            dhcp4: true

As you can see, the dhcp4: true setting means that the Wi-Fi network assigns an IP to the laptop dynamically, but I wanted to set a static IP to ensure it doesn't change every time I reboot the router.

Checking the Current IP Range

Running ifconfig revealed that my laptop's IP address was 192.168.1.8 in the 192.168.1.0/24 subnet.

# ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 164  bytes 11792 (11.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 164  bytes 11792 (11.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlo1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.8  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::5a00:e3ff:fe8f:a299  prefixlen 64  scopeid 0x20<link>
        ether 58:00:e3:8f:a2:99  txqueuelen 1000  (Ethernet)
        RX packets 11027  bytes 938949 (938.9 KB)
        RX errors 0  dropped 183  overruns 0  frame 0
        TX packets 5497  bytes 742012 (742.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

I decided to assign my laptop the static IP 192.168.1.8.

Setting a Static IP

I edited the /etc/netplan/50-cloud-init.yaml file as follows to ensure my laptop always gets the same IP:

# cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets: {}
    version: 2
    wifis:
        wlo1:
            access-points:
                MY-WIFI-NAME:
                    password: MY_WIFI_PASSWORD
            dhcp4: false
            addresses:
                - 192.168.1.8/24 
            routes:
                - to: default
                  via: 192.168.1.1 
            nameservers:
                addresses:
                    - 8.8.8.8 

After applying the changes using netplan apply, my laptop was assigned the static IP of 192.168.1.8 permanently.

Pi-hole Installation

Now, it was time to install Pi-hole. I’m a huge fan of Docker, so I used Docker to deploy Pi-hole on my system. I ran the following command to install Pi-hole:

docker run -d --name pihole -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -e TZ=Asia/Kolkata -e FTLCONF_webserver_api_password="giveanadminpassword" -e FTLCONF_dns_listeningMode=all -v /etc/pihole:/etc/pihole -v /etc/dnsmasq.d:/etc/dnsmasq.d --cap-add NET_ADMIN --restart unless-stopped pihole/pihole:latest

After the installation, I could access the Pi-hole admin interface by visiting http://192.168.1.8/admin.

How Does Pi-hole Work?

Every time you visit a website, your device needs to look up the domain name (like “example.com”) and convert it into an IP address (like “192.0.2.1”) to establish a connection. DNS servers handle this process.

Pi-hole functions as your network’s DNS server. When a request for a domain is made, Pi-hole checks if the domain is listed in its blacklist (which contains known ad-serving domains). If the domain is on the list, Pi-hole “blocks” it, and your device won’t load the ads or trackers associated with that domain. This process happens seamlessly for all devices connected to your network, giving you a clean, ad-free experience without the need to install individual ad-blocking software on every device.

Configuring Devices to Use Pi-hole as DNS server

If you have access to your router, you can configure it to point all connected devices to your Pi-hole as the DNS server. The steps may vary depending on your router model, so consult your router’s manual for specific instructions.

If you don’t have access to the router, you will need to configure each device individually to use Pi-hole as the DNS server. Below are the steps for various operating systems:

For Android Devices:

  1. Go to Network & Internet > Wi-Fi.
  2. Long press on your current network and select Modify Network.
  3. Change IP settings to Static.
  4. In the DNS 1 field, enter 192.168.1.8 (leave DNS 2 blank).
  5. Save the settings.

For Windows:

  1. Open Control Panel > Network and Internet > Network and Sharing Center.
  2. Click on Change adapter settings.
  3. Right-click on your active network connection and choose Properties.
  4. Select Internet Protocol Version 4 (TCP/IPv4) and click Properties.
  5. Choose Use the following DNS server addresses and enter 192.168.1.8.
  6. Click OK and restart Windows.

For Linux:

  1. Open the /etc/resolv.conf file and update the nameserver entry to 192.168.1.8.

Final Thoughts

Setting up Pi-hole was one of the best decisions I made for improving my online experience. It blocks all those irritating ads and trackers across all devices on my home network, and the best part is it requires minimal setup. Whether you’re a tech enthusiast or just someone looking for a smoother, more private internet experience, Pi-hole is the perfect solution.

Ready to reclaim your internet? Head over to Pi-hole’s official website and get started today!


메타데이터
post_id
5fa9c4a0fda2
slug
pi-hole-as-a-life-saving-adblocker-5fa9c4a0fda2
url
https://medium.com/@sajanpth/pi-hole-as-a-life-saving-adblocker-5fa9c4a0fda2
canonical_url
https://medium.com/@sajanpth/pi-hole-as-a-life-saving-adblocker-5fa9c4a0fda2
author_url
https://medium.com/@sajanpth
status
ok
fetched_at
2026-06-27 18:20:27