Raspberry Pi

How to set up Pi-hole on Raspberry Pi

Many ads on your browser or device screen will be too annoying, especially when someone is working on an important task and there requires an ad blocker that will stop these ads from popping out on your system screen. However, installing an Adblocker for each platform will require manual laboring and searching for a well-compatible Adblocker will also be time-consuming.

This tutorial guides you by setting up a perfect Adblocker on your Raspberry Pi device named Pi-hole, a general-purpose network AdBlocker that runs on your Raspberry Pi device and blocks the ads that appear on your screen.

How to setup Pi-hole on Raspberry Pi

Pi-hole is an excellent lightweight AdBlocker that can run on your Raspberry Pi device and performs adblocking without requiring it to be set up on each device. To install it on your Raspberry Pi device, use the steps given below.

Step 1: If you recently setup your Raspberry Pi device, you should first ensure that the git server is installed and if it’s not then you can install them using the following command-line.

$ sudo apt install git

Step 2: Now, you will need to install Pi-hole from the git repositories by executing the below given script in the command-line terminal.

$ git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole

Step 3: Next, you will need to create a directory through the following script.

$ cd "Pi-hole/automated install/"

Step 4: In the current directory, you will require to run the below script to perform the installation steps.

$ sudo bash basic-install.sh

Step 5: Choose to go with the “OK” option to allow the installer to transform your device into a network-wide ad blocker.

Step 6: Move to the next step by choosing the “OK” option.

Step 7: In this step, we are going to use a static IP address because we will set the DNS server later on. Click on the “Yes” option to set.

Step 8: Select “wlan0” option for WiFi by pressing the space button from your keyboard. If your Raspberry Pi has access to the Internet using the ethernet cable then you should select the “eth0” option and press Enter..

Step 9: Press the Enter button by choosing the option “Set static IP using current values” in the next screen.

Step 10: Press the Enter button again.

Step 11: Select any DNS provider according to your choice or you can simply go with Google DNS similar to our case..

Step 12: Choose the selected option again by pressing the Enter button.

Step 13: Install the web admin interface by choosing the “On” option.

Step 14: Go with the recommended option again in this step as well.

Step 15: Select the recommended option again in this step.

Step 16: Choose your privacy level according to your choice.

Once the above steps are performed, it will take some time to set up the installation process.

Step 17: In the final step press the enter button from the keyboard to complete the installation process.

Step 18: If you want to change your Admin Web Page login password, you can do this through the below mentioned command.

$ pihole -a -p <yourpassword>

Step 19: Now, reboot your device and once it restarts, go to your browser tab and enter the address

Step 20: Log in with your password.

Now if you want to use Pi-hole technology on your PC, you will need to go to your WIFI router settings and replace the DNS address with your Raspberry Pi address. Once you do it successfully, you can then surf the ad-free browsing on your PC.

In our case we test the ads by visiting the website “speedtest.net” before and after setting the DNS address.

The below image is taken before setting the DNS address on the router.

The next image is taken after performing the above steps and you will see that there are no ads appearing this time.

You can go on and visit other websites as well. You can also check the ads-block percentage by going into the Pi-hole dashboard:

That’s it now your Raspberry Pi turns itself into an Ad-blocker and you can enjoy Ad-free browsing.


If you spend most of your time surfing the web, you will surely not like the ads appearing on your browser’s screen and you have definitely tried every solution. If you fail to find the right option to block the ads, you should give Pi-hole a try which is fairly easy to set up on your Raspberry Pi device and provides you the opportunity to surf the ad-free internet on your other devices as well. The only thing required for you is to replace the DNS address of the router so that other devices can easily access the Pi-hole server.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.