How to Install WireGuard on Kali Linux
WireGuard is a modern VPN solution that offers fast and secure connections. In this tutorial, we will guide you through the process of installing WireGuard on Kali Linux.
Prerequisites
- Access to a terminal on Kali Linux.
- Superuser privileges (i.e. the ability to use
sudo).
Steps
Update the package list of your Kali Linux system by running the following command:
sudo apt-get updateInstall the necessary packages required for compiling and building WireGuard by running the following command:
sudo apt-get install wireguard-dkms wireguard-tools linux-headers-$(uname -r)This command installs the
wireguard-dkmsandwireguard-toolspackages along with the kernel headers.Confirm that the installation was successful by running the
lsmodcommand. You should seewireguardlisted in the output.lsmod | grep wireguardGenerate a new WireGuard key pair by running the following command:
sudo wg genkey | tee /etc/wireguard/privatekey | wg pubkey > /etc/wireguard/publickeyThis command generates a new private and public key pair for WireGuard and saves them to
/etc/wireguard/privatekeyand/etc/wireguard/publickeyon your system.Create a new configuration file for your WireGuard instance. The configuration file is a text file that contains the details required to connect to a WireGuard server. You can create this file manually in your preferred text editor (e.g. Nano), or by running:
sudo nano /etc/wireguard/wg0.confOpen the new configuration file (
/etc/wireguard/wg0.conf), and add the following content:[Interface] PrivateKey = [private key output from step 4] Address = 10.0.0.2/24 [Peer] PublicKey = [public key output from step 4] AllowedIPs = 0.0.0.0/0 Endpoint = [WireGuard server IP]:51820 PersistentKeepalive = 21This configures a new WireGuard interface (
[Interface]) and sets the private key, IP address, and a port number for the server. The[Peer]section specifies the server endpoint, public key, allowed IPs, and a persistent keep-alive.Start the WireGuard interface by running the following command:
sudo wg-quick up wg0This command starts the
wg0interface created in the previous step.Confirm that the WireGuard interface is working by running the following command:
sudo wg showThis command displays the current status of the WireGuard interface.
Congratulations! You have successfully installed and configured WireGuard on Kali Linux. You can now use the interface to connect to a WireGuard VPN server.