Protecting yourself with your VPN on WireGuard

In the era of digital blocking, surveillance of every movement on the web, inaccessibility of some resources due to geo of your IP and similar reasons, it is necessary to protect yourself at least in a basic way, regardless of whether it is a personal or work device.
The use of ready-made VPN-services or official hosting does not solve the problem of anonymization, because at the first request of law enforcement agencies your real data will be given out without any complaints. However, this point can be solved by creating your own VPN on an offshore hosting, where there is a bonus and payment in cryptocurrency.
Spoiler: Just a VPS is enough.
The offshore hosting services mentioned above are a great addition to what we're planning to do. You can find these with a simple search. However, be sure to research the site as no one has canceled the work of scammers.
1. First of all, let's connect to our VPS.
2. update the system packages:
3. Install WireGuard itself:
2. Just in case, let's check the WireGuard module:
4. Create a directory for configuration:
5. Now we will need the configuration keys:
6. Save the keys to the variable buffer:
7. Create a configuration file:
8. Add all the settings:
9. Enable IP addressing:
10. Let's also configure NAT via iptables:
11. Save the iptables rules:
Remember to install the iptables-persistent package if it is not installed:
This gives us a customized VPS to create the configuration. Now let's create WireGuard on Linux/Ubuntu systems:
1. Install WireGuard:
2. Generate keys:
3. Get your client's public key:
4. Add the client to the server configuration (edit the /etc/wireguard/wg0.conf file on the server):
5. Create a client configuration file (on the device):
6. Add the following configuration (replace with the IP of your VPS):
Save and you're done! All that's left is to run it:
1. Start WireGuard on the server:
2. Run WireGuard on the system:
3. Check the connection status:
Bonus:
To have WireGuard automatically start at system boot, run the following commands on the server:
Now your own WireGuard-based VPN is ready to use! Have fun surfing!


In the era of digital blocking, surveillance of every movement on the web, inaccessibility of some resources due to geo of your IP and similar reasons, it is necessary to protect yourself at least in a basic way, regardless of whether it is a personal or work device.
The use of ready-made VPN-services or official hosting does not solve the problem of anonymization, because at the first request of law enforcement agencies your real data will be given out without any complaints. However, this point can be solved by creating your own VPN on an offshore hosting, where there is a bonus and payment in cryptocurrency.
Spoiler: Just a VPS is enough.
The offshore hosting services mentioned above are a great addition to what we're planning to do. You can find these with a simple search. However, be sure to research the site as no one has canceled the work of scammers.
1. First of all, let's connect to our VPS.
Bash:
sudo apt update && sudo apt upgrade -y
Bash:
sudo apt update && sudo apt upgrade -y
Bash:
sudo apt install wireguard -y
Bash:
sudo modprobe wireguard
Bash:
sudo mkdir /etc/wireguard
Bash:
cd /etc/wireguard
sudo wg genkey | sudo tee privatekey | sudo wg pubkey | sudo tee publickey
Bash:
PRIVATE_KEY=$(sudo cat privatekey)
PUBLIC_KEY=$(sudo cat publickey)
Bash:
sudo nano /etc/wireguard/wg0.conf
Bash:
[Interface]
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = $PRIVATE_KEY
[Peer]
PublicKey = <CLIENT_PUBLIC_KEY>
AllowedIPs = 10.0.0.2/32
Bash:
echo “net.ipv4.ip_forward = 1” | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
Bash:
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i wg0 -j ACCEPT
sudo iptables -A FORWARD -o wg0 -m state --state RELATED,ESTABLISHED -j ACCEPT
Remember to install the iptables-persistent package if it is not installed:
Bash:
sudo apt install iptables-persistent -y
1. Install WireGuard:
Bash:
sudo apt install wireguard -y
Bash:
wg genkey | tee privatekey | wg pubkey | tee publickey
Bash:
CLIENT_PUBLIC_KEY=$(cat publickey)
Bash:
[Peer]
PublicKey = $CLIENT_PUBLIC_KEY
AllowedIPs = 10.0.0.0.2/32
Bash:
nano ~/wg0.conf
Bash:
[Interface]
Address = 10.0.0.2/24
PrivateKey = <CLIENT_PRIVATE_KEY>
[Peer]
PublicKey = <SERVER_PUBLIC_KEY>
Endpoint = ваш_vps_ip:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25
Save and you're done! All that's left is to run it:
1. Start WireGuard on the server:
Bash:
sudo wg-quick up wg0
Bash:
sudo wg-quick up ~/wg0.conf
Bash:
sudo wg show
To have WireGuard automatically start at system boot, run the following commands on the server:
Bash:
sudo systemctl enable wg-quick@wg0
