Skip to content

Instantly share code, notes, and snippets.

@vbop9834
Last active November 18, 2020 23:21
Show Gist options
  • Save vbop9834/6f585070501d962c36f5db8c524d9864 to your computer and use it in GitHub Desktop.
Save vbop9834/6f585070501d962c36f5db8c524d9864 to your computer and use it in GitHub Desktop.

Shoving ads up the Pi-Hole

First steps

The Raspberry Pi Zero W has a micro sd card (2GB) plugged in with the headless operating system raspbian(linux distro)

Raspberry Pi Zero Specs https://www.raspberrypi.org/pi-zero-w/

The power adapter plugs into the USB C port that is the farthest from the center of the board.

The other USB C port can be used for power and data.

Wifi setup

Remove the micro sd card and open the contents on the computer.

Create the file "wpa_supplicant.conf"

Edit and save the text below NOTE!!! The pi zero w can only connect to 2.4ghz networks.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<Insert 2 letter ISO 3166-1 country code here>

network={
 ssid="<Name of your wireless LAN>"
 psk="<Password for your wireless LAN>"
}

https://www.raspberrypi.org/documentation/configuration/wireless/headless.md

Safely eject the sd card and boot the pi.

The light on the pi will flash as it boots.

Remote Access

There are multiple ways to access the pi. See https://www.raspberrypi.org/documentation/remote-access/

My preferred method is SSH (I enabled it already by creating an empty file named ssh) https://www.raspberrypi.org/documentation/remote-access/ssh/README.md

SSH

I recommend using Putty https://www.putty.org/

use the hostname raspberrypi

login as pi

password is password

I recommend changing the password

After connecting use the command passwd

Raspi-config (Optional)

Run raspi-config

Open a ssh session run the command sudo raspi-config

navigate using the arrows and enter

Recommended steps

Update
Network Options

Unbound

I highly recommend reading the documentation https://docs.pi-hole.net/guides/unbound/

Important steps

Install

Command sudo apt install unbound

Configure

https://docs.pi-hole.net/guides/unbound/#configure-unbound

Start

sudo service unbound restart

Validate

dig pi-hole.net @127.0.0.1 -p 5335

Pi-Hole

https://pi-hole.net/

Install

Run the command and follow the prompts. Default options are ok except for the DNS (see DNS section below) curl -sSL https://install.pi-hole.net | bash https://github.com/pi-hole/pi-hole/#one-step-automated-install

DNS

Select custom

Insert 127.0.0.1#5335

https://docs.pi-hole.net/guides/unbound/#configure-pi-hole

Change Admin Password

https://discourse.pi-hole.net/t/how-do-i-set-or-reset-the-web-interface-password/1328

Run the command pihole -a -p

Configure the Router

I recommend using method 1 on the site below https://discourse.pi-hole.net/t/how-do-i-configure-my-devices-to-use-pi-hole-as-their-dns-server/245

Accessing the pi hole

UI

goto http://pihole/admin if that doesn't work then try http://raspberrypi/admin

(This can be changed. Look up raspbian hostname)

Add Block Lists

Goto http://pihole/admin/gravity.php (http://raspberrypi/admin/gravity.php)

Here are some sources for lists

https://firebog.net/

Update Lists

I prefer the command line for this

Follow the instructions to install this (see the command copied below) https://github.com/jacklul/pihole-updatelists

Install command wget -O - https://raw.githubusercontent.com/jacklul/pihole-updatelists/master/install.sh | sudo bash

Run the commmand pihole-updatelists --update && pihole-updatelists

OPTIONAL Update Alias

To make things simpler to maintain we can add an alias to the .bashrc file located in the user directory

Install Vim sudo apt-get install vim

Then run vim ~/.bashrc

Here's a quick rundown on how to use Vim https://coderwall.com/p/adv71w/basic-vim-commands-for-getting-started https://www.fosslinux.com/41731/a-beginners-guide-to-vim.htm

Press i to enter into Insert Mode

copy and paste the following line at the top of the file (the && symbol executes the following command after the other command completes successfully)

alias update="sudo apt-get update && sudo apt-get upgrade -y && sudo pihole-updatelists --update && sudo pihole-updatelists"

Press Escape to enter into Command Mode Type :wq and press enter (: is for command. w is for write/save. q is for quit)

After Vim closes exit the shell by typing exit

Reconnect

Run the new alias update

Useful commands

NOTE the command sudo gives root powers use with caution

sudo apt-get update

updates the package cache

sudo apt-get upgrade

upgrades packages

df

disk space

sudo apt-get clean

Cleans the package cache

sudo apt-get autoremove -y

cleans up unused dependencies

Ideas

Custom pi case

https://blog.protoneer.co.nz/raspberry-pi-zero-footprint-dimensions/

Dimensions : 65 mm by 30 mm
4 mounting holes for M2.5 screws.
Mini-HDMI
Two Micro USB ports – One OTG USB and One Power USB.
One Micro SD card reader.
Raspberry Pi Zero Mounting holes : 58mm x 23mm

Add heat sink for heat mitigation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment