From d0a5c4c4f6f60fb7492d79ee1278a9a334264d07 Mon Sep 17 00:00:00 2001 From: Mario Alegre Date: Sat, 19 Dec 2020 23:07:48 -0500 Subject: [PATCH] finished wireguard docs --- linux/wireguard/add-peer.md | 14 ++++++++++++-- linux/wireguard/install.md | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/linux/wireguard/add-peer.md b/linux/wireguard/add-peer.md index d0f010a..68be5e9 100644 --- a/linux/wireguard/add-peer.md +++ b/linux/wireguard/add-peer.md @@ -2,9 +2,19 @@ Say we want to connect two computers via wireguard. We will call them **one** and **two**. -## one -on one, run the following command to add a new host: +## manual + +On one, run the following command to add a new host: ``` sudo wg set wg0 peer ${two_pubkey:?} endpoint ${two_public_ip:?}:${two_port:?} allowed-ips ${two_wg_ip:?}/32 ``` if we also want to be able to refer to the host by an easy to remember name rather than just an IP, we can also add it to `/etc/hosts` +``` +echo -e "${two_wg_ip:?}\t${two_hostname}.wg.alemor.org" >> /etc/hosts +``` + +On two, run the same commands but with one and two switched. + +## automatic + +If you can ssh into an account that has sudo access on the host, simply run the `wg-addpeer` command included in this repo. diff --git a/linux/wireguard/install.md b/linux/wireguard/install.md index 12dca07..0891c4d 100644 --- a/linux/wireguard/install.md +++ b/linux/wireguard/install.md @@ -14,7 +14,7 @@ wg genkey | sudo tee -a wg0.conf | wg pubkey | sudo tee wg0.pubkey ``` open `wg0.conf` in a text editor and add the following lines: ``` -ListenPort = $port +ListenPort = ${wireguard_port:?} SaveConfig = true Address = ${wireguard_ip:?}/24 ```