WireGuard VPN MikroTik Configuration Guide

WireGuard (WireGuard VPN MikroTik) is a modern VPN protocol that became available in MikroTik starting with RouterOS v7. It combines simplicity, high speed, and modern cryptography. This makes it an excellent choice for connecting offices or remote users.

In this guide, we’ll set up a VPN tunnel between two MikroTik routers:

  • Router A (main office, network 192.168.1.0/24)
  • Router B (branch office, network 192.168.2.0/24)

For each step, both CLI commands and Winbox configuration will be shown.

Step 1. Creating the WireGuard VPN MikroTik Interface

🔹 CLI

/interface wireguard add name=wg1 listen-port=51820

🔹 Winbox

  1. Open Interfaces → WireGuard.
  2. Click + (Add) → select WireGuard.
  3. Specify:
    • Name: wg1 (You can specify your own name)
    • Listen Port: 51820 (You can specify your own port)
  4. Click OK.
WireGuard VPN MikroTik

Step 2. Viewing Keys

🔹 CLI

/interface wireguard print

Copy the Public Key — it needs to be provided to the other router.

🔹 Winbox

  1. Open the Interfaces → WireGuard tab.
  2. Select wg1.
  3. Copy the key from the Public Key field.
WireGuard VPN MikroTik

Step 3. Adding Peer (Partner)

🔹 CLI (Router A)

/interface wireguard peers add interface=wg1 \
    public-key="PUBKEY_B" \
    allowed-address=10.10.10.2/32 \
    endpoint-address=IP_RouterB \
    endpoint-port=51820

🔹 CLI (Router B)

/interface wireguard peers add interface=wg1 \
    public-key="PUBKEY_A" \
    allowed-address=10.10.10.1/32 \
    endpoint-address=IP_RouterA \
    endpoint-port=51820

🔹 Winbox (on each router)

  1. Go to WireGuard → Peers → +.
  2. Fill in:
    • Interface: wg1
    • Public Key: public key of the other router
    • Allowed Address: 10.10.10.2/32 (or 10.10.10.1/32 on the second)
    • Endpoint Address: external IP of the other router
    • Endpoint Port: 51820
  3. Click OK.
WireGuard VPN MikroTik

Step 4. Assigning Tunnel IP Addresses

🔹 CLI (Router A)

/ip address add address=10.10.10.1/30 interface=wg1

🔹 CLI (Router B)

/ip address add address=10.10.10.2/30 interface=wg1

🔹 Winbox

  1. Open IP → Addresses → +.
  2. On Router A: 10.10.10.1/30 → interface wg1.
  3. On Router B: 10.10.10.2/30 → interface wg1.

Step 5. Configuring Routes

🔹 CLI (Router A)

/ip route add dst-address=192.168.2.0/24 gateway=10.10.10.2

🔹 CLI (Router B)

/ip route add dst-address=192.168.1.0/24 gateway=10.10.10.1

🔹 Winbox

  1. Open IP → Routes → +.
  2. On Router A:
    • Dst. Address: 192.168.2.0/24
    • Gateway: 10.10.10.2
  3. On Router B:
    • Dst. Address: 192.168.1.0/24
    • Gateway: 10.10.10.1

Step 6. Allowing Port in Firewall

🔹 CLI

/ip firewall filter add chain=input action=accept protocol=udp dst-port=51820

🔹 Winbox

  1. Open IP → Firewall → Filter Rules → +.
  2. Specify:
    • Chain: input
    • Protocol: udp
    • Dst. Port: 51820
    • Action: accept

Testing the Configuration

  1. Perform ping from Router A to 10.10.10.2 and vice versa.
  2. Perform ping between hosts in networks 192.168.1.0/24 ↔ 192.168.2.0/24.
  3. In Winbox → WireGuard → Peers, check the Last Handshake field — it will show if there’s an active connection.

[amazon_auto_links id=”8218″]

Conclusion

WireGuard VPN MikroTik is a modern VPN protocol that can be configured literally in a few minutes. In this article, we built a tunnel between two offices using both CLI and Winbox, so anyone can choose their preferred working method.

WireGuard should be considered as the primary VPN protocol for RouterOS 7 thanks to its simplicity, security, and performance.

0 0 votes
Rating
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Scroll to Top