Install server - Pi-hole documentation (2024)

The terms "server" and "client"

Usage of the terms server and client were purposefully chosen in this guide specifically to help both new users and existing OpenVPN users become familiar with the construction of WireGuard's configuration files.

WireGuard itself simply refers to all connected devices as peers. It constitutes a connection between computers.

Installing the server components

Installing everything we will need for a wireguard connections is as simple as running:

sudo apt-get install wireguard wireguard-tools

For Ubuntu 18.04 and before, you need to do some extra steps:

sudo add-apt-repository ppa:wireguard/wireguardsudo apt updatesudo apt install wireguard wireguard-tools

If you're running a kernel older than 5.6 (check with uname -r), you will also need to install wireguard-dkms

If there is no wireguard package available for your system, you can follow the instructions below to compile WireGuard from source.

Compile WireGuard from source

With the following commands, you can install WireGuard from source as a backport of the WireGuard kernel module for Linux to 3.10 ≤ kernel ≤ 5.5 as an out-of-tree module. More recent kernels already include WireGuard themselves and you only need to install the wireguard tools.

Update your local system

sudo apt update && sudo apt upgrade -y

Install the toolchain

sudo apt install -y raspberrypi-kernel-headers libelf-dev build-essential pkg-config git

Download and compile the wireguard module

git clone https://git.zx2c4.com/wireguard-linux-compatmake -C wireguard-linux-compat/src -j$(nproc)sudo make -C wireguard-linux-compat/src install

You can ignore messages like

Warning: modules_install: missing 'System.map' file. Skipping depmod.

Check the module installation was successful

Run

sudo modprobe wireguard

If there is no output, wireguard was loaded correctly. Note that it may be necessary to re-install the wireguard module when you update your system's kernel.

git clone https://git.zx2c4.com/wireguard-toolsmake -C wireguard-tools/src -j$(nproc)sudo make -C wireguard-tools/src install

The ZX2C4 git repository is the official source for wireguard-linux, see WireGuard#Repositories (external link)

Initial configuration

Each network interface has a private key and a list of peers. Each peer has a public key. Public keys are short and simple, and are used by peers to authenticate each other. They can be passed around for use in configuration files by any out-of-band method, similar to how one might send their SSH public key to a friend for access to a shell server.

First, we create the folder containing our wireguard configuration:

sudo -icd /etc/wireguardumask 077

Key generation

Inhere, we generate a key-pair for the server:

wg genkey | tee server.key | wg pubkey > server.pub

Creating the WireGuard configuration

Create a config file

sudo nano /etc/wireguard/wg0.conf

and put the following into it:

[Interface]Address = 10.100.0.1/24, fd08:4711::1/64ListenPort = 47111

Then run

echo "PrivateKey = $(cat server.key)" >> /etc/wireguard/wg0.confexit # Exit the sudo session

to copy the server's private key into your config file.

Forward port on your router

If the server is behind a device, e.g., a router that is doing NAT, be sure to forward the specified port on which WireGuard will be running (for this example, 47111/UDP) from the router to the WireGuard server.

NAT: Network address translation

Network address translation modifies network packages. Incoming connection requests have their destination address rewritten to a different one.NAT involves more than just changing the IP addresses. For instance, when mapping address 1.2.3.4 to 5.6.7.8, there is no need to add a rule to do the reverse translation. A netfilter system called conntrack recognizes packets that are replies to an existing connection. Each connection has its own NAT state attached to it. The reverse translation is done automatically.

Set up a domain name for your router

When connecting from outside your network, you'll need to know the public IP address of your router to connect. However, as most households are getting dynamically-assigned public IP addresses (these addresses change periodically), you need to note down the address every day before leaving the house. Since this is very uncomfortable, we strongly suggest registering a dynamic host record (often called "DynDNS" record).

The public IP address is checked at regular intervals. As soon as it changes, the router (or a DynDNS tool) sends a corresponding message to a URL of the service provider, who then updates the record.

There are many excellent guides and a lot of services offer this for free (with more or less comfort). We suggest a few providers below, however, this list is neither absolute nor exhaustive:

