How to set up your network protection with Pi-hole
Learn how to use Pi-hole for remote network protection over Meshnet.
Introduction
These days, the internet is full of advertisements and malicious websites. Due to this, many people resort to using third-party tools, such as ad blockers or threat protection tools, to overcome the sheer amount of danger online. One such tool that enthusiasts tend to use more than others is Pi-hole.
Pi-hole allows you to transform your device to a local DNS server, which can be used as a network-wide ad blocker. While advertisement blocking is Pi-hole’s main purpose, you can use it for a variety of other options, such as local DNS mapping and website blacklisting.
On its own, Pi-hole only functions on the local area network (LAN). However, with the power of Meshnet, you can use Pi-hole on your devices remotely. Meshnet allows you to establish a secure and encrypted connection between your end device and the Pi-hole server.
While you can deploy a Pi-hole Docker container on Windows and macOS, this guide will walk you through the standard installation on Linux. It will also show how to configure your devices for remote use by setting the Pi-hole Meshnet IP address as your DNS address.
See the following overview video for additional information and instructions for the Pi-hole setup.
Alternatively, proceed with the detailed text-based instructions provided on this page.
Before you begin
Ensure that the machine you will use for Pi-hole meets the following criteria:
Linux distribution using Systemd or SysVinit
2 GB of free disk space or more
512 MB RAM or more
Static LAN IP address
Meshnet is enabled on the Linux machine and all client devices that will be using Pi-hole
For more detailed information, refer to the Pi-hole Prerequisites documentation.
Install Pi-hole
Open Terminal and run the following command to download and execute the Pi-hole installation script:
curl -sSL https://install.pi-hole.net | bashFor alternative installation methods, refer to the Pi-hole installation page.
Enter the sudo password of your Linux machine.
In the installation dialog, select OK until you reach the Static IP needed window. If your device already has a static LAN IP address configured, select Continue. Otherwise, complete the necessary IP adjustments in your network.
Choose the network interface that your device is using (for example,
eth0,wlan0,enp0s3) and then choose Select.
Select your preferred upstream DNS provider and select OK.
Complete the installation process by choosing the blocklist, installing the Admin Web Interface with the required modules, and configuring the query logging settings.
In the Installation complete window, note down the address and password for the Pi-hole web interface and select OK.

Tip
Make sure to change the password of your Pi-hole web interface to a unique and secure one. You can do so by executing the following command in the terminal:
sudo pihole setpasswordAllow Meshnet connections in Pi-hole settings
Default Pi-hole settings allow requests only from the same local subnet of the host device (for example, 192.168.1.0/24). Since Meshnet IP addresses use a different subnet, Pi-hole will ignore all queries to the server.
To allow remote Meshnet connections to your Pi-hole, complete the following steps:
Open your browser, enter the URL of the Pi-hole web interface that was provided in the Installation complete window, and log in.
If you are accessing the web interface from the host device directly, you can use this URL:
http://localhost/adminOtherwise, use the device’s local IP address instead of the
localhostpart.
From the left side menu, under System, go to Settings > DNS.
In the upper-right corner, click the Basic toggle to switch to the Expert view.
Under Interface, select the Permit all origins option.


Click Save and apply.
Pi-hole is now installed and prepared for use via Meshnet.
Tip
If you want to change the upstream DNS addresses for your Pi-hole in the future, you can do so on the same DNS tab, under Upstream DNS servers.
Import blocklists to Pi-hole
With the additional features Pi-hole offers, you can further enhance your network security. One example is to import custom website blocklists to protect your devices from malicious and dangerous URLs or phishing domains. For this guide, blocklists from the firebog.net website will be used.
Add URLs
To add blocklist URLs to Pi-hole:
Open your Pi-hole web interface.
From the menu on the left, under Group management, select Lists.
In the Address field, enter your preferred blocklist URL. Click Add.


You will see the newly added blocklist under Subscribed lists.


Update gravity script
To start using the newly imported blocklists, update Pi-hole’s gravity script.
Open Pi-hole’s web interface.
From the left side menu, under System, go to Tools > Update gravity.


Press Update and wait for the process to finish.
Once done, you will see a success message.
Alternatively, you can run the following command in Terminal:
sudo pihole updateGravityUse your Pi-hole DNS over Meshnet
The Pi-hole configuration is now finished. However, to use Pi-hole and all of its features, you need to set up its Meshnet IP address as the DNS server on each of your client devices.
Without a VPN connection
Windows 11
Right-click Start
and select Network connections.
Choose the network type your device is using (Wi-Fi or Ethernet).
Find the DNS server assignment option and click Edit.
Choose Manual from the dropdown menu and enable IPv4.
Fill in the DNS fields.
Preferred DNS server: the Meshnet IP of the Pi-hole device
Alternate DNS server: the DNS address of another provider


Click Save.
Windows 10
Right-click Start
and select Network connections.
Select Change adapter options.
Right-click your current network adapter (Wi-Fi or Ethernet) and choose Properties.
In the new window, select Internet Protocol Version 4 (TCP/IPv4) and click Properties.
Select Use the following DNS server addresses and fill in the fields underneath.
Preferred DNS server: the Meshnet IP of the Pi-hole device
Alternate DNS server: the DNS address of another provider

Click OK twice to apply the changes.
Open the Settings menu.
Go to Network & internet > Internet, find your current Wi-Fi network, and tap the gear button.
In the upper-right corner, select Modify.
Expand the Advanced settings dropdown, and change the IP settings value to Static.
Enter your device's local IP address, network gateway, and network prefix length.
Fill in the required DNS addresses.
Under DNS 1, enter the Meshnet IP of the Pi-hole device.
Under DNS 2, enter the DNS address of another provider.


Tap Save.
Open Settings.
Tap Wi-Fi, find your current network, and tap the Info
button.
Under DNS, tap Configure DNS, and choose Manual.
Select Add server and enter the Meshnet IP of the Pi-hole device.


Ensure that the added IP address is at the top.
Tap Save.
macOS Ventura 13 and newer
Go to System settings and click Network.
Select the network interface you use (Wi-Fi or Ethernet) and click Details.
Open the DNS tab and click the plus (+) button at the bottom to add the Meshnet IP address of the Pi-hole device.
Ensure that the added IP address is at the top.


Click OK to save the changes.
macOS Monterey 12 and older
Go to System preferences and click Network.
Select the network interface you use (Wi-Fi or Ethernet) and click Advanced.
Open the DNS tab and add the Meshnet IP address of the Pi-hole device by clicking the plus (+) icon.
Ensure that the added IP address is at the top.

Click OK and then click Apply.
Method 1: Using Network Manager
Open Settings, and then open either the Network or the Wi-Fi section (depending on your network type).
Click the gear button and go to the IPv4 tab.
Next to DNS, turn off the Automatic toggle.
Enter the Meshnet IP of the Pi-hole device and the DNS of another provider, separated by a comma, in the specified field.


Click Apply.
Open Terminal and run the following command to restart the Network Manager daemon:
sudo systemctl restart NetworkManagerEnter your sudo password.
Method 2: Using Terminal
Open Terminal and run the following command:
sudo nano /etc/systemd/resolved.confLocate the
DNSandFallbackDNSlines.Uncomment the lines by removing the hash (#) symbols.
Enter the DNS addresses following the equals (=) sign.
DNS=<Meshnet IP of the Pi-hole device>FallbackDNS=<DNS of another provider>
Press Ctrl + X, Y, and Enter to exit and save the changes.
Run the following command to ensure that the network changes are applied:
sudo systemctl restart systemd-resolvedEnter your sudo password.
Open the Android TV Settings menu.
Select Network & internet.
Choose your network and change the IP settings value to Static.
Enter your device's local IP address, network gateway, and network prefix length.
Type in the DNS addresses:
In the DNS 1 field, enter the Meshnet IP address of your Pi-hole device.

In the DNS 2 field, enter the DNS address of another provider.
With a VPN connection
Meshnet allows you to use your custom, self-hosted DNS server alongside a VPN connection via the NordVPN app. Follow these steps to use your Pi-hole DNS when connected to a VPN server:
Open the NordVPN app.
Navigate to the Devices in Meshnet
tab and copy the Meshnet IP address of your Pi-hole device.
In the lower-left corner, click Settings
.
Select the Connection and security section.
Turn on the Use custom DNS toggle and click the dropdown arrow.
In the first field, paste the copied Meshnet IP address.


Click the Save checkmark.
Now, when you establish a VPN connection to a NordVPN server, the DNS addresses that you specified will be used for the connection.
Open the NordVPN app.
Navigate to Profile
> Meshnet
> Manage devices and copy the Meshnet IP address of your Pi-hole device.
Go back to the Profile
menu, and then go to Settings
> DNS.
Select Custom, paste the copied Meshnet IP address, and tap Add.


Now, when you establish a VPN connection to a NordVPN server, the DNS addresses that you specified will be used for the connection.
Open the NordVPN app.
Navigate to Profile
> Meshnet
> Manage devices and copy the Meshnet IP address of your Pi-hole device by tapping it.
Go back to the Profile
menu and select Settings
.
Under VPN connection, tap Protocol.
In the Enter custom DNS address field, paste the copied Meshnet IP address.


Now, when you establish a VPN connection to a NordVPN server, the DNS addresses that you specified will be used for the connection.
Open the NordVPN app.
Navigate to the Meshnet
tab and copy the Meshnet IP address of your Pi-hole device.
In the lower-left corner, click Settings
and go to Custom DNS.
Click Add new DNS.
In the new entry, paste the copied Meshnet IP address.
Turn on the Use custom DNS servers toggle.


Now, when you establish a VPN connection to a NordVPN server, the DNS addresses that you specified will be used for the connection.
Open Terminal.
Run the following command, replacing
<MeshnetIP>with your Pi-hole device's Meshnet IP address:nordvpn set dns <MeshnetIP>Example

Now, when you establish a VPN connection to a NordVPN server, the DNS addresses that you specified will be used for the connection.
Open the NordVPN app.
Navigate to Settings
> DNS server.
Choose Custom and select Add server.

Enter the Meshnet IP address of your Pi-hole device and choose Add custom DNS.

Now, when you establish a VPN connection to a NordVPN server, the DNS address that you specified will be used for the connection.
Tip
If you're looking for alternate DNS addresses, here are some of the most popular free DNS providers:
Google —
8.8.8.8and8.8.4.4Cloudflare —
1.1.1.1and1.0.0.1AdGuard —
94.140.14.14and94.140.15.15Quad9 —
9.9.9.9and149.112.112.112OpenDNS —
208.67.222.222and208.67.220.220
You can also use the same upstream DNS addresses from the Pi-hole configuration.
After changing the DNS server to the Pi-hole’s Meshnet IP address, the setup is finished. Now you can safely use Pi-hole’s protection features while being away from your home network.
Last updated
Was this helpful?