idk pihole

Test PiHole in VM before implementing on system. Test with localhost, avoiding screwing up your network.

By logderman | foreverhereintheEther | 16 Jun 2024


Pihole allows you to block network wide DNS queries belonging to ad providers. This will not block ads like an ad blocker extension because those ads are delivered by the site you are on, such as this site. But with pihole, if you click on the ad, it will block your ability to visit the ad site. Both pihole and ublock origin together would be the ultimate ad blocking experience.

Your mobile phone may be connecting to ad servers due to apps you have installed, but pihole would block it if the ad servers are on the block list. Also your internet of things devices. TVs are now able to serve you ads, but not if they are blocked by pihole.

Places like youtube.com serve the ads from their server. So pihole is ineffective at blocking those ads.

There may be a tutorial for testing pihole in a VM using localhost, but I spent 16 plus hours trying to find one and could not. Here is how you do it.

First you need to set up a debian machine in a vm such as virtualbox. I used this one:

https://downloads.raspberrypi.com/rpd_x86/images/rpd_x86-2022-07-04/2022-07-01-raspios-bullseye-i386.iso

This is 32-bit.

To set this up, there are tutorials out there for the vm installation. I am covering the pihole set up. If you guys want a tutorial on how to install the VM, post in the comments and I can explain it.

After setting up the VM, you need to change your network settings to use a static ip address.

In the terminal type: ip route #get the default gateway which is what will be acting as a router (your host os). In VBox its usually 10.0.2.2. This is an abstraction which links to your host os routing. This route will not be found on the host OS, its just the way vbox allows the VM to communicate with the host OS.

You will also see your VMs ip address such as 10.0.2.15.

In the terminal type: sudo nano /etc/dhcpcd.conf

At the bottom of the page add:

interface eth0
static ip_address=10.0.2.15/24
static routers=10.0.2.2 #the default gateway (host os)
static domain_name_servers=1.1.1.1 #google's dns (dont worry it will change)

Save the file (ctrl + x then "y")

Terminal type: sudo nano /etc/resov.conf

Ensure these are in the file:

nameserver 1.1.1.1 #google

nameserver 208.67.220.220 #opendns

Terminal type: sudo apt update && sudo apt upgrade -y #updates your system

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

Wait a minute.

The following prompts will appear and for each one do the following:

1) This installer will transform your device into a network-wide ad blocker!

> OK

2) Donation message

> OK

3) Pi-hole is a server so it needs a static ip address to function properly

>This is what we did earlier. You must do it or it will mess up.

>OK

4) Do you want to use your current network settings as a static address?

> No, set static ip using custom values

5) Enter your desired IPV4 address:

IPv4 Address: change to 127.0.0.1

IPV4 Gateway: double check its the same as the default gateway (vbox 10.0.2.2).

6) Are these settings correct?

> Yes

7) Select Upstream DNS provider.

> Choose OpenDNS. This is where the pihole requests DNS. The only way to not use these is to set up something else which is much more complicated however the keyword is Unbound if you choose to go that route. Keep in mind ultimately even Unbound eventually ends up using Google or other authoritative servers. The authoritative DNS providers own the internet.

8) Pi-hole relies on third party lists in order to block ads.

> Yes #this is your domain blocking list

9) Do you want to install the Admin Web Interface

> Yes. #You dont need it but its nice to look at the network traffic in a gui

10) A web server is required for the Admin Web Interface.

> Yes

11) Would you like to enable query logging?

> Yes

12) Select privacy mode for FTL.

> 0 Show everything

13) Configure your devices to use Pi-hole as their DNS server using:

> write down the login password to 127.0.0.1/admin.

> Go to browser: 127.0.0.1/admin

> Type in your password and login

> click OK in the terminal

--------------------------------

Now go back to the file and change it to this at the bottom of the page. Delete your old stuff we added earlier.

sudo nano /etc/dhcpcd.conf

interface eth0
static ip_address=10.0.2.15/24
static routers=10.0.2.2 #the default gateway (host os)
static domain_name_servers=127.0.0.1 #the only real change

Save and exit.

Now:

sudo nano /etc/resov.conf

Delete the old nameserver lines and add:

nameserver 127.0.0.1

Save and exit.

Terminal type: sudo reboot

It reboots.

Go to browser. Turn off Ublock Origin (for testing purposes).

Go to youtube.com.

Click on a video.

You will see an ad (served through youtube.com). But if you click on it, the domain will be blocked. This may be more effective for protecting against malware from scummy ad domains.

Congrats.

This is a specific use case that I have not found anything about it on the internet. Setting up for network wide implementation is different. This is just so you can play around and test the capabilities in a safe and controlled environment without changing router settings and what not.

 

 

https://www.publish0x.com?a=3YaOPqMLbx

How do you rate this article?

3

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.