Downoad Wireguard

sudo add-apt-repository ppa:wireguard/wireguard

$ sudo apt-get update

$ sudo apt-get install wireguard

...
wireguard:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/4.4.0-1099-aws/updates/dkms/

depmod....

DKMS: install completed.
Setting up wireguard-tools (0.0.20191219-wg1~xenial) ...
Setting up wireguard (0.0.20191219-wg1~xenial) ...

Generate private, public key

$ umask 077
$ wg genkey | tee privatekey | wg pubkey > publickey

Add config

config content

[Interface]
PrivateKey = <private key>
Address = <ipv4>/24, <ipv6 prefix>
ListenPort = 51820
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
SaveConfig = true
sudo vim /etc/wireguard/wg0.conf

allow inet port

sudo ufw allow 51820/udp
sudo ufw enable
sudo ufw status verbose

Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip

To                         Action      From
--                         ------      ----
51820/udp                  ALLOW IN    Anywhere
51820/udp (v6)             ALLOW IN    Anywhere (v6)

start wire guard

$ wg-quick up wg0
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 172.26.6.229/24 dev wg0
[#] ip -6 address add fe80::4e2:9cff:fe15:f61e/64 dev wg0
[#] ip link set mtu 8921 up dev wg0
[#] iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

check wg status

$ sudo wg show
interface: wg0
  public key: <public key>
  private key: (hidden)
  listening port: 51820

$ ifconfig wg0
wg0       Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:172.26.6.229  P-t-P:172.26.6.229  Mask:255.255.255.0
          inet6 addr: fe80::4e2:9cff:fe15:f61e/64 Scope:Link
          UP POINTOPOINT RUNNING NOARP  MTU:8921  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:2 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)