Pihole Setup

Prepare SD Card

Raspi OS Configuration

$ sudo sed -i -e 's/^en_GB.UTF-8/# en_GB.UTF-8/' \
              -e 's/^# en_US.UTF-8/en_US.UTF-8/' \
              /etc/locale.gen
$ sudo locale-gen
$ sudo timedatectl set-timezone America/New_York
$ sudo -i -e 's/^#.*interface eth0/interface eth0/' \
             's/^#.*static ip_address.*/static ip_address=<ip>\/<cidr>/' \
             's/^#.*static routers.*/static routers=<gw ip>/' \
             's/^#.*static domain_name_servers.*/static domain_name_servers=<dns 1>, <dns 2>/' \
             /etc/dhcpcd.conf
$ sudo adduser <username>
$ sudo adduser <username> sudo
$ logout
$ sudo userdel -r pi
$ sudo sed -i -e "s/$(hostname)/<hostname>/" /etc/hosts
$ sudo hostnamectl set-hostname <hostname>
$ sudo reboot

Pihole Configuration

Install pihole

$ wget -O install.sh install.pi-hole.net
$ bash install.sh

Use the following settings:

Select Upstream DNS Provider: <router IP>
Web settings:
  Settings->DNS->Advanced DNS
      Uncheck Never forward non-FQDNs
      Uncheck Never forward reverse lookups for private IP ranges

Change web admin password

$ pihole -a p <password>

Add DNS Entries

$ echo "<fqdn> <ip>" >> /etc/pihole/custom.list
$ pihole restartdns reload
$ echo "cname=<alias fqdn>,<fqdn> >> /etc/dnsmasq.d/05-pihole-custom-cname.conf
$ pihole restartdns