WireGuard® is an extremely simple yet fast and modern VPN that utilizes state-of-the-art cryptography. It aims to be faster, simpler, leaner, and more useful than IPsec while avoiding massive headaches. It intends to be considerably more performant than OpenVPN. WireGuard is designed as a general-purpose VPN for running on embedded interfaces and super computers alike, fit for many different circumstances. Initially released for the Linux kernel, it is now cross-platform (Windows, macOS, BSD, iOS, Android) and widely deployable.
|comment (string; Default: )||Short description of the tunnel.|
|disabled (yes | no; Default: no)||Enables/disables the tunnel.|
|listen-port (integer; Default: 13231)||Port for WireGuard service to listen on for incoming sessions.|
|mtu (integer [0..65536]; Default: 1420)||Layer3 Maximum transmission unit.|
|name (string; Default: )||Name of the tunnel.|
|private-key (string; Default: )||A base64 private key. If not specified, it will be automatically generated upon interface creation.|
|public-key (string)||A base64 public key is calculated from the private key.|
|running (yes | no)|
Whether the interface is running.
|allowed-address (IP/IPv6 prefix; Default: )||List of IP (v4 or v6) addresses with CIDR masks from which incoming traffic for this peer is allowed and to which outgoing traffic for this peer is directed. The catch-all 0.0.0.0/0 may be specified for matching all IPv4 addresses, and ::/0 may be specified for matching all IPv6 addresses.|
|comment (string; Default: )||Short description of the peer.|
|disabled (yes | no; Default: no)||Enables/disables the peer.|
|endpoint-address (IP/Hostname; Default: )||The IP address or hostname. It is used by WireGuard to establish a secure connection between two peers.|
|endpoint-port (integer:0..65535; Default: )||The Endpoint port is the UDP port on which a WireGuard peer listens for incoming traffic.|
|interface (string; Default: )||Name of the WireGuard interface the peer belongs to.|
|persistent-keepalive (integer:0..65535; Default: 0)||A seconds interval, between 1 and 65535 inclusive, of how often to send an authenticated empty packet to the peer for the purpose of keeping a stateful firewall or NAT mapping valid persistently. For example, if the interface very rarely sends traffic, but it might at anytime receive traffic from a peer, and it is behind NAT, the interface might benefit from having a persistent keepalive interval of 25 seconds.|
|preshared-key (string; Default: )||A base64 preshared key. Optional, and may be omitted. This option adds an additional layer of symmetric-key cryptography to be mixed into the already existing public-key cryptography, for post-quantum resistance. Also can be generated automatically or entered manually, when the key is provided by the system administrator.|
|private-key (auto/none; Default: none)||Can be generated automatically or entered manually, when the key is provided by the system administrator.|
public-key (string; Default: )
The remote peer's calculated public key. It also can be generated if private-key is specified.
Will show already created Peer configuration and generate a QR code for easier peer setup on a client device. Does not affect the WireGuard Server.
Used for the client-server setup scenario, when the configuration is imported using a qr code for a client:
client-address (IP/IPv6 prefix; Default: )
When imported using a qr code for a client (for example, a phone), then this address for the wg interface is set on that device.
client-dns (IP/IPv6 prefix; Default: )
Specify when using WireGuard Server as a VPN gateway for peer traffic.
client-endpoint (IP/IPv6 prefix; Default: )
The IP address and port number of the WireGuard Server.
client-keepalive (integer:0..65535; Default: 0)
Same as persistent-keepalive but from peer side.
client-listen-port (integer:0..65535; Default: )
The local port upon which this WireGuard tunnel will listen for incoming traffic from peers, and the port from which it will source outgoing packets.
Minimum parameters must be specified for importing on the client device by QR-code/file.
interface: wireguard1 public-key: v/oIzPyFm1FPHrqhytZgsKjU7mUToQHLrW+Tb5e601M= private-key: KMwxqe/iXAU8Jn9dd1o5pPdHep2blGxNWm9I944/I24= allowed-address: 192.168.88.3/24 client-address: 192.168.88.3/32 client-endpoint: example.com:13231
|current-endpoint-address (IP/IPv6)||The most recent source IP address of correctly authenticated packets from the peer.|
|current-endpoint-port (integer)||The most recent source IP port of correctly authenticated packets from the peer.|
|last-handshake (integer)||Time in seconds after the last successful handshake.|
|rx (integer)||The total amount of bytes received from the peer.|
|tx (integer)||The total amount of bytes transmitted to the peer.|
Site to Site WireGuard tunnel
Consider setup as illustrated below. Two remote office routers are connected to the internet and office workstations are behind NAT. Each office has its own local subnet, 10.1.202.0/24 for Office1 and 10.1.101.0/24 for Office2. Both remote offices need secure tunnels to local networks behind routers.
WireGuard interface configuration
First of all, WireGuard interfaces must be configured on both sites to allow automatic private and public key generation. The command is the same for both routers:
Now when printing the interface details, both private and public keys should be visible to allow an exchange.
Any private key will never be needed on the remote side device - hence the name private.
Peer configuration defines who can use the WireGuard interface and what kind of traffic can be sent over it. To identify the remote peer, its public key must be specified together with the created WireGuard interface.
IP and routing configuration
Lastly, IP and routing information must be configured to allow traffic to be sent over the tunnel.
The default RouterOS firewall will block the tunnel from establishing properly. The traffic should be accepted in the "input" chain before any drop rules on both sites.
Additionally, it is possible that the "forward" chain restricts the communication between the subnets as well, so such traffic should be accepted before any drop rules as well.
RoadWarrior WireGuard tunnel
Add a new WireGuard interface and assign an IP address to it.
Adding a new WireGuard interface will automatically generate a pair of private and public keys. You will need to configure the public key on your remote devices. To obtain the public key value, simply print out the interface details.
For the next steps, you will need to figure out the public key of the remote device. Once you have it, add a new peer by specifying the public key of the remote device and allowed addresses that will be allowed over the WireGuard tunnel.
If you have default or strict firewall configured, you need to allow remote device to establish the WireGuard connection to your device.
To allow remote devices to connect to the RouterOS services (e.g. request DNS), allow the WireGuard subnet in input chain.
Or simply add the WireGuard interface to "LAN" interface list.
Download the WireGuard application from the App Store. Open it up and create a new configuration from scratch.
First of all give your connection a "Name" and choose to generate a keypair. The generated public key is necessary for peer's configuration on RouterOS side.
Specify an IP address in "Addresses" field that is in the same subnet as configured on the server side. This address will be used for communication. For this example, we used 192.168.100.1/24 on the RouterOS side, you can use 192.168.100.2 here.
If necessary, configure the DNS servers. If allow-remote-requests is set to yes under IP/DNS section on the RouterOS side, you can specify the remote WireGuard IP address here.
Click "Add peer" which reveals more parameters.
The "Public key" value is the public key value that is generated on the WireGuard interface on RouterOS side.
"Endpoint" is the IP or DNS with port number of the RouterOS device that the iOS device can communicate with over the Internet.
"Allowed IPs" are set to 0.0.0.0/0 to allow all traffic to be sent over the WireGuard tunnel.
Windows 10 configuration
Download WireGuard installer from Wireguard
Run as Administrator.
Press Ctrl+n to add new empty tunnel, add name for interface, Public key should be auto generated copy it to RouterOS peer configuration.
Add to server configuration, so full configuration looks like this (keep your auto generated PrivateKey in [Interface] section:
Save and Activate