Ubuntu Host Preparation for Pi-hole (Port 53 Conflict Fix)

# Ubuntu Host Preparation for Pi-hole (Port 53 Conflict Fix)

## 1. The Issue: Port 53 Conflict
By default, Ubuntu runs `systemd-resolved`, which acts as a local DNS stub listener on **Port 53**. Pi-hole also requires Port 53 to function as a DNS server. If `systemd-resolved` is not modified, the Pi-hole container will fail to start with an "address already in use" error.

## 2. The Fix: Steps to Release Port 53

### Step 1: Disable the DNS Stub Listener
1. Open the resolved configuration file:
   ```bash
   sudo nano /etc/systemd/resolved.conf
  1. Locate the line #DNSStubListener=yes.
  2. Change it to:
DNSStubListener=no
  1. Save and exit (Ctrl+O, Enter, Ctrl+X).

Step 2: Fix Local DNS Resolution

Since the stub listener is disabled, the default 127.0.0.53 DNS entry will no longer work. Point the system to the upstream DNS file instead so the host maintains internet connectivity.

  1. Remove the existing symlink:
sudo rm /etc/resolv.conf
  1. Create a new symlink to the actual resolv file:
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

Step 3: Reload and Restart Services

Apply the changes and reload the daemon to clear any configuration warnings.

sudo systemctl daemon-reload
sudo systemctl restart systemd-resolved

Verification

Check if Port 53 is free (output should be empty or not show systemd-resolved):

sudo lsof -i :53
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9