Pi-hole Wireguard VPN in Azure
This guide outlines the steps for setting up a Pi-hole VPN with Wireguard on an Azure virtual machine (VM). We will cover creating the VM, configuring Wireguard, and installing Pi-hole
Create a New Resource Group
To create a new resource group, run:
Create a Virtual Machine
Now, create your virtual machine with the following command:
This command will also generate SSH key files, enabling SSH access to your VM.
Open Port for Wireguard
Next, open port 4400, which will be used for Wireguard:
Check Public IP
To check your VM's public IP address, use:
Step 2: Set Up Wireguard
SSH into the VM
Connect to your VM via SSH using the public IP address from the previous step:
Update and Install UFW
Update your system and install UFW (Uncomplicated Firewall):
Configure UFW
Allow SSH and the VPN port through UFW:
Install Wireguard
Use the PiVPN script to install Wireguard:
Configure DNS Settings
Edit the DNS settings:
Uncomment the DNS
line and add your preferred DNS servers:
Symlink the Systemd Resolve File
Run the following commands to symlink the resolve file:
If you encounter an error like "unable to resolve host", resolve it by editing the hosts file:
Add the following line:
Verify the DNS Settings
You can verify the DNS settings by running:
Step 3: Configure Wireguard
After installing Wireguard, configure new clients using the pivpn
command:
Step 4: Set Up Pi-hole
Install Pi-hole
Pull and execute the Pi-hole installation script:
After installation, access the Pi-hole admin interface at http:///admin
.
Configure UFW for Pi-hole
Allow DNS Traffic (Port 53) To allow DNS traffic from your VPN network, run:
Allow HTTP Traffic (Port 80) To access the Pi-hole admin interface, allow HTTP traffic on port 80:
With these changes, Pi-hole should be set up and ready to block ads while being accessible through your VPN network.
Step 5: Resize VM to Save Costs
Resize your VM to a smaller size to save costs:
Step 6: Configure VPN on Windows 11
Copy Configuration File
Use scp
to copy the Wireguard client configuration file from your VM to your local Windows machine:
Replace <username>
with your VM’s username, <public-ip>
with your VM’s public IP address, and <client>
with the specific client configuration file name.
Install Wireguard App
Download and Install Wireguard Go to the Wireguard website and download the Windows app. Install the application on your Windows 11 machine.
Import the Configuration File Open the Wireguard app, click on Import Tunnel(s), and select the
.conf
file you transferred. This will set up the VPN profile in the app.Connect to the VPN With the configuration imported, click Activate to connect to the VPN.
By completing these steps, you should now have a functional Pi-hole VPN configured on your Windows 11 machine.
Last updated