From charlesreid1

Line 6: Line 6:


PiHole acts as a DNS server for Bespin, listening on port 53 by default. This complicates things for us:
PiHole acts as a DNS server for Bespin, listening on port 53 by default. This complicates things for us:
* We already set up dnsmasq to run as a DNS and DHCP server for the wireless AP hotspot
* We already set up dnsmasq to run as a DNS and DHCP server for the wireless AP hotspot
* If we hadn't set up dnsmasq, Ubuntu already has a built-in DNS server (systemd-resolvd) running on port 53 (see [[Ubuntu/Bespin]] for instructions to disable)
* If we hadn't set up dnsmasq, Ubuntu already has a built-in DNS server (systemd-resolvd) running on port 53 (see [[Ubuntu/Bespin]] for instructions to disable)


How to resolve this? We are going to run the PiHole on a non-standard port (5353), and keep using dnsmasq on port 53. But we will change dnsmasq so that it uses the PiHole DNS server as an upstream (recursive) DNS server (i.e., if dnsmasq receives a request for an entity like "github.com" and does not find it in <code>/etc/hosts</code>, it will pass the request along to the upstream DNS server.
===PiHole on Non-Standard Port===
 
We are using dnsmasq as DNS for the wifi AP - dnsmasq handles requests from clients on the AP.
 
The dnsmasq server passes along DNS requests it doesn't know how to resolve. We define the upstream DNS servers that dnsmasq uses. Instead of using 1.1.1.1 or 8.8.8.8, we can point to the PiHole DNS server.
 
Now, if a client on the AP requests "github.com", the request will go to dnsmasq. dnsmasq will not find it in <code>/etc/hosts</code> so it will pass the request on to the upstream DNS server - the PiHole. The PiHole checks whether the request should be filtered, and whether it can answer the request. If not, it forwards the request on to another DNS server.


If we do this with dnsmasq and the PiHole in a chain, we can get all the benefits of the PiHole DNS sinkhole, while still using dnsmasq and not modifying our existing, working setup too much.
In other words, the PiHole sits between the system DNS server and external DNS servers and acts as a kind of DNS proxy.


==Install Stuff==
==Install Stuff==

Revision as of 23:02, 7 July 2020

Running PiHole via Docker on Ubuntu 18.04

Notes on Networking and Ports

PiHole acts as a DNS server for Bespin, listening on port 53 by default. This complicates things for us:

  • We already set up dnsmasq to run as a DNS and DHCP server for the wireless AP hotspot
  • If we hadn't set up dnsmasq, Ubuntu already has a built-in DNS server (systemd-resolvd) running on port 53 (see Ubuntu/Bespin for instructions to disable)

PiHole on Non-Standard Port

We are using dnsmasq as DNS for the wifi AP - dnsmasq handles requests from clients on the AP.

The dnsmasq server passes along DNS requests it doesn't know how to resolve. We define the upstream DNS servers that dnsmasq uses. Instead of using 1.1.1.1 or 8.8.8.8, we can point to the PiHole DNS server.

Now, if a client on the AP requests "github.com", the request will go to dnsmasq. dnsmasq will not find it in /etc/hosts so it will pass the request on to the upstream DNS server - the PiHole. The PiHole checks whether the request should be filtered, and whether it can answer the request. If not, it forwards the request on to another DNS server.

In other words, the PiHole sits between the system DNS server and external DNS servers and acts as a kind of DNS proxy.

Install Stuff

Docker

Thanks to the Ansible step covered on the Ubuntu/Bespin page, Docker is already installed on Bespin.

$ which docker
/usr/bin/docker

$ which docker-compose
/usr/local/bin/docker-compose

PiHole Docker Image

Pull the latest pihole docker image:

docker pull pihole/pihole:latest

Create Docker Compose File