15/11/2026

MikroTik WireGuard: Site-to-Site VPN Between Branches

Picture a company with two offices. The accounting software lives at headquarters and the branch needs to reach it. A lot of teams still solve this with a port forward or an old VPN like PPTP. That means an important server sits straight on the internet, or traffic goes over weak encryption.

Picture a company with two offices. The accounting software lives at headquarters and the branch needs to reach it. A lot of teams still solve this with a port forward or an old VPN like PPTP. That means an important server sits straight on the internet, or traffic goes over weak encryption.

The clean way is a site-to-site tunnel. When the ITcorv team connects branch offices on MikroTik, WireGuard is usually what we use. It's light, fast, and the config is short. This post shows how to set up MikroTik WireGuard between two sites on RouterOS v7.

What is WireGuard?

WireGuard is a modern VPN built into MikroTik since RouterOS v7. It runs over UDP and uses key pairs instead of usernames and passwords. Each side has a private key that never leaves the router, and a public key that you give to the other side.

A few terms you need:

  • WireGuard interface: a virtual interface on the router. Traffic through it gets encrypted and sent to the other side over UDP. On MikroTik the default port is 13231 and the default MTU is 1420.
  • Peer: the other end of the tunnel, identified by its public key.
  • allowed-address: the addresses allowed to come in from this peer, and the addresses whose traffic should be sent to this peer. So it's a filter and it also decides what goes into the tunnel.
  • Endpoint: the other side's IP address or hostname, plus its port.

One important point: WireGuard has no real server and client. Both sides are equal. In practice, though, one side needs a fixed address so the other can find it.

Our scenario

  • Headquarters (HQ): has a fixed public IP, shown here as 203.0.113.10. Its LAN is 10.10.10.0/24.
  • Branch: no fixed IP, sits behind the ISP's NAT. Its LAN is 10.20.10.0/24.
  • Tunnel network: 10.255.255.0/30. HQ is .1, the branch is .2.
  • Internet on both sides is on ether1.

Swap the addresses for your own. Just make sure the two LANs don't overlap. If both sides are 192.168.88.0/24, routing won't work.

MikroTik WireGuard sample config

Before you start, take a backup and turn on Safe Mode (Ctrl+X in the terminal).

1) Create the interface on both routers

Same line on both:

routeros@itcorv:~
/interface wireguard
add listen-port=13231 name=wg-s2s

MikroTik generates the private and public keys for you. See the public key with:

routeros@itcorv:~
/interface wireguard print

Copy each router's public-key and give it to the other router. Never send the private key anywhere. You don't need to.

2) IP address on the tunnel

HQ:

routeros@itcorv:~
/ip address
add address=10.255.255.1/30 interface=wg-s2s

Branch:

routeros@itcorv:~
/ip address
add address=10.255.255.2/30 interface=wg-s2s

3) Define the peers

HQ, which waits for the branch to connect:

routeros@itcorv:~
/interface wireguard peers
add interface=wg-s2s name=branch1 \
    public-key="<branch public key>" \
    allowed-address=10.255.255.2/32,10.20.10.0/24 \
    responder=yes

Branch, which starts the connection:

routeros@itcorv:~
/interface wireguard peers
add interface=wg-s2s name=hq \
    public-key="<HQ public key>" \
    endpoint-address=203.0.113.10 endpoint-port=13231 \
    allowed-address=10.255.255.1/32,10.10.10.0/24 \
    persistent-keepalive=25s

A few notes:

  • There's no endpoint on HQ because the branch IP isn't fixed. Once the branch connects, HQ learns its address.
  • responder=yes means HQ never starts the connection, it only answers. That way it doesn't keep chasing an old address.
  • persistent-keepalive=25s on the branch sends an empty packet every 25 seconds so the ISP's NAT doesn't drop the mapping. Without it, after a while HQ can't reach the branch until some traffic comes from the branch side.
  • If HQ doesn't have a fixed IP, use a hostname instead, for example MikroTik's own IP Cloud.
  • The peer name field exists from RouterOS 7.15 and helps in the logs. On older versions use comment. And update anyway.

If you want an extra layer, you can add a preshared-key. It's optional and must be exactly the same on both sides.

4) Routes

MikroTik doesn't create routes from allowed-address. Add them yourself.

HQ:

routeros@itcorv:~
/ip route
add dst-address=10.20.10.0/24 gateway=wg-s2s

Branch:

routeros@itcorv:~
/ip route
add dst-address=10.10.10.0/24 gateway=wg-s2s

5) Firewall

If you have a proper firewall (and you should, see our MikroTik security post), the tunnel won't come up until you open its port.

On HQ:

routeros@itcorv:~
/ip firewall filter
add chain=input action=accept protocol=udp dst-port=13231 comment="WireGuard s2s"

This rule has to sit above your drop rules. Check the numbers with /ip firewall filter print and use move to bring it up, or drag it up in Winbox. Same for the other rules in this post.

We left out src-address because the branch IP isn't fixed. WireGuard doesn't answer any packet that isn't signed with the right key, so this open port is nothing like an open Winbox. If the branch does have a fixed IP, add src-address too. That's better.

The branch doesn't need this rule, because the connection starts from the branch and the replies pass through established/related.

Now allow traffic between the two LANs, on both routers, above the drop rules:

routeros@itcorv:~
/ip firewall filter
add chain=forward action=accept src-address=10.10.10.0/24 dst-address=10.20.10.0/24 comment="HQ to branch"
add chain=forward action=accept src-address=10.20.10.0/24 dst-address=10.10.10.0/24 comment="branch to HQ"

If the whole branch shouldn't reach the whole HQ, limit it here. For example, only the accounting server's IP and only its port.

6) Check NAT

If your masquerade rule uses out-interface-list=WAN (like MikroTik's default config), you're fine. But if you wrote masquerade with no outgoing interface, tunnel traffic gets NATed too and the other side doesn't see real addresses. Add an exception first:

routeros@itcorv:~
/ip firewall nat
add chain=srcnat action=accept dst-address=10.20.10.0/24 comment="no NAT to branch"

This rule has to sit above the masquerade. On the branch, do the same with dst-address=10.10.10.0/24.

Testing

1) Peer status:

routeros@itcorv:~
/interface wireguard peers print detail

Look at last-handshake. If it shows a few seconds or minutes ago, the tunnel is up. rx and tx should be growing. On HQ, current-endpoint-address should show the branch's current IP.

2) Ping across the tunnel:

From the branch:

routeros@itcorv:~
/ping 10.255.255.1 count=4

3) LAN to LAN ping:

From the branch, using the router's own LAN address as the source:

routeros@itcorv:~
/ping 10.10.10.1 src-address=10.20.10.1 count=4

If the tunnel ping works but this one doesn't, it's usually a missing route, a closed forward chain, or allowed-address missing that network.

4) From a branch PC:

On a machine in 10.20.10.0/24, ping the HQ server or open the app. A traceroute should show the path going through 10.255.255.1.

5) Firewall counters:

routeros@itcorv:~
/ip firewall filter print stats where comment~"WireGuard|HQ to|branch to"

The counters should have gone up.

Tips

  • MTU issues: if ping works but some sites or big files hang, it's usually MTU, especially when one side is on PPPoE. You can clamp MSS on the tunnel:
routeros@itcorv:~
/ip firewall mangle
add chain=forward action=change-mss new-mss=clamp-to-pmtu protocol=tcp tcp-flags=syn out-interface=wg-s2s passthrough=yes
  • More branches: create a separate peer on HQ for each branch, with its own allowed-address. Allowed-address ranges of peers on the same interface must not overlap.
  • Change the port if needed: if the handshake never shows up, check that the ISP isn't blocking UDP on that port. You can change listen-port, just remember to change the branch's endpoint-port and HQ's firewall rule too.
  • Multiple internet links: if HQ has two WANs, tunnel replies can leave through the wrong one. MikroTik's docs have a mangle config for this case that works together with responder=yes.
  • Remote management: don't add the tunnel to your LAN interface list unless you know what you're doing. Anything you opened for LAN is then open to the branch too. The specific rules above are better.
  • Naming: give interfaces and peers meaningful names. With ten branches, branch-tabriz beats peer7 every time.
  • VLANs: if the branch has several VLANs, only put the networks that really need to reach HQ into allowed-address and the routes. We covered VLAN separation in MikroTik VLAN setup.

FAQ

Is WireGuard or IPsec better for connecting branches?

Both are secure. WireGuard's config is much shorter and easier to troubleshoot. IPsec is what you need when the other side is another vendor's device without WireGuard.

Which MikroTik version has WireGuard?

RouterOS v7. It's not in v6.

What if the branch has no fixed IP?

No problem. The branch starts the connection and keeps it alive with persistent-keepalive. Only HQ needs a fixed IP or a hostname.

The tunnel is up but I can't reach the other LAN. Why?

Check three things: the route to the other LAN, allowed-address on the peer, and the forward chain in the firewall. It's usually one of those three.

If you have several branches and want them connected with a solid, secure design, the ITcorv team can help through our network services and network security. For a consultation, reach out from this page.