Skip to content

Instantly share code, notes, and snippets.

@MortezaJavadian
Last active September 17, 2025 09:37
Show Gist options
  • Select an option

  • Save MortezaJavadian/fd1e6967126089a419ee3eb493a82f0e to your computer and use it in GitHub Desktop.

Select an option

Save MortezaJavadian/fd1e6967126089a419ee3eb493a82f0e to your computer and use it in GitHub Desktop.
A complete Pi-hole guide, from installation to setup. This document explains Pi-hole features, how to install it, configure DNS and DHCP, and manage your network with advanced blocking and filtering.

Pi-hole & Network Manager

It acts as a DNS server. When you try to visit a website, your device asks the Pi-hole for the address. If the address is a known in Pi-hole, Pi-hole filter the request as you want.

Pi-hole Features

  • Custom DNS Servers:
    You can tell Pi-hole to use any DNS provider you want, instead of just public ones like Google. like use Shecan DNS to access restricted content or services for your entire network.

  • Local DNS Records:
    Assign easy-to-remember names to devices IP address on your local network.

  • Group Management:
    Apply different blocking or filtering rules to different device groups on your network.

  • Advanced Blocklists (with Regex):
    Manually block (blacklist) or allow (whitelist) specific domains. You can use Regular Expressions (Regex) to block entire patterns of domains with a single rule like block domains with "ads" in name.

  • Dashboard:
    Pi-hole have a good Dashboard that you can see stats about your network.

  • Query Log:
    See a real-time log of every single DNS request made by every device on your network.

Installation & Setup

Dependencies

  1. Install an OS:
    Use a lightweight Linux OS like Debian or Raspberry Pi OS.
  2. Give it a Static IP:
    Your Pi-hole server needs a permanent address.

Installation Command

  1. Run One Command:
    The complete installer handles everything.

    curl -sSL [https://install.pi-hole.net](https://install.pi-hole.net) | bash
  2. Follow the Installer:
    The installer is a simple step-by-step guide. It will ask you to:

    • Confirm your Static IP.
    • Choose an "upstream" DNS provider (like Google or Cloudflare).
    • Accept the default blocklists.
    • Install the web admin interface.

    NOTE: At the end, it will give you a password for the web dashboard. Save it! that it is possible to set a new password with this command pihole setpassword.

  3. Configure Your Router:
    You need to tell your network to use Pi-hole as its DNS server. It is possible in two ways:

  • First Way (Recommended): Log in to your router and change its DHCP DNS Server setting to the Pi-hole's static IP address.
  • Second Way: Disable the DHCP server on your router and enable DHCP server inside Pi-hole.

What is a DHCP Server?

DHCP stands for Dynamic Host Configuration Protocol.

DHCP Server is like a manager for your network. When a new device connects to the network, the DHCP server automatically assigns it all the necessary information:

  1. IP Address: gives a unique IP for every device.
  2. Subnet Mask: Defines the size of the local network.
  3. Default Gateway: Router's IP To get to the internet.
  4. DNS Server IP: Translating domain names to IP addresses.

NOTE: Without DHCP, you would have to manually configure every single device that connects to your network, which is slow and prone to errors.

The DHCP Conflict: Router vs. Pi-hole

You must only have ONE active DHCP server on your network. You must choose to use either your router's DHCP server or Pi-hole's DHCP server.

Problem

If you disable both your router's DHCP server or Pi-hole's DHCP server, your network will stop working for most devices.

  • Result: When a device connects, it will ask for an IP address, but no server will answer. The device will not be able to join the network or access the internet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment