# Setting up Wireguard ## Steps ### Step 1: Install the dependencies Here you will be needing to install the packages that wireguard needs to work. ```bash ## Debian or Ubuntu sudo apt install wireguard ## RHEL-based sudo dnf install wireguard-tools ``` ### Step 2: Setup wireguard interface configs This step requires you to do multiple things: 1. Generate a private & public key for both the server and client 2. Create a wireguard interface config for both the server & client - In this step you will need to choose an IP for both server and client (the usual choice is on a subnet included in 10.0.0.0/8 (ex: 10.200.1.x/24)). #### A: Create Pub & Priv keys (server & client) Here we will generate a private and public key for both the server & client. ```bash ## Much of this will be inline commands with pipes, but feel free to seperate them if you feel you need to. ### Generate pub and priv key for server wg genkey | tee wg0-server-privkey | wg pubkey > wg0-server-pubkey ### Generate pub and priv key for first client wg genkey | tee wg0-client-privkey | wg pubkey > wg0-client-pubkey ## This is the networks you want your client to have access to (configured in the client's wg0.conf) networks=10.200.1.0/24,192.168.1.0/24 ## This is just my example IPs for a basic setup, you can use your own (it won't matter as long as they are valid addresses) ### The server IP needs to be one that will be on the network 10.200.1.0/24 (with the /24 at the end signifying the subnet mask) server_ip=10.200.1.1/24 ### While you can just use 10.200.1.0/24 on the AllowedIPs, it will cause issues when you are wanting to setup more peers/clients to use that interface. ### to be able to provide VPN connections for multiple clients you will need to scope it down to a specific IP using the /32 netmask ### otherwise all connections will have issues when you try to reload the wg interface config (as it will try to forward all traffic accross all peers) client_ip=10.200.1.2 masquerade_interface=eno1 # You will need to find out what interface you want/need to use (just look it up with "ip address" or "ifconfig" (whatever your util is)) ### This will actually generate the config using bash, but feel free to do it manually (for your choice of IPs you will need to make sure you cat > wg0-server.conf < wg0-client.conf <