Blame
|
1 | # Ubuntu Host Preparation for Pi-hole (Port 53 Conflict Fix) |
||||||
| 2 | ||||||||
| 3 | ## 1. The Issue: Port 53 Conflict |
|||||||
| 4 | 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. |
|||||||
| 5 | ||||||||
| 6 | ## 2. The Fix: Steps to Release Port 53 |
|||||||
| 7 | ||||||||
| 8 | ### Step 1: Disable the DNS Stub Listener |
|||||||
| 9 | 1. Open the resolved configuration file: |
|||||||
|
10 | ```bash |
||||||
| 11 | sudo nano /etc/systemd/resolved.conf |
|||||||
|
12 | ``` |
||||||
| 13 | 2. Locate the line `#DNSStubListener=yes`. |
|||||||
| 14 | 3. Change it to: |
|||||||
| 15 | ```ini |
|||||||
| 16 | DNSStubListener=no |
|||||||
| 17 | ``` |
|||||||
| 18 | 4. Save and exit (`Ctrl+O`, `Enter`, `Ctrl+X`). |
|||||||
| 19 | ||||||||
| 20 | ### Step 2: Fix Local DNS Resolution |
|||||||
| 21 | ||||||||
| 22 | 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. |
|||||||
| 23 | ||||||||
| 24 | 1. Remove the existing symlink: |
|||||||
| 25 | ```bash |
|||||||
| 26 | sudo rm /etc/resolv.conf |
|||||||
| 27 | ||||||||
| 28 | ``` |
|||||||
| 29 | ||||||||
| 30 | ||||||||
| 31 | 2. Create a new symlink to the actual resolv file: |
|||||||
| 32 | ```bash |
|||||||
| 33 | sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf |
|||||||
| 34 | ||||||||
| 35 | ``` |
|||||||
| 36 | ||||||||
| 37 | ### Step 3: Reload and Restart Services |
|||||||
| 38 | ||||||||
| 39 | Apply the changes and reload the daemon to clear any configuration warnings. |
|||||||
| 40 | ||||||||
| 41 | ```bash |
|||||||
| 42 | sudo systemctl daemon-reload |
|||||||
| 43 | sudo systemctl restart systemd-resolved |
|||||||
| 44 | ||||||||
| 45 | ``` |
|||||||
| 46 | ||||||||
| 47 | ### Verification |
|||||||
| 48 | ||||||||
| 49 | Check if Port 53 is free (output should be empty or not show `systemd-resolved`): |
|||||||
| 50 | ||||||||
| 51 | ```bash |
|||||||
| 52 | sudo lsof -i :53 |
|||||||
| 53 | ``` |
|||||||
