Alpine Linux set up WireGuard VPN server

Setting up a WireGuard VPN server on Alpine Linux can be done by following these steps:

  1. Start by installing the WireGuard package by running the following command:
apk add wireguard-tools wireguard-virt
  1. Create a new directory to store the configuration files by running the following command:
mkdir -p /etc/wireguard
  1. Generate a private key for the server by running the following command:
wg genkey | tee /etc/wireguard/privatekey | wg pubkey > /etc/wireguard/publickey
  1. Create a new configuration file for the server by running the following command:
nano /etc/wireguard/wg0.conf
  1. Add the following content to the configuration file, replacing the IP addresses and subnet with your own values:
[Interface]
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = <server private key>

[Peer]
PublicKey = <client public key>
AllowedIPs = 10.0.0.2/32

  1. Start the WireGuard service by running the following command:
wg-quick up wg0
  1. Add the WireGuard service to the system startup by running the following command:
rc-update add wireguard
  1. To check the status of the WireGuard server, you can run the following command:
wg show
  1. To add a new client you will need to generate a new key pair and add the client’s public key to the server configuration file in the Peer section.
  2. Once the client is configured with the server’s public key, the client can connect to the server using the WireGuard client.

Note: Please make sure that your firewall is configured to allow traffic on UDP port 51820, and that you have a valid IP addresses for the server and clients.

Leave a Comment