How to Add Users in Linux: A Complete Guide
Managing users is a fundamental task for system adminis...
WireGuard is a modern and efficient VPN protocol known for its simplicity and high performance. Unlike older VPN protocols such as OpenVPN or IPsec, WireGuard is lightweight, fast, and secure. If you're looking to secure your internet connection or create a private network for your business, setting up WireGuard on a VPS is a great choice. In this guide, we’ll walk you through the steps to set up WireGuard VPN on your VPS.
Before installing WireGuard, ensure that your VPS is running a Linux-based operating system, such as Ubuntu, CentOS, or Debian. You will also need root privileges to install and configure WireGuard.
ssh root@your-vps-ip
sudo apt update && sudo apt upgrade -y # For Ubuntu/Debian systems sudo yum update -y # For CentOS
WireGuard is available in the official repositories for most Linux distributions. Follow the instructions below to install it:
sudo apt install wireguard
wg --version
sudo yum install epel-release
sudo yum install wireguard-tools
WireGuard uses public and private keys for encryption. You’ll need to generate a pair of keys for your server and clients.
wg genkey | tee /etc/wireguard/privatekey
wg pubkey < /etc/wireguard/privatekey > /etc/wireguard/publickey
cat /etc/wireguard/privatekey cat /etc/wireguard/publickey
Now that you have generated the keys, it’s time to create the configuration file for WireGuard.
/etc/wireguard/wg0.conf
: sudo nano /etc/wireguard/wg0.conf
[Interface] Address = 10.0.0.1/24 # Private IP for the server PrivateKey = [Server Private Key] ListenPort = 51820 [Peer] PublicKey = [Client Public Key] AllowedIPs = 10.0.0.2/32 # IP of the client
Now that the server configuration is in place, it's time to start the WireGuard service.
sudo wg-quick up wg0
sudo systemctl enable wg-quick@wg0
sudo wg show
To allow traffic through the WireGuard VPN tunnel, you’ll need to configure your firewall to allow UDP traffic on the WireGuard port (51820 by default).
sudo ufw allow 51820/udp sudo ufw enable
sudo firewall-cmd --permanent --add-port=51820/udp sudo firewall-cmd --reload
sudo apt install wireguard
wg genkey | tee privatekey | wg pubkey > publickey
sudo nano /etc/wireguard/wg0.conf
[Interface] PrivateKey = [Client Private Key] Address = 10.0.0.2/32 [Peer] PublicKey = [Server Public Key] Endpoint = [Server IP]:51820 AllowedIPs = 0.0.0.0/0 PersistentKeepalive = 25
sudo wg-quick up wg0
Once both the server and client are configured and running, test the connection by pinging the server from the client machine:
ping 10.0.0.1
If everything is configured correctly, you should see successful pings, indicating that your WireGuard VPN connection is active.
Why Choose SurferCloud for Hosting Your VPN Server?
If you're looking for a reliable and secure cloud platform to host your WireGuard VPN server, SurferCloud is a great option. With high-performance servers, robust security features, and global server locations, SurferCloud ensures your VPN setup is fast, secure, and scalable. Whether you're managing a personal VPN or enterprise-level services, SurferCloud offers flexible hosting solutions tailored to your needs.
Learn more by visiting SurferCloud Official Website for more details and services.
Managing users is a fundamental task for system adminis...
Palworld is an exciting game that mixes elements of adv...
Are you new to cloud servers and want to take advantage...