DynDNS providers
  • Strato.de (Guides: EN / DE)

    If you already have a hosting package at Strato, you can easily set up a subdomain to be used as a DynDNS record. This is entirely free for members.

  • DNSHome.de

    This provider offers you several free subdomains under different domain names. SSL and also IPv6 are possible. DNSSEC is activated by default. They offer configuration guides for the Fritz!Box and also ddclient (update tool for Windows and Linux) on the website.

  • GoIP.de

    Go IP is a German DynDNS provider. The service is completely free and allows the registration of one domain and up to 15 subdomains per person. The website is characterized by extensive help with setting up the router.

  • noip.com

    You can up to three hostnames like myname.no-ip.org for free. A disadvantage is that you have to confirm the domains at least every 30 days, otherwise they will be deleted.

  • Dyn.com

    One of the first providers to offer DynDNS was the American company Dyn, whose product "DynDNS" gave its name to an entire service branch. In the meantime, numerous successors whose services are often free of charge came up. DynDNS service is especially easy to use is if it is directly supported by the router.

You can either use the methods the corresponding providers recommend or use existing DynDNS solutions inbuilt in your router (if available). Most providers are compatible with, e.g., the popular Fritz!Box routers (EN / DE).

Start the server

Register your server wg0 as:

sudo systemctl enable wg-quick@wg0.servicesudo systemctl daemon-reloadsudo systemctl start wg-quick@wg0

If successful, you should not see any output.

Error: RTNETLINK answers: Operation not supported

In case you get an error like

RTNETLINK answers: Operation not supportedUnable to access interface: Protocol not supported

you should check that the WireGuard kernel module is loaded with the command below:

sudo modprobe wireguard

If you get an error saying the module is missing, try reinstalling WireGuard or restart your server and try again. This may happen when the WireGuard server is installed for a more recent kernel than you are currently running. This typically happens when you have neither updated nor restarted your system for a long time.

Error: RTNETLINK answers: File exists

In case you get an error like

RTNETLINK answers: File exists

you need to check the configured IP addresses (check the CIDR notation). Overlapping IP address ranges cause this error when trying to register a router for an address where a a route already exists. This is meaningful and always an error in your configuration. However, the error message could be more clear about this.

Check everything is running

With the following command, you can check if your wireguard server is running:

sudo wg

The output should look like the following:

interface: wg0 public key: XYZ123456ABC= ⬅ Your public key will be different private key: (hidden) listening port: 47111

Your public key will be different from ours. This is expected (you just created your own key above).

Set your Pi-hole to allow only local requests

On your Settings page (tab DNS), ensure you select the appropriate listening mode of your Pi-hole. Allow only local requests is preferred as it adds a bit of additional safety. Your WireGuard peers/clients will be correctly recognized as being only one hop away.

You can now continue to add clients.

Install server - Pi-hole documentation (2024)

FAQs

How long does it take to install Pi-hole? ›

Run Pi Hole Installer

It will take quite a while to install, and may seem to 'hang' at points. Just let it do its thing for about 20 minutes! The screenshots below are based on the 5.18. 2 release of Pi-Hole.

Why should I use unbound DNS? ›

Unbound is a validating, recursive, caching DNS resolver. It is designed to be fast and lean and incorporates modern features based on open standards. To help increase online privacy, Unbound supports DNS-over-TLS and DNS-over-HTTPS which allows clients to encrypt their communication.

How to setup Pi-hole DHCP server? ›

You can turn on Pi-hole's DHCP in Settings > DHCP, tick the enabled box, type in your router's IP address where indicated, and pick a range of addresses to hand out. Eg if the router is on 192.168. 1.1 and Pi-hole is on 192.168.

What is the easiest way to install Pi-hole? ›

Simplest way is to install Pi-hole on a supported OS with a static IP configured. Use the Docker image if you're familiar with Docker and that's easier. It's commonly installed on a Raspberry Pi running Pi OS. Once it's up and running it's a DNS server on your network.

Does Pi-hole slow wifi? ›

The only way for Pi-hole to slow down your network is if you've set up something to route all traffic via the Pi-hole server. Pi-hole only handles DNS queries, there is no way for it to slow down the internet connection at all, it doesn't see or handle any traffic other than DNS queries.

What is the difference between Pi-hole and unbound? ›

Pi-hole is a DNS sinkhole that can block ads and trackers for all devices on your network. Unbound is a validating, recursive, caching DNS resolver.

What DNS does Pi-hole use? ›

Pi-hole makes use of a modified dnsmasq called FTLDNS, cURL, lighttpd, PHP and the AdminLTE Dashboard to block DNS requests for known tracking and advertising domains.

Is unbound DNS free? ›

Unbound is a validating, recursive, and caching DNS resolver product from NLnet Labs. It is distributed free of charge in open-source form under the BSD license.

