WireGuard is a popular VPN (Virtual Private Network) software which provides fast and secure connectivity to users. In this tutorial, we will guide you on how to install WireGuard on nixOS Latest.
Open a terminal and make sure that your system is up-to-date with the latest package updates.
sudo nix-channel --update && sudo nixos-rebuild switch
Use the following command to install the WireGuard package:
sudo nix-env -i wireguard
Generate a private and a public key using the following commands.
sudo umask 077
sudo mkdir -p /etc/wireguard
sudo wg genkey | sudo tee /etc/wireguard/privatekey | wg pubkey | sudo tee /etc/wireguard/publickey
Create the configuration file /etc/wireguard/wg0.conf
and edit it as follows:
sudo vim /etc/wireguard/wg0.conf
[Interface]
Address = 10.10.10.1/24
PrivateKey = <SERVER_PRIVATE_KEY>
[Peer]
AllowedIPs = 10.10.10.2/32
PublicKey = <CLIENT_PUBLIC_KEY>
Replace <SERVER_PRIVATE_KEY>
with your server's private key generated in step 3, and <CLIENT_PUBLIC_KEY>
with the public key of the client that you wish to connect to.
Use the following commands to start and enable the WireGuard service:
sudo systemctl enable wg-quick@wg0
sudo systemctl start wg-quick@wg0
In this tutorial, we have shown you how to install WireGuard on nixOS Latest. To ensure that the installation is complete, verify that the service is running by running the following command:
sudo systemctl status wg-quick@wg0
That's it! You are now ready to use your secure VPN connection.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!