You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
Go to file
GOD/GRATEFUL MIB OPERATOR a2b9868312
Update README.md
3 months ago
.github Bump github/codeql-action from 2 to 3 5 months ago
advanced Add "-ni" to all sqlite3 invocations 5 months ago
automated install adminlte->web 7 months ago
manpages adminlte->web 7 months ago
test Bump pytest from 7.4.3 to 7.4.4 in /test 4 months ago
.codespellignore Yu vs uh 8 months ago
.editorconfig Add editorconfig-checker workflow 2 years ago
.gitattributes linux style line endings enforced 7 years ago
.gitignore Update the tests (#4427) 3 years ago
.stickler.yml Disable line length rule for yamllint - fix indentation in stale.yml 2 years ago
.yamllint.conf Disable line length rule for yamllint - fix indentation in stale.yml 2 years ago
CONTRIBUTING.md Add editorconfig-checker workflow 2 years ago
LICENSE Update LICENSE of the project to EUPL v1.2 7 years ago
README.md Update README.md 3 months ago
gravity.sh Add "-ni" to all sqlite3 invocations 5 months ago
pihole Only source versions file if the file exits 1 year ago

README.md

Pi-hole website
Network-wide ad blocking via your own Linux hardware

The Pi-hole® is a DNS sinkhole that protects your devices from unwanted content without installing any client-side software.

  • Easy-to-install: our dialogs walk you through the simple installation process in less than ten minutes
  • Resolute: content is blocked in non-browser locations, such as ad-laden mobile apps and smart TVs
  • Responsive: seamlessly speeds up the feel of everyday browsing by caching DNS queries
  • Lightweight: runs smoothly with minimal hardware and software requirements
  • Robust: a command-line interface that is quality assured for interoperability
  • Insightful: a beautiful responsive Web Interface dashboard to view and control your Pi-hole
  • Versatile: can optionally function as a DHCP server, ensuring all your devices are protected automatically
  • Scalable: capable of handling hundreds of millions of queries when installed on server-grade hardware
  • Modern: blocks ads over both IPv4 and IPv6
  • Free: open source software that helps ensure you are the sole person in control of your privacy

One-Step Automated Install

Those who want to get started quickly and conveniently may install Pi-hole using the following command:

curl -sSL https://install.pi-hole.net | bash

Alternative Install Methods

Piping to bash is controversial, as it prevents you from reading code that is about to run on your system. Therefore, we provide these alternative installation methods which allow code review before installation:

Method 1: Clone our repository and run

git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole
cd "Pi-hole/automated install/"
sudo bash basic-install.sh

Method 2: Manually download the installer and run

wget -O basic-install.sh https://install.pi-hole.net
sudo bash basic-install.sh

Method 3: Using Docker to deploy Pi-hole

Please refer to the Pi-hole docker repo to use the Official Docker Images.

Post-install: Make your network take advantage of Pi-hole

Once the installer has been run, you will need to configure your router to have DHCP clients use Pi-hole as their DNS server. This router configuration will ensure that all devices connecting to your network will have content blocked without any further intervention.

If your router does not support setting the DNS server, you can use Pi-hole's built-in DHCP server; be sure to disable DHCP on your router first (if it has that feature available).

As a last resort, you can manually set each device to use Pi-hole as their DNS server.


Pi-hole is free but powered by your support

There are many reoccurring costs involved with maintaining free, open-source, and privacy-respecting software; expenses which our volunteer developers pitch in to cover out-of-pocket. This is just one example of how strongly we feel about our software and the importance of keeping it maintained.

Make no mistake: your support is absolutely vital to help keep us innovating!

Donations

Donating using our Sponsor Button is extremely helpful in offsetting a portion of our monthly expenses:

Alternative support

If you'd rather not donate (which is okay!), there are other ways you can help support us:

Contributing via GitHub

We welcome everyone to contribute to issue reports, suggest new features, and create pull requests.

If you have something to add - anything from a typo through to a whole new feature, we're happy to check it out! Just make sure to fill out our template when submitting your request; the questions it asks will help the volunteers quickly understand what you're aiming to achieve.

You'll find that the install script and the debug script have an abundance of comments, which will help you better understand how Pi-hole works. They're also a valuable resource to those who want to learn how to write scripts or code a program! We encourage anyone who likes to tinker to read through it and submit a pull request for us to review.


Getting in touch with us

While we are primarily reachable on our Discourse User Forum, we can also be found on various social media outlets.

Please be sure to check the FAQs before starting a new discussion, as we do not have the spare time to reply to every request for assistance.


Breakdown of Features

Faster-than-light Engine

FTLDNS is a lightweight, purpose-built daemon used to provide statistics needed for the Web Interface, and its API can be easily integrated into your own projects. As the name implies, FTLDNS does this all very quickly!

Some of the statistics you can integrate include:

  • Total number of domains being blocked
  • Total number of DNS queries today
  • Total number of ads blocked today
  • Percentage of ads blocked
  • Unique domains
  • Queries forwarded (to your chosen upstream DNS server)
  • Queries cached
  • Unique clients

Access the API via telnet, the Web (admin/api.php) and Command Line (pihole -c -j). You can find out more details over here.

The Command-Line Interface

The pihole command has all the functionality necessary to fully administer the Pi-hole, without the need for the Web Interface. It's fast, user-friendly, and auditable by anyone with an understanding of bash.

Some notable features include:

You can read our Core Feature Breakdown for more information.

The Web Interface Dashboard

This optional dashboard allows you to view stats, change settings, and configure your Pi-hole. It's the power of the Command Line Interface, with none of the learning curve!

Some notable features include:

  • Mobile-friendly interface
  • Password protection
  • Detailed graphs and doughnut charts
  • Top lists of domains and clients
  • A filterable and sortable query log
  • Long Term Statistics to view data over user-defined time ranges
  • The ability to easily manage and configure Pi-hole features
  • ... and all the main features of the Command Line Interface!

There are several ways to access the dashboard:

  1. http://pi.hole/admin/ (when using Pi-hole as your DNS server)
  2. `http://<#!/usr/bin/env bash

shellcheck disable=SC1090

Pi-hole: A black hole for Internet advertisements

(c) Pi-hole (https://pi-hole.net)

Network-wide ad blocking via your own hardware.

Installs and Updates Pi-hole

This file is copyright under the latest version of the EUPL.

Please see LICENSE file for your rights under this license.

pi-hole.net/donate

Install with this command (from your Linux machine):

curl -sSL https://install.pi-hole.net | bash

-e option instructs bash to immediately exit if any command [1] has a non-zero exit status

We do not want users to end up with a partially working install, so we exit the script

instead of continuing the installation with something broken

set -e

Append common folders to the PATH to ensure that all basic commands are available.

When using "su" an incomplete PATH could be passed: https://github.com/pi-hole/pi-hole/issues/3209

export PATH+=':/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'

######## VARIABLES #########

For better maintainability, we store as much information that can change in variables

This allows us to make a change in one place that can propagate to all instances of the variable

These variables should all be GLOBAL variables, written in CAPS

Local variables will be in lowercase and will exist only within functions

It's still a work in progress, so you may see some variance in this guideline until it is complete

Dialog result codes

dialog code values can be set by environment variables, we only override if

the env var is not set or empty.

: "${DIALOG_OK:=0}"
"${DIALOG_CANCEL:=1}"
"${DIALOG_ESC:=255}"

List of supported DNS servers

DNS_SERVERS=$(cat << EOM Google (ECS, DNSSEC);8.8.8.8;8.8.4.4;2001:4860:4860:0:0:0:0:8888;2001:4860:4860:0:0:0:0:8844 OpenDNS (ECS, DNSSEC);208.67.222.222;208.67.220.220;2620:119:35::35;2620:119:53::53 Level3;4.2.2.1;4.2.2.2;; Comodo;8.26.56.26;8.20.247.20;; DNS.WATCH (DNSSEC);84.200.69.80;84.200.70.40;2001:1608:10:25:0:0:1c04:b12f;2001:1608:10:25:0:0:9249:d69b Quad9 (filtered, DNSSEC);9.9.9.9;149.112.112.112;2620:fe::fe;2620:fe::9 Quad9 (unfiltered, no DNSSEC);9.9.9.10;149.112.112.10;2620:fe::10;2620:fe::fe:10 Quad9 (filtered, ECS, DNSSEC);9.9.9.11;149.112.112.11;2620:fe::11;2620:fe::fe:11 Cloudflare (DNSSEC);1.1.1.1;1.0.0.1;2606:4700:4700::1111;2606:4700:4700::1001 EOM )

Location for final installation log storage

installLogLoc="/etc/pihole/install.log"

This is an important file as it contains information specific to the machine it's being installed on

setupVars="/etc/pihole/setupVars.conf"

Pi-hole uses lighttpd as a Web server, and this is the config file for it

lighttpdConfig="/etc/lighttpd/lighttpd.conf"

This is a file used for the colorized output

coltable="/opt/pihole/COL_TABLE"

Root of the web server

webroot="/var/www/html"

We clone (or update) two git repositories during the install. This helps to make sure that we always have the latest versions of the relevant files.

web is used to set up the Web admin interface.

Pi-hole contains various setup scripts and files which are critical to the installation.

Search for "PI_HOLE_LOCAL_REPO" in this file to see all such scripts.

Two notable scripts are gravity.sh (used to generate the HOSTS file) and advanced/Scripts/webpage.sh (used to install the Web admin interface)

webInterfaceGitUrl="https://github.com/pi-hole/web.git" webInterfaceDir="${webroot}/admin" piholeGitUrl="https://github.com/pi-hole/pi-hole.git" PI_HOLE_LOCAL_REPO="/etc/.pihole"

List of pihole scripts, stored in an array

PI_HOLE_FILES=(chronometer list piholeDebug piholeLogFlush setupLCD update version gravity uninstall webpage)

This directory is where the Pi-hole scripts will be installed

PI_HOLE_INSTALL_DIR="/opt/pihole" PI_HOLE_CONFIG_DIR="/etc/pihole" PI_HOLE_BIN_DIR="/usr/local/bin" FTL_CONFIG_FILE="${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf" if [ -z "$useUpdateVars" ]; then useUpdateVars=false fi

adlistFile="/etc/pihole/adlists.list"

Pi-hole needs an IP address; to begin, these variables are empty since we don't know what the IP is until this script can run

IPV4_ADDRESS=${IPV4_ADDRESS} IPV6_ADDRESS=${IPV6_ADDRESS}

Give settings their default values. These may be changed by prompts later in the script.

QUERY_LOGGING=true INSTALL_WEB_INTERFACE=true PRIVACY_LEVEL=0 CACHE_SIZE=10000

if [ -z "${USER}" ]; then USER="$(id -un)" fi

dialog dimensions: Let dialog handle appropriate sizing.

r=20 c=70

######## Undocumented Flags. Shhh ########

These are undocumented flags; some of which we can use when repairing an installation

The runUnattended flag is one example of this

reconfigure=false runUnattended=false INSTALL_WEB_SERVER=true

Check arguments for the undocumented flags

stop_service pihole-FTL &> /dev/null

if [ ! -d /var/log/pihole/ ]; then
    mkdir -m 0755 /var/log/pihole/
fi

# Special handling for pihole-FTL.log -> pihole/FTL.log
if [ -f /var/log/pihole-FTL.log ] && [ ! -L /var/log/pihole-FTL.log ]; then
    # /var/log/pihole-FTL.log      -> /var/log/pihole/FTL.log
    # /var/log/pihole-FTL.log.1    -> /var/log/pihole/FTL.log.1
    # /var/log/pihole-FTL.log.2.gz -> /var/log/pihole/FTL.log.2.gz
    # /var/log/pihole-FTL.log.3.gz -> /var/log/pihole/FTL.log.3.gz
    # /var/log/pihole-FTL.log.4.gz -> /var/log/pihole/FTL.log.4.gz
    # /var/log/pihole-FTL.log.5.gz -> /var/log/pihole/FTL.log.5.gz
    for f in /var/log/pihole-FTL.log*; do mv "$f" "$( sed "s/pihole-/pihole\//" <<< "$f")"; done
fi

# Remaining log files
if [ -f /var/log/pihole.log ] && [ ! -L /var/log/pihole.log ]; then
    mv /var/log/pihole*.* /var/log/pihole/ 2>/dev/null
fi

restart_service pihole-FTL

# Download and compile the aggregated block list
runGravity

# Update local and remote versions via updatechecker
/opt/pihole/updatecheck.sh

if [[ "${useUpdateVars}" == false ]]; then
    displayFinalMessage "${pw}"
fi

# If the Web interface was installed,
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
    # If there is a password,
    if (( ${#pw} > 0 )) ; then
        # display the password
        printf "  %b Web Interface password: %b%s%b\\n" "${INFO}" "${COL_LIGHT_GREEN}" "${pw}" "${COL_NC}"
        printf "  %b This can be changed using 'pihole -a -p'\\n\\n" "${INFO}"
    fi
fi

if [[ "${useUpdateVars}" == false ]]; then
    # If the Web interface was installed,
    if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
        printf "  %b View the web interface at http://pi.hole/admin or http://%s/admin\\n\\n" "${INFO}" "${IPV4_ADDRESS%/*}"
    fi
    # Explain to the user how to use Pi-hole as their DNS server
    printf "  %b You may now configure your devices to use the Pi-hole as their DNS server\\n" "${INFO}"
    [[ -n "${IPV4_ADDRESS%/*}" ]] && printf "  %b Pi-hole DNS (IPv4): %s\\n" "${INFO}" "${IPV4_ADDRESS%/*}"
    [[ -n "${IPV6_ADDRESS}" ]] && printf "  %b Pi-hole DNS (IPv6): %s\\n" "${INFO}" "${IPV6_ADDRESS}"
    printf "  %b If you have not done so already, the above IP should be set to static.\\n" "${INFO}"
    INSTALL_TYPE="Installation"
else
    INSTALL_TYPE="Update"
fi

# Display where the log file is
printf "\\n  %b The install log is located at: %s\\n" "${INFO}" "${installLogLoc}"
printf "  %b %b%s complete! %b\\n" "${TICK}" "${COL_LIGHT_GREEN}" "${INSTALL_TYPE}" "${COL_NC}"

if [[ "${INSTALL_TYPE}" == "Update" ]]; then
    printf "\\n"
    "${PI_HOLE_BIN_DIR}"/pihole version --current
fi

}

allow to source this script without running it

if ; then main "$@" fi>/admin/`