How do I setup a network with Pi-hole? ›

You install Pi-hole on your server (in this case, we're using a Raspberry Pi) and assign it a static IP address. On your router, you set the DNS primary server to the Pi-hole IP address. When a device connects to your home network, it gets the Pi-hole IP address as its main DNS server from your router.

Why use Pi-hole? ›

With a Pi-hole acting as the DNS server for your network, many pages will load without ads at all. Most privacy-invading trackers won't work either. You'll still see cookie and app install banners, because those can't be blocked at the DNS level.

How do I access my Pi-hole server? ›

There are several ways to access the dashboard: http://<IP_ADDRESS_OF_YOUR_PI_HOLE>/admin/ http://pi.hole/admin/ (when using Pi-hole as your DNS server) http://pi.hole/ (when using Pi-hole as your DNS server)

How to add DNS records in Pi-hole? ›

Once Pi-Hole is setup, head over to the local DNS settings under DNS Records at /admin/dns_records. php . Here you can enter a local domain name that will point to a local IP of your choice. Example, if you have a local Bookstack instance setup on 192.168.

How long does it take to install a Raspberry Pi? ›

Usually, Raspbian installation in Raspberry Pi takes about 30–45 Minutes including transferring the installation files in SD Card.

How much does it cost to set up a Pi-hole? ›

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.

How long does RetroPie take to install? ›

Install RetroPie

Total time for install is only 15 minutes. Select “Basic Install' and allow the packages time to install. Then select YES to install the core and main packages. This step may take a few minutes.

How much space does Pi-hole take? ›

To deploy Pi-hole on your home network, make sure you have all of the following: A Raspberry Pi with at least 512MB of RAM (all Raspberry Pi versions satisfy this requirement) and Raspbian installed. An SD-card with at least 2GB of free space.

Top Articles
Initiate of Mysteries - Fallout 76 Wiki Guide - IGN
How to Buy, Sell, and Use Steam Trading Cards
Ffxiv Act Plugin
Knoxville Tennessee White Pages
Moon Stone Pokemon Heart Gold
Wizard Build Season 28
Readyset Ochsner.org
Apex Rank Leaderboard
Elden Ring Dex/Int Build
Skip The Games Norfolk Virginia
Elizabethtown Mesothelioma Legal Question
Missing 2023 Showtimes Near Landmark Cinemas Peoria
Gino Jennings Live Stream Today
Munich residents spend the most online for food
Tamilrockers Movies 2023 Download
Katherine Croan Ewald
Diamond Piers Menards
The Ultimate Style Guide To Casual Dress Code For Women
Site : Storagealamogordo.com Easy Call
Is Windbound Multiplayer
Filthy Rich Boys (Rich Boys Of Burberry Prep #1) - C.M. Stunich [PDF] | Online Book Share
Integer Division Matlab
Sandals Travel Agent Login
Horn Rank
Ltg Speech Copy Paste
Cognitive Science Cornell
Random Bibleizer
Craigslist Fort Smith Ar Personals
The Clapping Song Lyrics by Belle Stars
Poe T4 Aisling
R/Sandiego
Kempsville Recreation Center Pool Schedule
Pfcu Chestnut Street
Beaver Saddle Ark
Log in or sign up to view
A Man Called Otto Showtimes Near Amc Muncie 12
Powerspec G512
The Minneapolis Journal from Minneapolis, Minnesota
Saybyebugs At Walmart
Gvod 6014
2007 Jaguar XK Low Miles for sale - Palm Desert, CA - craigslist
Miami Vice turns 40: A look back at the iconic series
Tlc Africa Deaths 2021
Youravon Com Mi Cuenta
Nope 123Movies Full
Kushfly Promo Code
Diario Las Americas Rentas Hialeah
Game Akin To Bingo Nyt
Kidcheck Login
Marion City Wide Garage Sale 2023
Latest Posts
Article information

Author: Duane Harber

Last Updated:

Views: 5545

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Duane Harber

Birthday: 1999-10-17

Address: Apt. 404 9899 Magnolia Roads, Port Royceville, ID 78186

Phone: +186911129794335

Job: Human Hospitality Planner

Hobby: Listening to music, Orienteering, Knapping, Dance, Mountain biking, Fishing, Pottery

Introduction: My name is Duane Harber, I am a modern, clever, handsome, fair, agreeable, inexpensive, beautiful person who loves writing and wants to share my knowledge and understanding with you.