Set up your own WireGuard VPN on a NAT VPS (with wireguard-install)
One script, a few questions, five minutes. Use one of your NAT ports to build a fast, encrypted VPN of your own for your phone and laptop, IPv6 included.
Mekanode ekibi
· 4 dk okuma
Whether you want to stay safe on public Wi-Fi, browse from abroad as if you were at home, or simply have a VPN that's yours, WireGuard is the easiest way. It's modern and fast, and it barely touches your phone's battery.
In this guide we'll install WireGuard on a NAT VPS with angristan/wireguard-install, a script that asks you a few questions and does the hard work itself.
First, how NAT ports work
On NAT plans the server's IPv4 address is shared, but you get a port range of your own. The server page in your panel shows something like this:
- SSH port:
20040. Connections to this port from outside go to port 22 on your server. - Your ports:
20041 – 20059, TCP and UDP. These open on your server under the same number: 20041 outside goes to 20041 inside.
WireGuard needs a single UDP port, so one port from your range is all it takes. This guide uses 20041.
Your port range and NAT IP are on the server page in your panel, under "Network". Replace 51.68.34.53, 20040 and 20041 in this guide with your own values.
1. Connect and download the script
ssh -p 20040 root@51.68.34.53curl -O https://raw.githubusercontent.com/angristan/wireguard-install/master/wireguard-install.sh
chmod +x wireguard-install.sh
./wireguard-install.shThe script works on Ubuntu, Debian, AlmaLinux, Rocky Linux, Fedora and more. It must run as root.
2. Answer the questions: two of them matter
The script asks a few questions. For most, press Enter to accept the default. There are two you must change:
| Question | What to enter |
|---|---|
IPv4 or IPv6 public address | The script suggests the server's internal address (10.88.0.x). Delete it and type your NAT IP: 51.68.34.53 |
Public interface | Enter |
WireGuard interface name | Enter (wg0) |
Server WireGuard IPv4 / IPv6 | Enter |
Server WireGuard port | Delete the random suggestion and type a port from your range: 20041 |
DNS resolver | Enter (1.1.1.1) or your preferred DNS |
Allowed IPs | Enter (all traffic goes through the VPN) |
Skip these two and the VPN installs fine, but you won't be able to connect: either the internal address isn't reachable from outside, or the random port isn't forwarded to you.
When installation finishes, the script asks for a name for your first device (Client name, e.g. phone). After that, Enter is fine again.
3. Connect your phone: scan the QR code
At the end the script prints a QR code in the terminal and tells you where the config file is: /root/wg0-client-phone.conf.
- Install the official WireGuard app on your phone (App Store / Google Play).
- Tap + → Scan from QR code and scan the code in your terminal.
- Name the tunnel and switch it on.
For a computer, download the config file and add it in the WireGuard app with Import tunnel from file:
scp -P 20040 root@51.68.34.53:/root/wg0-client-phone.conf .4. Is it working?
With the VPN on, visit any "what is my IP" site. Your IPv4 address should show as 51.68.34.53 and your IPv6 address as your server's. The script adds IPv6 to the VPN too, so your device gets IPv6 internet even if your home network doesn't have it.
5. Adding and removing devices
Just run the script again:
./wireguard-install.shUse 1) Add a new user to add a device and 3) Revoke existing user to remove one. Create a separate user for each device; don't use one config file on two devices at the same time.
Tip: connect over IPv6
If your phone is on mobile data, or your home network supports IPv6, you can skip NAT entirely and connect straight to your server's IPv6 address. Change the Endpoint line in the device's config:
Endpoint = [2a14:7581:3d10:42::1]:20041On IPv6 every port is yours, so any port would work. Keeping it the same as the server's port is simply the easiest, since the config stays identical on both sides.
Good to know
- Traffic quota: every 1 GB you download through the VPN reaches the server once and leaves it once. The quota counts inbound and outbound together, so it shows up as roughly 2 GB. If the quota runs out, the server isn't switched off; speed is reduced until the end of the month.
- Rules: the VPN is yours, and so is responsibility for the traffic that leaves it. The usage rules in our terms of service apply to VPN traffic too.
- WireGuard or OpenVPN? If your network doesn't block UDP, WireGuard is faster and simpler. If you're on a corporate network that only lets TCP through, see our OpenVPN guide.
Her sunucuda gerçek IPv6 /64, NAT IPv4 ve tam root erişimi. Aylık £2.49'dan başlayan fiyatlarla, yaklaşık bir dakikada hazır.