In this tutorial, we'll walk through setting up Dynamic DNS (DDNS) on No-IP and installing WireGuard VPN using PiVPN on a Raspberry Pi. This guide assumes you have basic knowledge of Linux commands and network configurations.
- A Raspberry Pi with Raspbian installed
- A No-IP account
- Internet access
- A public IP address
Dynamic DNS (DDNS) allows you to map a dynamic IP address to a static hostname. This is useful if your ISP changes your IP address frequently.
- Go to No-IP's website and sign up for a free account.
- Confirm your email address.
- Log in to your No-IP account.
- Navigate to
Dynamic DNS>Add Hostname. - Enter a hostname (e.g.,
myhome.no-ip.org). - Select a domain.
- Click
Save Hostname.
-
Open a terminal on your Raspberry Pi.
-
Download the No-IP DUC:
cd /usr/local/src sudo wget https://www.noip.com/client/linux/noip-duc-linux.tar.gz sudo tar xf noip-duc-linux.tar.gz cd noip-2.1.9-1 sudo make sudo make install
-
Configure the No-IP DUC:
sudo /usr/local/bin/noip2 -C
-
Enter your No-IP account credentials when prompted.
-
To start the No-IP DUC client:
sudo /usr/local/bin/noip2
-
To ensure it runs on startup, add the following to
/etc/rc.local:sudo nano /etc/rc.local
Add before the
exit 0line:/usr/local/bin/noip2
WireGuard is a modern, fast, and secure VPN protocol. PiVPN makes the installation of WireGuard easy.
- Update and upgrade your system:
sudo apt update sudo apt upgrade -y
- Install PiVPN:
curl -L https://install.pivpn.io | bash - Follow the on-screen prompts:
- Select
WireGuard. - For the local user, select the default user (e.g.,
pi). - When prompted for the port, enter
1337. - Confirm and proceed with the installation.
- Select
- Log in to your router's web interface.
- Navigate to the port forwarding section.
- Add a new rule to forward UDP port
1337to the internal IP address of your Raspberry Pi.
- On your Raspberry Pi, generate a new client profile:
pivpn add
- Follow the prompts to create a client profile (e.g.,
myclient).
- The configuration file will be saved in
/home/pi/configs/(or the home directory of the selected user). - Transfer the configuration file to your client device (e.g., via SCP, email, or USB drive):
scp pi@your_pi_ip:/home/pi/configs/myclient.conf /local/path/
- Install the WireGuard app on your client device (available for Windows, macOS, Linux, iOS, and Android).
- Import the configuration file
myclient.confinto the WireGuard app.
- Open the WireGuard app on your client device.
- Select the imported configuration and connect.
You have successfully set up Dynamic DNS with No-IP and installed WireGuard VPN using PiVPN on port 1337. Your Raspberry Pi is now ready to provide secure VPN access with a consistent hostname.
Feel free to leave comments if you encounter any issues or have questions!