Last active
March 12, 2022 22:03
-
-
Save atomlab/403367605b9334e3172bf94cfb7f7451 to your computer and use it in GitHub Desktop.
Revisions
-
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -51,7 +51,7 @@ Reboot server after network setup, that make sure that interface wg0 append succ ## Setup iptables and NAT on Wireguard server For masquerading all traffic to internet we should setup iptables. For setup iptables we use **ferm**. 1. Enable forward traffic -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -69,7 +69,7 @@ net.ipv4.ip_forward = 1 Create file ``` vim /etc/ferm/ferm.d/wg_nat.conf ``` _/etc/ferm/ferm.d/wg_nat.conf_ -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -51,7 +51,7 @@ Reboot server after network setup, that make sure that interface wg0 append succ ## Setup iptables and NAT on Wireguard server For masquerading all trafic to internet we should setup iptables. For setup iptables we use **ferm**. 1. Enable forward traffic -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 50 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -49,6 +49,56 @@ iface wg0 inet static Reboot server after network setup, that make sure that interface wg0 append successful ## Setup iptables and NAT on Wireguard server For forwarding all trafic to internet we should setup iptables frowarding and NAT. For setup iptables we use **ferm**. 1. Enable forward traffic ``` # echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf # sysctl -p net.ipv4.ip_forward = 1 ``` 2. Install [ferm](http://ferm.foo-projects.org/) ``` # apt install ferm ``` Create file ``` vim /etc/ferm/ferm.d/nat.conf ``` _/etc/ferm/ferm.d/wg_nat.conf_ ``` table nat { chain POSTROUTING { outerface eth0 MASQUERADE; } } table filter { chain INPUT { # Allow wireguard ports proto (tcp udp) dport 51820 ACCEPT; } chain FORWARD { # Allow forward only 192.168.120.0/24 clients networks saddr 192.168.120.0/24 daddr 0.0.0.0/0 ACCEPT; } } ``` Apploy ferm setting ``` # ferm /etc/ferm/ferm.conf # ``` ## Android client setup [Install wg client for Android](https://www.wireguard.com/install/) -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Wireguard setup on Ubuntu 16.04/18.04 ## Install ``` -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 21 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -83,6 +83,27 @@ ListenPort = 51820 PublicKey = cmfyWxlXbFKpdtnsI2a0WF2bu7/MZRcV+Kf6aF/osxY= # public key generated on client side AllowedIPs = 192.168.120.2/32 # ip address allowed to connect with this public key ``` Apply configuration on server ``` # wg setconf wg0 /etc/wireguard/wg0.conf ``` Check connections ``` # wg interface: wg0 public key: J5s0i4x9XuuNylQlfEGrZoFgV1Id48qZoPvjVS+sBDU= private key: (hidden) listening port: 51820 peer: cmfyWxlXbFKpdtnsI2a0WF2bu7/MZRcV+Kf6aF/osxY= endpoint: 176.34.241.253:53745 allowed ips: 192.168.120.2/32 latest handshake: 26 seconds ago transfer: 2.20 MiB received, 47.72 MiB sent ``` ## Troubleshooting -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 2 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -80,13 +80,10 @@ PrivateKey = 2B5zWbvkWxovKZsbdyLPLdxQlwGDDsocdhaP2w0nwnE= ListenPort = 51820 [Peer] PublicKey = cmfyWxlXbFKpdtnsI2a0WF2bu7/MZRcV+Kf6aF/osxY= # public key generated on client side AllowedIPs = 192.168.120.2/32 # ip address allowed to connect with this public key ``` ## Troubleshooting ``` -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -84,9 +84,8 @@ PublicKey = cmfyWxlXbFKpdtnsI2a0WF2bu7/MZRcV+Kf6aF/osxY= AllowedIPs = 192.168.120.2/32 ``` _cmfyWxlXbFKpdtnsI2a0WF2bu7/MZRcV+Kf6aF/osxY=_ it's public keys generated on client side _192.168.120.2/32_ - ip address allowed to connect with this public key ## Troubleshooting -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -85,6 +85,7 @@ AllowedIPs = 192.168.120.2/32 ``` `cmfyWxlXbFKpdtnsI2a0WF2bu7/MZRcV+Kf6aF/osxY=` it's public keys generated on client side `192.168.120.2/32` - ip address allowed to connect with this public key ## Troubleshooting -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 16 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -71,6 +71,22 @@ Endpoint: 163.172.161.5:51820 5. Press button **Save** on the bottom 6. Enable vpn connection # Add peer to wireguard config on server _/etc/wireguard/wg0.conf_ ``` [Interface] PrivateKey = 2B5zWbvkWxovKZsbdyLPLdxQlwGDDsocdhaP2w0nwnE= ListenPort = 51820 [Peer] PublicKey = cmfyWxlXbFKpdtnsI2a0WF2bu7/MZRcV+Kf6aF/osxY= AllowedIPs = 192.168.120.2/32 ``` `cmfyWxlXbFKpdtnsI2a0WF2bu7/MZRcV+Kf6aF/osxY=` it's public keys generated on client side `192.168.120.2/32` - ip address allowed to connect with this public key ## Troubleshooting ``` -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -78,10 +78,12 @@ Endpoint: 163.172.161.5:51820 RTNETLINK answers: Operation not supported ``` Install kernel headers ``` # apt -y install linux-headers-$(uname -r) # dpkg-reconfigure wireguard-dkms ``` Reboot system # Links https://tunfish.org/doc/sandbox/troubleshooting.html -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -62,7 +62,7 @@ Private key: (GENERATE) Address: 192.168.120.2/32 DNS server: 1.1.1.1 ``` 4. Press **ADD PEER** button bellow ``` Public key: J5s0i4x9XuuNylQlfEGrZoFgV1Id48qZoPvjVS+sBDU= Allowed IPs: 0.0.0.0/0 -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 18 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,18 +2,26 @@ ## Install ``` # sudo add-apt-repository ppa:wireguard/wireguard # sudo apt-get update # sudo apt-get install wireguard ``` ## Generate keys ``` # cd /etc/wireguard/ # umask 077 # wg genkey > privatekey # wg pubkey < privatekey > publickey ``` Check created keys ``` # cat privatekey 2B5zWbvkWxovKZsbdyLPLdxQlwGDDsocdhaP2w0nwnE= # cap publickey J5s0i4x9XuuNylQlfEGrZoFgV1Id48qZoPvjVS+sBDU= ``` ## Wireguard config @@ -66,13 +74,13 @@ Endpoint: 163.172.161.5:51820 ## Troubleshooting ``` # ip link add dev wg0 type wireguard RTNETLINK answers: Operation not supported ``` ``` # apt -y install linux-headers-$(uname -r) # dpkg-reconfigure wireguard-dkms ``` # Links -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 17 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -45,9 +45,23 @@ Reboot server after network setup, that make sure that interface wg0 append succ [Install wg client for Android](https://www.wireguard.com/install/) 1. Press button (**+**) 2. Select **Create from scratch** 3. Setup interface ``` Name: wg_vpn Private key: (GENERATE) Address: 192.168.120.2/32 DNS server: 1.1.1.1 ``` 4. Press **ADD PERR** button bellow ``` Public key: J5s0i4x9XuuNylQlfEGrZoFgV1Id48qZoPvjVS+sBDU= Allowed IPs: 0.0.0.0/0 Endpoint: 163.172.161.5:51820 ``` 5. Press button **Save** on the bottom 6. Enable vpn connection ## Troubleshooting -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -43,7 +43,9 @@ Reboot server after network setup, that make sure that interface wg0 append succ ## Android client setup [Install wg client for Android](https://www.wireguard.com/install/) 1. Put button (*+*) -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -43,7 +43,7 @@ Reboot server after network setup, that make sure that interface wg0 append succ ## Android client setup [Install wg client for Android](https://play.google.com/store/apps/details?id=com.wireguard.android) -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -39,7 +39,13 @@ iface wg0 inet static post-down ip link del $IFACE ``` Reboot server after network setup, that make sure that interface wg0 append successful ## Android client setup [Install wg client for Android] (https://play.google.com/store/apps/details?id=com.wireguard.android) ## Troubleshooting -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -39,6 +39,7 @@ iface wg0 inet static post-down ip link del $IFACE ``` Reboot after network setup, that make sure that interface wg0 append successful ## Troubleshooting -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -26,6 +26,19 @@ PrivateKey = 2B5zWbvkWxovKZsbdyLPLdxQlwGDDsocdhaP2w0nwnE= ListenPort = 51820 ``` ## Interface setup _/etc/network/interfaces.d/wg0.cfg_ ``` auto wg0 iface wg0 inet static address 192.168.120.1 netmask 255.255.255.0 pre-up ip link add $IFACE type wireguard pre-up wg setconf $IFACE /etc/wireguard/$IFACE.conf post-down ip link del $IFACE ``` ## Troubleshooting -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 25 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,21 +1,41 @@ # Wireguard setup on Ubuntu 18.04 ## Install ``` sudo add-apt-repository ppa:wireguard/wireguard sudo apt-get update sudo apt-get install wireguard ``` ## Generate keys ``` cd /etc/wireguard/ umask 077 wg genkey > privatekey wg pubkey < privatekey > publickey ``` ## Wireguard config _/etc/wireguard/wg0.conf_ ``` [Interface] PrivateKey = 2B5zWbvkWxovKZsbdyLPLdxQlwGDDsocdhaP2w0nwnE= ListenPort = 51820 ``` ## Troubleshooting ``` ip link add dev wg0 type wireguard RTNETLINK answers: Operation not supported ``` ``` apt -y install linux-headers-$(uname -r) dpkg-reconfigure wireguard-dkms ``` -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -20,4 +20,4 @@ dpkg-reconfigure wireguard-dkms ``` # Links https://tunfish.org/doc/sandbox/troubleshooting.html -
atomlab revised this gist
Jun 30, 2019 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -17,4 +17,7 @@ RTNETLINK answers: Operation not supported ``` $ apt -y install linux-headers-$(uname -r) dpkg-reconfigure wireguard-dkms ``` # Links (https://tunfish.org/doc/sandbox/troubleshooting.html) -
atomlab created this gist
Jun 30, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ # Wireguard setup on Ubuntu 18.04 ``` $ sudo add-apt-repository ppa:wireguard/wireguard $ sudo apt-get update $ sudo apt-get install wireguard ``` ## Troubleshooting ``` $ ip link add dev wg0 type wireguard RTNETLINK answers: Operation not supported ``` ``` $ apt -y install linux-headers-$(uname -r) dpkg-reconfigure wireguard-dkms ```