Skip to content

Instantly share code, notes, and snippets.

@AjkayAlan
Last active March 20, 2022 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AjkayAlan/7d462b6e04f11e144ec787a6b2cd25dd to your computer and use it in GitHub Desktop.
Save AjkayAlan/7d462b6e04f11e144ec787a6b2cd25dd to your computer and use it in GitHub Desktop.

Prework

  1. Format your SD Card with FAT32 if <= 32GB, otherwise use exFAT
  2. Go to https://www.raspberrypi.org/downloads/raspberry-pi-os/ and the lite image, then unzip it
  3. Download https://www.balena.io/etcher/ and install it
  4. Use Etcher to write the downloaded image to the SD card
  5. Create a blank file named ssh into the boot partition to enable ssh with headless
  6. Put the SD card into your Raspberry Pi, plug it into ethernet, and power it on

SSH

Check your router to see what IP the Raspberry PI was assigned - the hostname should be something like raspberrypi. Then, SSH into it. See the docs at https://www.raspberrypi.org/documentation/linux/usage/users.md#:~:text=User%20management%20in%20Raspberry%20Pi,and%20change%20each%20user's%20password. for the default user and pass.

Change The Default Pass

First things first, change the default password using passwd

Update Everything

sudo apt update
sudo apt full-upgrade

Static IP

Add the following to /etc/dhcpcd.conf (Note that this assumes your router is on 192.168.1.1 and you are installing pihole):

interface eth0
static ip_address=192.168.1.5/24
static routers=192.168.1.1
# static domain_name_servers=127.0.0.1
static domain_name_servers=192.168.1.1
static ip6_address=2604:2d80:4a90:8e01:6725:3263:ee41:ddff

Then, reboot your pi - sudo reboot. When it comes back online, it should be ssh'd to via the static ip you defined above.

Raspberry Config

Config your Pi based on some preferences you have, using:

sudo raspi-config

Important settings include your localization options including locale and timezone

Installing & Configuring PiHole

Run the installer:

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

Follow through the prompts. Copy the password provided at the end of the install. Lets change the password:

sudo pihole -a -p

After the installer finishes, log into the web ui. Mine is located at http://192.168.1.5/admin/index.php. Click login, and get yourself familiar with the interface.

I use Cloudflare for DNS, but one thing is the installer only enables IPv4, so I am going enable IPv6 as well by going to Settings -> DNS, and selecting the IPv6 unchecked options for Cloudflare.

Also, add some good blocklists. I recommend using https://github.com/jessedp/pihole5-list-tool, as it works well. To do so:

sudo apt-get install python3-pip
sudo pip3 install pihole5-list-tool --upgrade
sudo pihole5-list-tool

Switch Your Router To Use PiHole

This is different for every setup, but essentially you need to switch your router to use your pihole for DNS.

Installing A Unifi Controller

Follow https://community.ui.com/questions/Step-By-Step-Tutorial-Guide-Raspberry-Pi-with-UniFi-Controller-and-Pi-hole-from-scratch-headless/e8a24143-bfb8-4a61-973d-0b55320101dc.

After the install finishes, open the UI on port 8443 of your pi. Mine is https://192.168.1.5/8443.

Ntop

You can also install ntopng to forward data to your router. Install via https://packages.ntop.org/

Then follow https://www.ntop.org/ntopng/how-to-analyse-mikrotik-traffic-using-ntopng/

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