Wireguard

in #wireguard4 years ago

Wireguard Set Up

I been thru wireguard setup with a lot hurdles such as
-Having issue to connect to server
-Able to connect to server but having issue to connect to internet
-Able to connect to internet but IP still leaking

Noting my set up config here so that you can avoid the issue :)

Ubuntu 18.4 Install

sudo apt install wireguard

Server Set Up

Generate key
wg genkey | tee privatekey | wg pubkey > publickey

create conf file
sudo vi /etc/wireguard/wg0.conf

[Interface]
PrivateKey = <Private Key>
Address = 10.0.0.1/24
Address = fd86:ea04:1115::1/64
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o ens4 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -A FORWARD -o %i -j ACCEPT; ip6tables -t nat -A POSTROUTING -o ens4 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o ens4 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -D FORWARD -o %i -j ACCEPT; ip6tables -t nat -D POSTROUTING -o ens4 -j MASQUERADE
ListenPort = 51820
SaveConfig = true

[Peer]
PublicKey = <Client1's Public Key>
AllowedIPs = 10.0.0.3/32


[Peer]
PublicKey = <Client2's Public Key>
AllowedIPs = 10.0.0.2/32

.

Start Up wg0
wg-quick up wg0

Note

  • "eth0" is the name of connection that connect to internet. Set accordingly or you will unable to connect to internet

Client Set Up

Generate
wg genkey | tee client1_private_key | wg pubkey > client1_public_key

conf file:

[Interface]
Address = 10.0.0.3/32
PrivateKey = <Client Private Key>
DNS = 1.1.1.1

[Peer]
PublicKey = <Server Public Key>
Endpoint = <Server Public url/ip>:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 21

Coin Marketplace

STEEM 0.22
TRX 0.26
JST 0.040
BTC 98454.72
ETH 3466.95
USDT 1.00
SBD 3.20