Difference between revisions of "Configure WireGuard VPN"
From Organic Design wiki
m |
(server conf) |
||
Line 10: | Line 10: | ||
<source lang="bash"> | <source lang="bash"> | ||
wg genkey | sudo tee /etc/wireguard/privatekey | wg pubkey | sudo tee /etc/wireguard/publickey | wg genkey | sudo tee /etc/wireguard/privatekey | wg pubkey | sudo tee /etc/wireguard/publickey | ||
+ | </source> | ||
+ | |||
+ | |||
+ | <source> | ||
+ | [Interface] | ||
+ | PrivateKey = PRIVATEKEY_FILE_CONTENTS | ||
+ | Address = 10.xx.xx.1/24 | ||
+ | Address = fdxx:xxxx:xxxx::1/64 | ||
+ | ListenPort = 51820 | ||
+ | SaveConfig = true | ||
+ | PostUp = iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE | ||
+ | PostUp = ip6tables -t nat -I POSTROUTING -o eth0 -j MASQUERADE | ||
+ | PreDown = iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE | ||
+ | PreDown = ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE | ||
</source> | </source> |
Revision as of 23:38, 22 March 2022
We've recently changed from OpenVPN to WireGuard for our VPN solution. We use a VPN so that we can be sure our local browsing traffic's private even when we're on an insecure connection like a hotel or airport. Of course there are many solutions available such as ProtonVPN or RiseupVPN, but we like to be independent for our security, and also this allows us to customise the ports and locations and have higher bandwidth than a shared solution.
These first steps need to be done on the same way on the server and on the clients. First install WireGuard which is in the default Debian repositories, and we'll also need resolvconf.
sudo apt install wireguard resolvconf
Then create a key-pair that are called privatekey and publickey in the /etc/wireguard directory.
wg genkey | sudo tee /etc/wireguard/privatekey | wg pubkey | sudo tee /etc/wireguard/publickey
[Interface]
PrivateKey = PRIVATEKEY_FILE_CONTENTS
Address = 10.xx.xx.1/24
Address = fdxx:xxxx:xxxx::1/64
ListenPort = 51820
SaveConfig = true
PostUp = iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE
PostUp = ip6tables -t nat -I POSTROUTING -o eth0 -j MASQUERADE
PreDown = iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
PreDown = ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE