VM Config
VM Specifications:
- CPU: 1vCPU (2 cores)
- RAM: 2 GB
- HD: 100 GB
Change the hostname:
Update the IP:
Install
Update the system
Install the bits
Firewall Changes
IPv6 is disabled in the template.
UFW is enabled in the template with a default policy to deny incoming, allow outgoing, and allow ssh.
Add firewall rules:
Restart UFW.
Show the policies in a numbered order.
Pi Hole Config
To log into the web interface, go to:
http://ph01.domain.local/admin
http://ph02.domain.local/admin
Change the default web interface password.
You have to log into the web interface first. Otherwise, the command below will clear the password. If you didn't read this, log into the web interface with the blank password, then use the command below to set a new pwd.
Enter the command and then you will be prompted twice for the login. Use this method in order to avoid having the password remain in the bash history.
Update block list (Gravity)
To customize themes and contacts:
DNS Setup
Background:
There are really two options on where to place Pihole:
OPTION 1: client > adDNS > pihole (internet forwardwers)
OPTION 2: client > pihole > adDNS (internet forwardwers)
OPTION 1
OPTION 1 is the preferred method as it is the simplest, easiest, but the downside is that you loose the logging on a per client basis. All logs would show which AD DNS server was taking care of the request instead of the client itself.
During the setup wizard, you can select a public DNS server or select custom. Verify the following settings:
In the Pihole Web Interface:
- Select a Public DNS provider (Quad9 (filtered, DNSSEC))
- Verify - Upstream DNS servers Custom 1-4 are NOT checked.
- Verify - "Conditional forwarding" is NOT checked.
OPTION 2
This would provide the client logging but in a lot of testing, the config is very kludgy. There are a lot of forums on the topic, but most of it is hobbists with odd setups.
If blocking is going to be required, it does not matter who requests the content so long as the target is controlled. Although, if per client logging is required, OPTION 2 is going to be required. OPTION 2, can be setup in two different ways (as described below).
During the setup wziard, you can select a public DNS server or select custom. We are using Active Directory for DHCP and DNS, so we want to set the upstream to be custom. Thare two differnt options here.
OPTION 2A
In the Pihole Web Interface:
- Verify - Public DNS servers are NOT checked.
- Settings > DNS > Upstream DNS Servers
- Custom1 (IPv4): 192.168.30.100
- Custom2 (IPv4): 192.168.30.101
- Verify - "Conditional forwarding" is NOT checked.
OPTION 2B
Option 2B is preferred method (over 2A).
The problem with OPTION 2B is that there is only one text box for a single subnet. We have more than that.
In the Pihole Web Interface:
- Verify - Public DNS servers are NOT checked.
- Verify - Upstream DNS servers Custom 1-4 are NOT checked.
- "Conditional forwarding" should be checked.
- Local network in CIDR notation: 192.168.30.0/24
- IP address of your DHCP server: 192.168.30.100
- Local domain name: domain.local
Additional Information
The active settings from the web interface are stored in: /etc/dnsmasq.d/01-pihole.conf. This file is over written every time their is a upgrade. So we have to create our own extra config file that will stay after updates.
Make sure to restart the service.
Verify that it restarted ok.
To verify the syntanx:
Whichever option you pick for the Pihole DNS setup, update the Active Directory DNS servers DNS forwarders.
- Open the DNS server MMC for the Windows DNS server.
- Right click the DNS Server you would like to udpate.
- Select Properties.Open the Edit Forwarders window
- Select the Forwarders tab.
- click Edit.
- Make the appriate udpates based on OPTION X.
- Repeat these steps for each Windows AD DNS server.
Local DNS Fixes
If you are using OPTION 1, you will need to modify the local hosts config as the DNS resolver cannot find the Active Directory DNS servers.
Verify the change.
Certificate Creation
Certificate creation is out of the scope of this document.
When settting the Subject Name and Alternate names, make sure to add the second Pi-Hole host to the setup in the same certifciate.
Certificate Install
This section was taken from the domain join guide.
Pihole requires the certs to be in a "base-64 encoded x.509 (.pem)" format. The *.pem is required. Disregard the note below about the *.crt extension. They are effectively the same content just a different file extension.
The PEM format is the most common format used for certificates. Extensions used for PEM certificates are: cer, crt, and pem. They are Base64 encoded ASCII files that contain human readable content between --BEGIN CERTIFICATE-- and --END CERTIFICATE--. The DER format is the binary form of the certificate. DER formatted certificates do not contain the "BEGIN CERTIFICATE/END CERTIFICATE" statements. DER formatted certificates most often use the '.der' extension.
The certs should have already been converted from the a "base-64 encoded x.509 (.cer)" Windows encoding to a Unix encoding. If this has not already happened:
Run the following OpenSSL commands:
Combine the files (if needed):
Combine the intermediate cert in to the root CA.
Combine the private key in to the system cert.
Download the certs to the local system.
In the respective distro cert install commands, adding a combined chain would be redundant. So we only use the root and intermediate, not cert chain.
Create directory to store the certs.
Move the certs to their proper home.
Sercure the certs.
Update the Lighttpd config to see the certs and to redirect from http to https.
The active settings from the web interface are stored in: /etc/lighttpd/lighttpd.conf. This file is over written every time their is a upgrade. So we have to create our own extra config file that will stay after updates.
ph02 ONLY
Update the external config from ph01 to ph02.
Verify the changes.
Verify the syntax of the changes to the config file before restarting Lighttpd service.
Restart Lighttpd
DNS over TLS (DoT)
!!! DO NOT USE !!!
See the "Summary - Description" above.
DNS over HTTPS (DoH)
!!! DO NOT USE !!!
See the "Summary - Description" above.
Download the latest bits.
Install the deb package.
Point the app to a public DoH provider.
Create a local service account for the service.
- -s specifies shell account to allow.
- -r is a system account.
- -M is to NOT create a home dir.
Change the user password
Configure the app to start
Make sure that the new cloudflared user has access to the config files.
Enable and then start the cloudflared service.
Configure Pihole to now use the app.
If you want to use Cloud flare, you could add it to as another "Upstream DNS Servers" Custom: 127.0.0.1#5053
In the Pihole Web Interface:
- Verify - Public DNS servers are NOT checked.
- Settings > DNS > Upstream DNS Servers
- Custom1 (IPv4): 127.0.0.1#5054
- Verify - "Conditional forwarding" is NOT checked.
Never a bad idea for a reboot.
Troubleshooting
To backup config through web interface
References
Install
- https://github.com/pi-hole/pi-hole/#one-step-automated-install
- https://docs.pi-hole.net/main/prerequisites/
- https://docs.pi-hole.net/ftldns/dns-resolver/
DNS forwarding
Cert Install
- https://www.mattbattison.dev/2019/10/17/my-pi-hole-set-up.html
- https://discourse.pi-hole.net/t/enabling-https-for-your-pi-hole-web-interface/5771
- https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_SSL#Configuration
Additional lighttpd documenation
- https://cheapsslsecurity.com/blog/how-to-install-ssl-certificate-on-lighttpd-server/
- https://tecadmin.net/configure-ssl-in-lighttpd-server/
DNS over HTTPS
- https://docs.pi-hole.net/guides/dns/cloudflared/
- https://www.reddit.com/r/pihole/comments/aoezvx/how_to_install_pihole_with_dns_over_https_cloud/
- https://www.quad9.net/news/blog/doh-with-quad9-dns-servers/
- https://www.quad9.net/support/faq/#doh
DNS over LTS
- https://www.quad9.net/support/faq/#dns_tls
- https://dnsprivacy.org/dns_privacy_clients/#browsers
- https://bartonbytes.com/posts/configure-pi-hole-for-dns-over-tls/
- https://gist.github.com/Jiab77/1cdc2896f22791c4db492e87bbf609ff
- https://blog.svarun.dev/configure-pi-hole-with-dns-over-tls-private-dns
- https://discourse.pi-hole.net/t/implement-dns-over-tls-capability-in-pi-hole/8722/2
- https://www.reddit.com/r/pihole/comments/cbvx5e/dns_over_tls_over_tor_for_the_pi_hole_setup_guide/