MikroTik WireGuard Road-Warrior Setup with DMZ Routing for Windows, macOS, iOS and Android
Set up a WireGuard server on RouterOS 7 for laptops and phones, route traffic to a DMZ file server and invoicing server without source NAT, and lock the firewall down to the exact ports each service needs.
A road-warrior VPN lets staff reach internal servers from laptops and phones while working off-site. Putting the WireGuard listener directly on the MikroTik gateway keeps the configuration in one place, but two shortcuts often weaken the setup in production: adding the WireGuard interface to the router's LAN interface list, and using masquerade source NAT toward internal servers instead of routing.
Adding WireGuard to the LAN list exposes the router's management ports and the entire office network to every connected phone and laptop. Source NAT toward the DMZ hides each client's tunnel IP behind the router's own address, so your file server and invoicing application log every login as coming from the router rather than the specific device.
This note builds a RouterOS 7.x road-warrior WireGuard server from scratch, connects Windows, macOS, iOS and Android clients, and routes them cleanly to a DMZ file server and a hosted invoicing server with per-device audit visibility and port-level firewall rules.
The setup
The examples below use documentation public addresses (203.0.113.0/24) and private RFC 1918 subnets. Replace them with your own addresses.
- WAN:
ether1, public IP203.0.113.10(vpn.example.com), listening onUDP 51820 - WireGuard interface:
wg-roadwarrior, router tunnel IP10.20.99.1/24, MTU1420 - DMZ network:
vlan20-dmz, router IP10.20.20.1/24 - File server (SMB and SFTP):
10.20.20.10(files.office.internal),TCP 445andTCP 22 - Hosted invoicing server (HTTPS):
10.20.20.20(invoices.office.internal),TCP 443 - Office LAN:
bridge-lan,10.20.10.0/24(blocked from road-warrior clients) - Road-warrior client peers (one
/32per device, never shared): - Windows 11 laptop:
10.20.99.11/32 - macOS laptop:
10.20.99.12/32 - iOS phone:
10.20.99.13/32 - Android phone:
10.20.99.14/32
Step 1: Create the WireGuard interface and subnet
Create the WireGuard interface on RouterOS and assign its /24 gateway address. RouterOS generates the server's Curve25519 private and public key pair automatically when the interface is created.
/interface wireguard
add name=wg-roadwarrior listen-port=51820 mtu=1420 comment="Road-warrior VPN"
/ip address
add address=10.20.99.1/24 interface=wg-roadwarrior comment="Road-warrior tunnel subnet"
Read back the generated public-key:
/interface wireguard print detail where name=wg-roadwarrior
Copy the public-key string from the output. Every client device needs this server public key in its [Peer] block. The router's private-key stays on the router.
Step 2: Register client peers on RouterOS
Each device gets its own peer entry, its own key pair, its own preshared-key and a single /32 address in allowed-address.
Do not set allowed-address=10.20.99.0/24 on a client peer. Inside a WireGuard interface, allowed-address is both an ingress source filter and an egress routing table. If the first peer claims 10.20.99.0/24, RouterOS sends reply traffic for every other client (10.20.99.12, .13, .14) down the first peer's tunnel.
Set responder=yes on every road-warrior peer. Without responder=yes, RouterOS repeatedly tries to initiate handshakes to the client's last known public IP and port after the client disconnects or moves between mobile networks.
Option A: Client-generated keys (recommended for Windows and macOS)
On laptops, generate the key pair inside the client app so the client's private key never exists on the router. Paste the client's public key into RouterOS and let RouterOS generate a per-peer preshared-key:
/interface wireguard peers
add interface=wg-roadwarrior name=win-laptop \
public-key="PASTE_WINDOWS_CLIENT_PUBLIC_KEY=" \
preshared-key=auto \
allowed-address=10.20.99.11/32 \
responder=yes \
comment="Windows 11 laptop"
add interface=wg-roadwarrior name=mac-laptop \
public-key="PASTE_MACOS_CLIENT_PUBLIC_KEY=" \
preshared-key=auto \
allowed-address=10.20.99.12/32 \
responder=yes \
comment="macOS laptop"
To read back the generated preshared-key for each laptop, run:
/interface wireguard peers print detail where interface=wg-roadwarrior
Option B: RouterOS QR code and config export (for iOS and Android)
Typing base64 keys on a phone is error-prone. RouterOS can generate the peer's private key, preshared key, client config file and terminal QR code directly when you set private-key=auto and populate the client-* attributes:
/interface wireguard peers
add interface=wg-roadwarrior name=ios-phone \
private-key=auto preshared-key=auto \
allowed-address=10.20.99.13/32 \
client-address=10.20.99.13/32 \
client-dns=10.20.99.1 \
client-endpoint=vpn.example.com:51820 \
client-allowed-address=10.20.99.1/32,10.20.20.0/24 \
client-keepalive=25 \
responder=yes \
comment="iOS phone"
add interface=wg-roadwarrior name=android-phone \
private-key=auto preshared-key=auto \
allowed-address=10.20.99.14/32 \
client-address=10.20.99.14/32 \
client-dns=10.20.99.1 \
client-endpoint=vpn.example.com:51820 \
client-allowed-address=10.20.99.1/32,10.20.20.0/24 \
client-keepalive=25 \
responder=yes \
comment="Android phone"
Print the QR code and full client configuration in the RouterOS terminal (your admin user needs the sensitive policy enabled):
/interface wireguard peers show-client-config [find name=ios-phone]
/interface wireguard peers show-client-config [find name=android-phone]
Note on RouterOS versions: client-allowed-address was added in RouterOS 7.21. On RouterOS 7.12 through 7.20, the generated QR code sets AllowedIPs = 0.0.0.0/0, ::/0 (a full tunnel); after scanning the QR code on the phone, edit the tunnel in the mobile app and change Allowed IPs to 10.20.99.1/32, 10.20.20.0/24 if you want a split tunnel.
Step 3: Firewall input rules and internal DNS

