Helpless Automation

Application Development

How to setup DHCP on the PiHole with a TP-Link Router

My set up is:

  • PiHole running BookWorm OS
  • TP-Link Router Archer AXE5400

I also had issues running DHCP from the PiHole using a TP-Link router. The problem is that if you reserve an IP for your PiHole, like 192.168.0.2, in the router but then turn off DHCP, the PiHole will not get assigned to 192.168.0.2 because reservations need DHCP running on the TP-Link router for the assignment to work.

One way of solving this is to set the DHCP IP address pool on the router from 192.168.0.2 to 192.168.0.2 while keeping the DHCP on. This will essentially only lease IP to the router and nothing else. Then, turn on DHCP on the PiHole. That should work.

I ended up setting a static IP on the PiHole to 192.168.1.2. Then you can turn off DHCP on the router and turn it on in the PiHole, and walla, everything seems to be working. I also disabled the WiFi on the PiHole because it’s hard to connect to the router. I am using BookWork OS on the PiHole.

Remember to restart your modem, router, and PiHole. I noticed issues if the devices were not restarted.

Here is a post I wrote on how to set a static IP on the PiHole that has BookWork OS:
https://www.helplessautomation.com/set-static-ip-with-pi-hole-dns-on-raspberry-pi/

For both solutions above, remember to set the router’s primary and secondary DNS servers to point to the PiHole IP.

I hope this helps. Let me know if anyone has any questions.

HLC

Set Static IP with Pi-hole DNS on Raspberry Pi

Set Static IP with Pi-hole DNS on Raspberry Pi (Bookworm)

These instructions guide you through setting a static IP address (192.168.1.2) on a Raspberry Pi running Bookworm OS using nmtui, with the Pi configured to use itself as the DNS server for Pi-hole.

Prerequisites

  • Raspberry Pi OS Bookworm is installed.
  • You have terminal access (via SSH or directly).
  • NetworkManager is installed (default in Bookworm).
  • Pi-hole is installed and will use 192.168.1.2 as its address.
  • You router will use 192.168.1.1 as its address.

Steps to Configure

  1. Open the Terminal

    Log in to your Raspberry Pi and open a terminal.

  2. Launch nmtui

    Run this command:

    sudo nmtui
  3. Navigate to “Edit a Connection”

    Use arrow keys to select “Edit a connection” and press Enter.

  4. Select Your Network

    Highlight your connection (e.g., Wired connection 1 for Ethernet or your Wi-Fi name) and press Enter.

  5. Configure IPv4 Settings

    Scroll to “IPv4 CONFIGURATION”, change from Automatic to Manual, and press Enter.

  6. Set Static IP and DNS
    • Addresses: Enter 192.168.1.2/24 (subnet mask 255.255.255.0).
    • Gateway: Enter your router’s IP (e.g., 192.168.1.1).
    • DNS servers: Enter 192.168.1.2 (the Pi’s own IP for Pi-hole).
  7. Save the Configuration

    Scroll to “OK” and press Enter, then Esc to return to the main menu.

  8. Exit nmtui

    Select “Quit” and press Enter.

  9. Restart the Network

    Apply changes with:

    sudo systemctl restart NetworkManager

    Or reboot:

    sudo reboot
  10. Verify the Static IP

    Check with:

    ip addr

    Ensure 192.168.1.2 is assigned to your interface (e.g., eth0 or wlan0).

Example Configuration

  • Static IP: 192.168.1.2/24
  • Gateway: 192.168.1.1
  • DNS: 192.168.1.2 (Pi-hole)
Notes:
  • Adjust the gateway to match your network’s router IP.
  • Ensure no other device uses 192.168.1.2 to avoid conflicts.
  • If Pi-hole isn’t working, verify it’s running (sudo systemctl status pihole-FTL).
  • If nmtui isn’t available, install it with: sudo apt install network-manager.

Updated: March 02, 2025 | Powered by xAI

Raspberry Pi OS with Pi-Hole Installation





 

Raspberry Pi with Pi-Hole Setup Instructions

I recently upgraded my Pi-Hole OS from Buster (v10) to Bookworm (v12). Even though I did this a few years back, it is hard to remember the steps needed to accomplish the goal. Especially for those that are more versed in Windows OS than Linux type OS. This time I decided to document the procedure.

1. SD Card Setup

Updates the system and configures basic settings on the SD card.

sudo apt update && sudo apt full-upgrade -y
sudo raspi-config  # Timezone, SSH, expand filesystem
sudo reboot

2. Fix SSH

Removes old SSH key from Windows to reconnect after reinstall.

ssh-keygen -R 192.168.1.4  # On Windows, adjust IP

3. Overclock (Fix Flickering)

Boosts CPU/GPU speeds to fix screen flicker, later optimized.

sudo nano /boot/firmware/config.txt
# Initial: over_voltage=6, arm_freq=2100, gpu_freq=750
# Optimized: over_voltage=4, arm_freq=1800, gpu_freq=750
sudo reboot

4. USB SSD Boot

Enables SSD booting and clones SD card to SSD for faster performance.

sudo rpi-eeprom-update -a && sudo reboot
lsblk  # Verified your source and target drive addresses: SD=/dev/mmcblk0, SSD=/dev/sda
sudo dd if=/dev/mmcblk0 of=/dev/sda bs=4M status=progress && sudo sync
sudo shutdown -h now
sudo raspi-config  # Expand filesystem on SSD
sudo reboot

5. Swap File Tweaks

Adjusts virtual memory: removed, then set to 1GB, later 512MB.

sudo swapoff -a          # Turn off all active swap spaces
sudo systemctl stop dphys-swapfile  # Stop the swap management service
sudo apt remove dphys-swapfile      # Uninstall the swap service
sudo rm /var/swap        # Remove the swap file (optional)
free -h                  # Verify swap is 0B (no reboot needed)
# Later: CONF_SWAPSIZE=1024
sudo apt install -y dphys-swapfile
sudo nano /etc/dphys-swapfile  # CONF_SWAPSIZE=1024
sudo systemctl start dphys-swapfile
# Later: CONF_SWAPSIZE=512
sudo systemctl stop dphys-swapfile 
sudo nano /etc/dphys-swapfile  # CONF_SWAPSIZE=512
sudo systemctl start dphys-swapfile

6. Enable RDP

Installs xrdp for remote desktop access from Windows.

sudo apt install -y xrdp
sudo systemctl enable xrdp && sudo systemctl start xrdp
sudo reboot

7. Install Pi-Hole

Sets up Pi-Hole as a network-wide ad blocker and DNS server.

sudo apt update
curl -sSL https://install.pi-hole.net | bash  # Follow installer prompts
sudo pihole -a -p  # Set admin password


That is it, let me know if you have any questions. HLC.