Wireguard is a fast, secure, versatile, and easy to set-up VPN Software which (luckily) is unclided in MikroTik's RouterOS since v7.
First, set up the router:
[archy@MikroTik] > interface/wireguard/add comment="wireguard wan" listen-port=13231 name=wg0
Get the autogenerated public key for the wireguard interface and save it in a variable:
[archy@stealth-falcon ~]$ gateway_publickey=$(ssh archy@gw.archyslife.lan 'interface/wireguard/print' | grep -iE 'public-key' | sed -s 's/public-key=//g' | sed -s 's/"//g' | sed -s 's/\ //g')
By default, the 'wireguard-tools' package is not installed on fedora so we have to install it:
[archy@stealth-falcon ~]$ sudo dnf -4y --refresh install wireguard-tools
Also, ensure systemd-resolved is running:
[archy@stealth-falcon ~]$ sudo systemctl enable --now systemd-resolved.service
Create the private and public keys:
[archy@stealth-falcon ~]$ client_privatekey=$(wg genkey)
[archy@stealth-falcon ~]$ client_publickey=$(echo $client_privatekey | wg pubkey)
Now that we have generated the public and private keys (and stored them in variables in the shell session), create the configuration file on the client:
[archy@stealth-falcon ~]$ cat << EOF | sudo tee /etc/wireguard/home.conf
[Interface]
Address = 172.31.202.10/32
DNS = 172.31.202.254
PrivateKey = $client_privatekey
[Peer]
Publickey = $gateway_publickey
AllowedIPs = 0.0.0.0/0
Endpoint = vpn.archyslife.lan:13231
EOF
Now add all peers to the router:
[archy@MikroTIk] > interface/wireguard/peers/add interface=wg0 allowed-address=172.31.202.10/32 comment="archy - laptop" public-key="client_publickey_here"
From here on out, you can test your wireguard connection using 'wg-quick':
[archy@stealth-falcon ~]$ sudo wg-quick up home
Once the tunnel is up, all your traffic should be routed through the wireguard tunnel.
Feel free to comment and / or suggest a topic.
Comments
Post a Comment