Used Model: Raspberry Pi (Model B Rev 2, armv6l)
Download the Raspberry Pi Imager,
start it and follow the instructions to create an image using the
Raspberry Pi OS Lite (32-bit)
(a debian port without desktop environment).
- User:
pi
- Password:
raspberry
sudo raspi-config
- set timezone and keyboard
- enable ssh server
- set hostname to
pi-hole
- whatever else fits your needs...
Afterwards, everything else can be done via ssh.
ssh <USERNAME>@<PI-IP>
sudo adduser <USERNAME>
sudo usermod -a -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,gpio,i2c,spi <USERNAME>
Afterwards, you can login with your new user account and remove the pi
user and its home directory:
sudo pkill -u pi
sudo deluser -remove-home pi
sudo visudo
Edit the line for the sudoers group:
%sudo ALL=(ALL:ALL) NOPASSWD:ALL
Copy your ssh id from your local machine to the pi:
ssh-copy-id -i ~/.ssh/id_rsa.pub <USERNAME>@<PI-IP>
You can also add an entry to your local .ssh/config
for convenient connect:
Host pi-hole
HostName <PI-IP>
User <USERNAME>
IdentityFile ~/.ssh/id_rsa
Afterwards, you can connect via ssh pi-hole
.
sudo apt-get update
sudo apt-get upgrade
curl -sSL https://install.pi-hole.net | bash
# change or remove pihole password
pihole -a -p
# install
sudo apt-get install ufw
# reboot afterwards
sudo shutdown -r now
# deny all incoming traffic
sudo ufw default deny incoming
# allow ssh from local network
sudo ufw allow from 192.168.0.0/24 to any app OpenSSH
# limit ssh connections
sudo ufw limit ssh/tcp
# allow http from local network
sudo ufw allow from 192.168.0.0/24 to any app WWW
# allow dns for pi hole
sudo ufw allow 53/tcp
sudo ufw allow 53/udp
sudo ufw allow 67/tcp
sudo ufw allow 67/udp
sudo ufw allow 546:547/udp
# enable firewall (WARNING: misconfiguration may lock you out!)
sudo ufw enable
sudo ufw status verbose
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get clean