WireGuard_Installation_and_Configuration_Guide
WireGuard_Installation_and_Configuration_Guide
Introduction
WireGuard is a modern, efficient, and secure VPN solution. This guide provides step-by-step
instructions for setting up WireGuard on your server via the terminal, creating multiple
VPN client configurations, and installing a graphical user interface (GUI) alternative to `wg-
easy`.
2. Install WireGuard:
3. Enable IP Forwarding:
sudo sysctl -p
4. Generate Keys:
umask 077
wg genkey | tee /etc/wireguard/server_private.key | wg pubkey >
/etc/wireguard/server_public.key
[Interface]
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = <ServerPrivateKey>
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j
MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0
-j MASQUERADE
SaveConfig = true
6. Start WireGuard:
sudo wg show
[Peer]
PublicKey = <Client1PublicKey>
AllowedIPs = 10.0.0.2/32
nano client1.conf
[Interface]
PrivateKey = <Client1PrivateKey>
Address = 10.0.0.2/24
DNS = 10.0.0.1
[Peer]
PublicKey = <ServerPublicKey>
Endpoint = <ServerPublicIP>:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25
The script will automatically install and configure WireGuard. You can add or remove peers
and monitor the status through its web-based interface.
Navigate to the provided URL after setup (e.g., `http://<ServerIP>:8080`). Use the default or
set credentials during installation.
Connect a client using the generated configuration. Verify the connection by pinging the
server:
ping 10.0.0.1
sudo wg show
To add a new client, repeat the steps in **Part 2**. To remove a client, delete their `[Peer]`
block from `wg0.conf` and restart WireGuard:
sudo wg-quick down wg0 && sudo wg-quick up wg0
Conclusion
This guide provides a comprehensive setup for WireGuard, including multi-client
configuration and a user-friendly GUI alternative. Follow the steps carefully to ensure a
secure and functional VPN environment.