Wireguard VPN setup Featured Image

Self-host Wireguard VPN Server in 5 minutes

Wireguard May 3, 2023

Introduction

I think this will be the easiest setup available for self-hosting. It took around 3 weeks to make it work. And found this amazing Github repo. Which makes it just 1 minute away to self-host wireguard. But as we all know everything comes with some cost. So here cost is your learning part.

You will be able to self-host 💻 within minutes but will cut ✂️ down your learning part. So I suggest anyone reading 📕 this blog can try some other tutorials available over the internet before trying this fast-forward ⏩ way of setup.

I will list down few tutorials which you can follow to self-host. And try if you can do it without some automated scripts. Because that will be going to shine in your experience and skills. And not in the number of things you did.

I tried so much to set up all the available blogs over the internet but didn't get any way to make any of them work. Here is the list of blogs that I tried and if some of you get success please comment to let me know which blog worked out for you. That would be helpful for me and for all the other people also who will be going to read this sometime in the future.

Installation - WireGuard
How To Set Up WireGuard on Ubuntu 22.04 | DigitalOcean
In this tutorial, you will set up WireGuard on an Ubuntu 22.04 server, and then configure another machine to connect to it as a peer using both IPv4 and IPv6…
How to Set up a Secure WireGuard VPN on Ubuntu 22.04
In this tutorial, you will set up WireGuard VPN on the Ubuntu 22.04. WireGuard is a modern VPN technology.

These are few of them which I followed and so much of Stackoverflow. But didn't got success even after trying all these...

Fast Forward Technique

Disclaimer - I will not be responsible for any cause due to this GitHub repository. I am just sharing this on the basis of my good experience.

Step 1. Got to this github repository read what project is all about in detail. And what it does when you run through this script.

Step 2. Make directory if you wish to download this file into some other folder rather then root directory. (Optional)

mkdir wireguard
and
cd wireguard
to enter in the directory

⬆️ In the above command wireguard is the folder name and mkdir command to create a directory.

Step 3. Run the following command to download the wireguard-install.sh file

curl -O https://raw.githubusercontent.com/angristan/wireguard-install/master/wireguard-install.sh

Step 4. Now in order to execute this script we need to give execution permission to wireguard-install.sh .

chmod +x wireguard-install.sh

here chmod command is used for permissions and +x means execute permission.

Step 5.  Run the following command to run the script and install wireguard server

./wireguard-install.sh
if the ⬆️above one doesn't work then use this⬇️ one
sudo ./wireguard-install.sh

This command will show interface similar to this just press enter if you feel the details are okay provided by the script.

Welcome to the WireGuard installer!
The git repository is available at:
https://github.com/angristan/wireguard-install
I need to ask you a few questions before starting the setup.You can keep the default options and just press enter if you are ok with them.

IPv4 or IPv6 public address: 192.168.XX.XX (Replace this with your public ip)
Public interface: dev0
WireGuard interface name: wg0
Server WireGuard IPv4: 10.66.66.1
Server Port : Any(Example - 4576)
Just Keep pressing 🔨 your enter key.

If you face any issues just try repeating the steps or configuring your firewall properly ⬇️

Source - https://pin.it/4tnYz9j

Allow the port you just selected through your respective firewall UFW or IPTABLES  for UDP and TCP.

And don't forget to add the same rule to your hosting provider's dashboard as well. In order to allow traffic over those ports.

If you are going through this shortcut way of self-hosting Wireguard. Then you might wonder where to locate wire guard configurations.

Go to /etc/wireguard/ you can see all your configuration related to wireguard here. You also have to manually add clients by generating key and pair of private and public jut go through step 5.

Hurray! 🙌 we have completed the self-hosting for Wireguard.

Now you can generate the keys for peers/clients to connect through your wireguard. Re-run step 5 to generate client config and download wireguard client according to your platform.

Read this blog on how to setup wireguard client.

  1. Download Windows Client Link
  2. Download Android Client Link
  3. Download IOS Client Link
  4. Download MAC Client Link
  5. Download Ubuntu Client
    sudo apt install wireguard resolvconf

Thanks for reading hope you enjoyed reading.

Tags