> ## Content Index
> Fetch the complete content index at: https://technotes.tewodros.dev/llms.txt
> Use this file to discover other available public pages before exploring further.

# MikroTik WireGuard Road-Warrior Setup with DMZ Routing for Windows, macOS, iOS and Android
- URL: https://technotes.tewodros.dev/mikrotik-wireguard-road-warrior-dmz-clients/
- Published: 2026-10-15T19:02:37.000Z
- Updated: 2026-10-15T19:02:36.000Z
- Description: 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.
- Author: Tewodros Asfaw
- Tags: MikroTik, WireGuard, RouterOS, Security, Networking

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 IP `203.0.113.10` (`vpn.example.com`), listening on `UDP 51820`
- **WireGuard interface**: `wg-roadwarrior`, router tunnel IP `10.20.99.1/24`, MTU `1420`
- **DMZ network**: `vlan20-dmz`, router IP `10.20.20.1/24`
- **File server (SMB and SFTP)**: `10.20.20.10` (`files.office.internal`), `TCP 445` and `TCP 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 `/32` per 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.

```routeros
/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`:

```routeros
/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`:

```routeros
/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:

```routeros
/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:

```routeros
/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):

```routeros
/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

![Packet walk across the RouterOS input chain and forward chain for un-NATed DMZ access](https://technotes.tewodros.dev/content/images/2026/10/wg-dmz-flow-1.png)

Handshakes and DNS queries terminate on the router input chain; DMZ traffic crosses the forward chain without source NAT so servers log each client's real /32 address.

Two separate traffic flows hit the router's `input` chain:

1. **Encrypted WireGuard UDP packets** arriving from the internet on `UDP 51820`.
2. **Decrypted DNS queries** arriving from road-warrior clients inside `wg-roadwarrior` to `10.20.99.1` on port `53`.

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`:

```routeros
/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:

```routeros
/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 both `10.20.99.0/24` and `10.20.20.0/24` automatically. No static routes are needed on the MikroTik, provided the file server (`10.20.20.10`) and invoicing server (`10.20.20.20`) use `10.20.20.1` as 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 pointing `10.20.99.0/24` back to `10.20.20.1`:

```routeros
# 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`):

```routeros
/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:

```routeros
/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 to `10.20.99.1` and 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 allowing `in-interface=wg-roadwarrior out-interface=ether1` in the `forward` chain.

The configurations below use the split-tunnel setup.

### 1\. Windows 10 and Windows 11

1. Download and install the official Windows client from `https://www.wireguard.com/install/`.
2. Open WireGuard and press `Ctrl+N` (or click **Add Tunnel** → **Add empty tunnel...**).
3. WireGuard pre-fills a new `PrivateKey` and displays the matching `Public key` at the top of the window. Copy that `Public key` into the `win-laptop` peer on RouterOS (from Step 2, Option A).
4. Replace the editor text with the configuration below, keeping the `PrivateKey` that Windows generated:

```ini
[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

```

1. Leave **Block unticked traffic (kill-switch)** unticked if it appears; that option is only for `0.0.0.0/0` full tunnels. Click **Save**, then click **Activate**.
2. Open File Explorer and enter `\\files.office.internal\` in the address bar, or open your browser to `https://invoices.office.internal`.

### 2\. macOS

1. Install the official **WireGuard** app from the Mac App Store.
2. Click the WireGuard icon in the menu bar → **Manage Tunnels** → click `+` → **Add Empty Tunnel...**.
3. Copy the displayed `Public key` into the `mac-laptop` peer on RouterOS (Step 2, Option A), then complete the tunnel configuration:

```ini
[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

```

1. 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.
2. Click **Save** and toggle the tunnel to **Active**. In Finder, press `Cmd+K` and connect to `smb://files.office.internal`.

### 3\. iOS (iPhone and iPad)

1. Install **WireGuard** from the Apple App Store.
2. On the MikroTik terminal, run `/interface wireguard peers show-client-config [find name=ios-phone]`.
3. In the iOS WireGuard app, tap `+` → **Create from QR code**, scan the QR code from the terminal and name the tunnel `Office-DMZ`.
4. Tap the tunnel name → **Edit** and check **Allowed IPs** under the `[Peer]` section. On RouterOS 7.21 and newer, it will already read `10.20.99.1/32, 10.20.20.0/24`. On earlier RouterOS 7 builds, replace `0.0.0.0/0, ::/0` with `10.20.99.1/32, 10.20.20.0/24`.
5. Scroll down to **On-Demand Activation**, enable **Cellular** and **Wi-Fi**, and exclude your office Wi-Fi SSID. Tap **Save**.

### 4\. Android

1. Install **WireGuard** from Google Play or F-Droid.
2. On the MikroTik terminal, run `/interface wireguard peers show-client-config [find name=android-phone]`.
3. Tap the blue `+` button in the Android app → **Scan from QR code**, scan the terminal QR code and name the tunnel `Office-DMZ`.
4. 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).
5. 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:

```routeros
/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 under `3m`.
- `current-endpoint-address` and `current-endpoint-port`: shows the client's public IP and NAT source port.
- `rx` and `tx`: both counters must climb above `0`.

If a client cannot reach the File Server or Hosted Invoicing Server, check these four failure modes in order:

- **`tx` climbs on the client, `rx` stays `0`, and `last-handshake` is blank on RouterOS.** The UDP handshake is not reaching `wg-roadwarrior`. Check that `UDP 51820` is above your `input` drop rule (`/ip firewall filter print stats where chain=input`), and confirm your WAN IP on `ether1` is a real public IPv4 address rather than an ISP CGNAT address in `100.64.0.0/10`.
- **Handshake succeeds, `10.20.99.1` answers pings, but `10.20.20.10` and `10.20.20.20` time out.** Check the default gateway on both DMZ servers. If a DMZ server's default gateway is not `10.20.20.1`, its reply packets for `10.20.99.0/24` go elsewhere and get dropped.
- **Pings to `10.20.20.10` work, `https://invoices.office.internal` loads, but Windows SMB (`TCP 445`) on `10.20.20.10` times out.** By default, Windows Server Firewall's *File and Printer Sharing (SMB-In)* rule only accepts connections from `LocalSubnet` (`10.20.20.0/24`). Because we did not masquerade the VPN traffic, the connection arrives from `10.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 add `10.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-mss` mangle rules from Step 4 are active and increment their packet counters (`/ip firewall mangle print stats where chain=forward`) when opening `https://invoices.office.internal`.

## Checklist

1. Create `wg-roadwarrior` on `UDP 51820` with `10.20.99.1/24` and `mtu=1420`.
2. Add one peer per device with its own key pair, `preshared-key=auto`, `responder=yes` and a unique `/32` in `allowed-address`.
3. Open `UDP 51820` on WAN `input`, allow `UDP/TCP 53` from `wg-roadwarrior`, and add `/ip dns static` records for `files.office.internal` and `invoices.office.internal`.
4. Keep `wg-roadwarrior` out of the `LAN` interface list.
5. Route `10.20.99.0/24` to `vlan20-dmz` without source NAT so DMZ servers log each client's real `/32` IP.
6. Add `forward` rules permitting only `TCP 445,22` to `10.20.20.10` and `TCP 443` to `10.20.20.20`, followed by an explicit drop rule for `in-interface=wg-roadwarrior`.
7. Add TCP MSS clamping (`1360` bytes) on `wg-roadwarrior` in both directions.
8. Add `10.20.99.0/24` to the Windows Firewall SMB scope on the file server if it runs Windows Server.