Two separate traffic flows hit the router's input chain:
- Encrypted WireGuard UDP packets arriving from the internet on
UDP 51820. - Decrypted DNS queries arriving from road-warrior clients inside
wg-roadwarriorto10.20.99.1on port53.
Keep wg-roadwarrior out of the LAN interface list. Instead, accept UDP 51820 on the WAN and accept only DNS (UDP 53 and TCP 53) from wg-roadwarrior:
/ip firewall filter
add chain=input action=accept protocol=udp dst-port=51820 \
comment="Allow WireGuard road-warrior handshakes" place-before=1
add chain=input action=accept in-interface=wg-roadwarrior src-address=10.20.99.0/24 \
protocol=udp dst-port=53 comment="Allow road-warrior DNS (UDP)" place-before=2
add chain=input action=accept in-interface=wg-roadwarrior src-address=10.20.99.0/24 \
protocol=tcp dst-port=53 comment="Allow road-warrior DNS (TCP)" place-before=3
Turn on the RouterOS DNS resolver and add static internal records for the DMZ servers so clients can connect by hostname instead of raw IP addresses:
/ip dns
set allow-remote-requests=yes
/ip dns static
add name=files.office.internal type=A address=10.20.20.10 ttl=5m comment="DMZ File Server"
add name=invoices.office.internal type=A address=10.20.20.20 ttl=5m comment="DMZ Invoicing Server"
Because your WAN input chain drops uninvited traffic from the internet, allow-remote-requests=yes answers only LAN, DMZ and wg-roadwarrior clients. Verify from an external host (dig @203.0.113.10 example.com) that port 53 is closed on ether1.
Step 4: Routing and firewall rules for DMZ access
Traffic from a road-warrior client (10.20.99.11) to a DMZ server (10.20.20.10 or 10.20.20.20) passes through the router's forward chain.
Routing between the WireGuard subnet and the DMZ
There are two common DMZ topologies behind a MikroTik:
- Case 1: The DMZ VLAN (
vlan20-dmz,10.20.20.1/24) terminates directly on this MikroTik. RouterOS creates active connected routes (DAC) for both10.20.99.0/24and10.20.20.0/24automatically. No static routes are needed on the MikroTik, provided the file server (10.20.20.10) and invoicing server (10.20.20.20) use10.20.20.1as their default gateway. - Case 2: The DMZ sits behind a downstream L3 switch or internal firewall (for example at
10.20.20.2). Add a static route on the MikroTik for the DMZ subnet, and add a return route on the downstream device pointing10.20.99.0/24back to10.20.20.1:
# Only needed if 10.20.20.0/24 lives behind a downstream router at 10.20.20.2
/ip route
add dst-address=10.20.20.0/24 gateway=10.20.20.2 comment="DMZ via downstream L3 switch"
Do not add a masquerade rule on vlan20-dmz to work around a missing gateway on a DMZ server. When traffic is routed without source NAT, the file server and invoicing server see the true client IP (10.20.99.11 through 10.20.99.14). If a server in 10.20.20.0/24 uses a different default gateway that you cannot change, add a single static route on that server for 10.20.99.0/24 via 10.20.20.1:
- On a Linux DMZ server (
10.20.20.20):ip route add 10.20.99.0/24 via 10.20.20.1 - On a Windows DMZ file server (
10.20.20.10):route -p add 10.20.99.0 mask 255.255.255.0 10.20.20.1
Forward firewall rules for the File Server and Hosted Invoicing Server
Group the authorised road-warrior IPs in an address list, permit only the required TCP ports into vlan20-dmz, and drop all other forwarding from wg-roadwarrior so road-warrior devices cannot scan the DMZ or enter the office LAN (10.20.10.0/24):
/ip firewall address-list
add list=wg-dmz-clients address=10.20.99.11 comment="Windows 11 laptop"
add list=wg-dmz-clients address=10.20.99.12 comment="macOS laptop"
add list=wg-dmz-clients address=10.20.99.13 comment="iOS phone"
add list=wg-dmz-clients address=10.20.99.14 comment="Android phone"
/ip firewall filter
add chain=forward action=accept in-interface=wg-roadwarrior out-interface=vlan20-dmz \
src-address-list=wg-dmz-clients dst-address=10.20.20.10 protocol=tcp dst-port=445,22 \
comment="Allow WG clients to DMZ File Server (SMB and SFTP)" place-before=1
add chain=forward action=accept in-interface=wg-roadwarrior out-interface=vlan20-dmz \
src-address-list=wg-dmz-clients dst-address=10.20.20.20 protocol=tcp dst-port=443 \
comment="Allow WG clients to DMZ Hosted Invoicing (HTTPS)" place-before=2
add chain=forward action=accept in-interface=wg-roadwarrior out-interface=vlan20-dmz \
src-address-list=wg-dmz-clients dst-address=10.20.20.0/24 protocol=icmp \
comment="Allow WG clients to ping DMZ hosts for diagnostics" place-before=3
add chain=forward action=drop in-interface=wg-roadwarrior \
comment="Drop all other traffic from wg-roadwarrior" place-before=4
Place these rules above any general drop rules in your forward chain, while keeping your standard connection-state=established,related accept rule at the top of the forward chain so reply packets from the DMZ flow back to wg-roadwarrior.
Clamp TCP MSS for SMB and HTTPS over the tunnel
WireGuard encapsulates packets inside UDP, reducing the default tunnel MTU to 1420 bytes. If a client connects over LTE or a PPPoE link (1492 or 1480 MTU), large SMB file transfers (TCP 445) or TLS certificate exchanges (TCP 443) can stall while small pings succeed. Clamp the TCP Maximum Segment Size (MSS) on wg-roadwarrior to 1360 bytes:
/ip firewall mangle
add chain=forward in-interface=wg-roadwarrior protocol=tcp tcp-flags=syn \
tcp-mss=1361-65535 action=change-mss new-mss=1360 passthrough=yes \
comment="Clamp TCP MSS in from wg-roadwarrior"
add chain=forward out-interface=wg-roadwarrior protocol=tcp tcp-flags=syn \
tcp-mss=1361-65535 action=change-mss new-mss=1360 passthrough=yes \
comment="Clamp TCP MSS out to wg-roadwarrior"
Step 5: Configure Windows, macOS, iOS and Android clients
Before configuring the clients, decide between a split tunnel and a full tunnel:
- Split tunnel (
AllowedIPs = 10.20.99.1/32, 10.20.20.0/24): Only DNS queries to10.20.99.1and traffic for the DMZ (10.20.20.0/24) enter the VPN. Normal internet browsing stays on the client's local connection. This is the right choice when staff only need the file server and invoicing server. - Full tunnel (
AllowedIPs = 0.0.0.0/0, ::/0): All traffic from the client goes through the MikroTik router. If you use a full tunnel, you must also add a firewall rule on the MikroTik allowingin-interface=wg-roadwarrior out-interface=ether1in theforwardchain.
The configurations below use the split-tunnel setup.
1. Windows 10 and Windows 11
- Download and install the official Windows client from
https://www.wireguard.com/install/. - Open WireGuard and press
Ctrl+N(or click Add Tunnel → Add empty tunnel...). - WireGuard pre-fills a new
PrivateKeyand displays the matchingPublic keyat the top of the window. Copy thatPublic keyinto thewin-laptoppeer on RouterOS (from Step 2, Option A). - Replace the editor text with the configuration below, keeping the
PrivateKeythat Windows generated:
[Interface]
PrivateKey = <WINDOWS_GENERATED_PRIVATE_KEY>
Address = 10.20.99.11/32
DNS = 10.20.99.1
[Peer]
PublicKey = <MIKROTIK_SERVER_PUBLIC_KEY>
PresharedKey = <WIN_LAPTOP_PRESHARED_KEY_FROM_ROUTEROS>
AllowedIPs = 10.20.99.1/32, 10.20.20.0/24
Endpoint = vpn.example.com:51820
PersistentKeepalive = 25
- Leave Block unticked traffic (kill-switch) unticked if it appears; that option is only for
0.0.0.0/0full tunnels. Click Save, then click Activate. - Open File Explorer and enter
\\files.office.internal\in the address bar, or open your browser tohttps://invoices.office.internal.
2. macOS
- Install the official WireGuard app from the Mac App Store.
- Click the WireGuard icon in the menu bar → Manage Tunnels → click
+→ Add Empty Tunnel.... - Copy the displayed
Public keyinto themac-laptoppeer on RouterOS (Step 2, Option A), then complete the tunnel configuration:
[Interface]
PrivateKey = <MACOS_GENERATED_PRIVATE_KEY>
Address = 10.20.99.12/32
DNS = 10.20.99.1
[Peer]
PublicKey = <MIKROTIK_SERVER_PUBLIC_KEY>
PresharedKey = <MAC_LAPTOP_PRESHARED_KEY_FROM_ROUTEROS>
AllowedIPs = 10.20.99.1/32, 10.20.20.0/24
Endpoint = vpn.example.com:51820
PersistentKeepalive = 25
- Optional: tick On-Demand for Wi-Fi and Ethernet, and add your office Wi-Fi SSID under the excluded SSIDs list so the tunnel turns on automatically whenever the Mac leaves the office.
- Click Save and toggle the tunnel to Active. In Finder, press
Cmd+Kand connect tosmb://files.office.internal.
3. iOS (iPhone and iPad)
- Install WireGuard from the Apple App Store.
- On the MikroTik terminal, run
/interface wireguard peers show-client-config [find name=ios-phone]. - In the iOS WireGuard app, tap
+→ Create from QR code, scan the QR code from the terminal and name the tunnelOffice-DMZ. - Tap the tunnel name → Edit and check Allowed IPs under the
[Peer]section. On RouterOS 7.21 and newer, it will already read10.20.99.1/32, 10.20.20.0/24. On earlier RouterOS 7 builds, replace0.0.0.0/0, ::/0with10.20.99.1/32, 10.20.20.0/24. - Scroll down to On-Demand Activation, enable Cellular and Wi-Fi, and exclude your office Wi-Fi SSID. Tap Save.
4. Android
- Install WireGuard from Google Play or F-Droid.
- On the MikroTik terminal, run
/interface wireguard peers show-client-config [find name=android-phone]. - Tap the blue
+button in the Android app → Scan from QR code, scan the terminal QR code and name the tunnelOffice-DMZ. - Tap the pencil icon to edit the tunnel if you want per-app routing: tap All Applications, choose Include only selected applications, and tick your browser (for the invoicing server) and your SMB file manager (such as Solid Explorer, CX File Explorer or Material Files).
- Verify that Allowed IPs is set to
10.20.99.1/32, 10.20.20.0/24, tap the save icon and toggle the switch on.
Step 6: Verification and troubleshooting
Once a client connects, check the peer state on the MikroTik:
/interface wireguard peers print detail where interface=wg-roadwarrior
Look at three fields on the active peer:
last-handshake: should appear within seconds of activation and stay under3m.current-endpoint-addressandcurrent-endpoint-port: shows the client's public IP and NAT source port.rxandtx: both counters must climb above0.
If a client cannot reach the File Server or Hosted Invoicing Server, check these four failure modes in order:
txclimbs on the client,rxstays0, andlast-handshakeis blank on RouterOS. The UDP handshake is not reachingwg-roadwarrior. Check thatUDP 51820is above yourinputdrop rule (/ip firewall filter print stats where chain=input), and confirm your WAN IP onether1is a real public IPv4 address rather than an ISP CGNAT address in100.64.0.0/10.- Handshake succeeds,
10.20.99.1answers pings, but10.20.20.10and10.20.20.20time out. Check the default gateway on both DMZ servers. If a DMZ server's default gateway is not10.20.20.1, its reply packets for10.20.99.0/24go elsewhere and get dropped. - Pings to
10.20.20.10work,https://invoices.office.internalloads, but Windows SMB (TCP 445) on10.20.20.10times out. By default, Windows Server Firewall's File and Printer Sharing (SMB-In) rule only accepts connections fromLocalSubnet(10.20.20.0/24). Because we did not masquerade the VPN traffic, the connection arrives from10.20.99.11. On the Windows file server, open Windows Defender Firewall with Advanced Security → Inbound Rules → File and Printer Sharing (SMB-In) → Scope → Remote IP address, and add10.20.99.0/24. - Ping works and TCP connects, but the invoicing page hangs mid-load or SMB directory listings stall. TCP packets are exceeding the path MTU. Confirm the two
change-mssmangle rules from Step 4 are active and increment their packet counters (/ip firewall mangle print stats where chain=forward) when openinghttps://invoices.office.internal.
Checklist
- Create
wg-roadwarrioronUDP 51820with10.20.99.1/24andmtu=1420. - Add one peer per device with its own key pair,
preshared-key=auto,responder=yesand a unique/32inallowed-address. - Open
UDP 51820on WANinput, allowUDP/TCP 53fromwg-roadwarrior, and add/ip dns staticrecords forfiles.office.internalandinvoices.office.internal. - Keep
wg-roadwarriorout of theLANinterface list. - Route
10.20.99.0/24tovlan20-dmzwithout source NAT so DMZ servers log each client's real/32IP. - Add
forwardrules permitting onlyTCP 445,22to10.20.20.10andTCP 443to10.20.20.20, followed by an explicit drop rule forin-interface=wg-roadwarrior. - Add TCP MSS clamping (
1360bytes) onwg-roadwarriorin both directions. - Add
10.20.99.0/24to the Windows Firewall SMB scope on the file server if it runs Windows Server.