Alpine Linux set up WireGuard VPN server
Setting up a WireGuard VPN server on Alpine Linux can be done by following these steps:
- Start by installing the WireGuard package by running the following command:
apk add wireguard-tools wireguard-virt- Create a new directory to store the configuration files by running the following command:
mkdir -p /etc/wireguard- Generate a private key for the server by running the following command:
wg genkey | tee /etc/wireguard/privatekey | wg pubkey > /etc/wireguard/publickey- Create a new configuration file for the server by running the following command:
nano /etc/wireguard/wg0.conf- Add the following content to the configuration file, replacing the IP addresses and subnet with your own values:
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = <server private key>
PublicKey = <client public key>
AllowedIPs = 10.0.0.2/32- Start the WireGuard service by running the following command:
wg-quick up wg0- Add the WireGuard service to the system startup by running the following command:
rc-update add wireguard- To check the status of the WireGuard server, you can run the following command:
wg show- 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.
- Once the client is configured with the server's public key, the client can connect to the server using the WireGuard client.
