Last active
April 2, 2020 08:49
-
-
Save miguelmota/2a6733cd6fe7bd5e631d8909ca4d2e83 to your computer and use it in GitHub Desktop.
Linux wireguard setup server and client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# arch install: https://gist.github.com/miguelmota/0515421a743ac705d40a40ae6d2f1042 | |
sudo -s -H | |
mkdir -p /etc/wireguard/keys | |
cd /etc/wireguard/keys | |
umask 077 | |
wg genkey | tee privatekey | wg pubkey > publickey | |
vim /etc/wireguard/wg0.conf | |
wg-quick up wg0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ubuntu install: https://gist.github.com/miguelmota/7aea0be31895b7d1c148afcadcce0bea | |
sudo -s -H | |
mkdir -p /etc/wireguard/keys | |
cd /etc/wireguard/keys | |
umask 077 | |
wg genkey | tee privatekey | wg pubkey > publickey | |
vim /etc/wireguard/wg0.conf | |
wg-quick up wg0 | |
systemctl enable wg-quick@wg0.service | |
vim /etc/sysctl.conf | |
# uncomment line | |
# net.ipv4.ip_forward=1 | |
sysctl -p | |
cat /proc/sys/net/ipv4/ip_forward # 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Interface] | |
PrivateKey = <client private key> | |
Address = 10.0.0.2/32 | |
DNS = 1.1.1.1 | |
[Peer] | |
PublicKey = <server public key> | |
Endpoint = <server public ip>:51820 | |
AllowedIPs = 0.0.0.0/0 | |
PersistentKeepalive = 25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Interface] | |
PrivateKey = <server private key> | |
Address = 10.0.0.1/24 | |
ListenPort = 51820 | |
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE | |
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE | |
[Peer] | |
PublicKey = <client public key> | |
AllowedIPs = 10.0.0.2/32 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment