# Connect a MikroTik VPN gateway to Trustaige

> Set up RouterOS 7 as an IKEv2 gateway that passes EAP-TLS to Trustaige RADIUS and takes its disconnects, or checks Trustaige device certificates itself.

Source: https://docs.trustaige.com/manage/vpn-gateway-mikrotik

Replace these placeholders with your organization's own values:

- `<your-vpn-gateway>`: VPN gateway, for example `vpn.example.com`. The Gateway identity on the VPN network’s page in the hub, or its Gateway when no identity is set.
- `<your-office-network>`: Office network, for example `10.20.0.0/16`. One of the Office networks on the VPN network’s page in the hub.
- `<your-radius-server>`: Trustaige RADIUS server, for example `203.0.113.10`. The Server, or Primary server, the hub shows when you register your RADIUS server at a site.
- `<your-radius-secret>`: RADIUS shared secret, a secret. The hub shows it once, when you register your RADIUS server at a site.

RouterOS's IPsec identities can pass a connection's EAP conversation through
to a RADIUS server (`auth-method=eap-radius`, RFC 3579). With Trustaige RADIUS
as that server, managed devices connect with their Trustaige certificate, and
Trustaige decides every connection by the device, its owner, its posture and
your policies. RouterOS also takes Disconnect-Requests from RADIUS, so a device
that loses its standing can be taken off the VPN in seconds.

Read [Connect managed devices to your VPN gateway](/manage/vpn-gateway) first
for the hub's side: the VPN network, the one proposal and the gateway's
certificate.

## Before you start

| You need | Why |
|---|---|
| RouterOS 7 | The commands below are RouterOS 7's. |
| A certificate for the router, with its private key | Devices check it before they sign in (see [the gateway's certificate](/manage/vpn-gateway#the-gateways-certificate)). RouterOS also requires a Subject Key Identifier in it. |
| A VPN network in the hub, served at a site, with the router registered there | The hub gives you the RADIUS servers, the port and the shared secret. |
| UDP 500 and 4500 open to the router; UDP 1812 and 1813 out to Trustaige | IKE and NAT traversal in; RADIUS and accounting out. |

## In Trustaige

1. Add the VPN network with **Server** set to **Trustaige RADIUS**, and serve
   it at the site, as [the overview](/manage/vpn-gateway#set-up-the-vpn-in-the-hub)
   describes.

2. On the site's page, under **Access points**, choose **Add access point**,
   then **A VPN gateway** and **MikroTik**. Enter the **Public address** the
   router's RADIUS requests come from.

3. Turn on **Takes disconnects**. The router takes Disconnect-Requests once
   incoming RADIUS is on, below.

4. Choose **Register gateway**, and copy the **Server** (or **Primary server**
   and **Secondary server**), the **Port** and the shared secret.

## On the router

1. **Import the router's certificate** with its key. Upload the PKCS #12 file
   under **Files**, then:

   ```txt title="RouterOS"
   /certificate import file-name=vpn-gateway.p12 passphrase="…" name=trustaige-vpn-gateway
   ```

   Import any intermediate that issued it the same way, so the router sends it
   with its own.

2. **Add Trustaige RADIUS for IPsec**, with accounting:

   ```txt title="RouterOS"
   /radius add service=ipsec address=<your-radius-server> secret="<your-radius-secret>" \
       authentication-port=1812 accounting-port=1813 comment=trustaige
   /ip ipsec settings set interim-update=5m
   ```

   - Set `authentication-port` to the hub's **Port**, and `accounting-port` to
     the port after it. If the hub showed a secondary server, add a second
     entry with that address.
   - RouterOS sends accounting for IPsec by default, and returns Trustaige's
     `Class` in it unchanged. Trustaige shows each session under **Connected
     now**, and can disconnect only a session it saw in accounting.
     `interim-update` keeps the session's figures current.
   - `require-message-auth` stays at its default, which Trustaige meets: it
     signs every reply.

3. **Take Disconnect-Requests** on the port the hub shows beside the gateway
   (**Disconnects on UDP 3799**). RouterOS listens on 1700 unless told
   otherwise:

   ```txt title="RouterOS"
   /radius incoming set accept=yes port=3799
   ```

   Allow UDP 3799 in from the addresses the hub lists when you choose
   **Disconnects on UDP 3799**, and from nowhere else.

4. **The proposal.** The IKE half goes in a profile, the tunnel half in a
   proposal. These are [the one proposal](/manage/vpn-gateway#the-one-proposal)
   and nothing else:

   ```txt title="RouterOS"
   /ip ipsec profile add name=trustaige-vpn hash-algorithm=sha256 enc-algorithm=aes-256 \
       dh-group=ecp256 lifetime=8h
   /ip ipsec proposal add name=trustaige-vpn auth-algorithms=sha256 enc-algorithms=aes-256-gcm \
       pfs-group=ecp256 lifetime=1h
   ```

   With AES-GCM the tunnel needs no separate integrity algorithm;
   `auth-algorithms` is kept to one value so nothing else is offered.

5. **Addresses, DNS and routes for devices:**

   ```txt title="RouterOS"
   /ip pool add name=trustaige-vpn ranges=10.99.0.10-10.99.0.250
   /ip ipsec mode-config add name=trustaige-vpn address-pool=trustaige-vpn \
       split-include=<your-office-network> system-dns=no static-dns=10.20.0.53
   /ip ipsec policy group add name=trustaige-vpn
   /ip ipsec policy add group=trustaige-vpn template=yes src-address=<your-office-network> \
       dst-address=10.99.0.0/24 proposal=trustaige-vpn
   ```

   - The pool and DNS server are your own. Choose a range the office routes
     back to the router.
   - Add one policy template, and one `split-include` entry, for each of the
     VPN's **Office networks**. The template's `src-address` is what the router
     offers devices as its side of the tunnel, and Apple devices route only
     that. On a VPN that carries **All traffic**, use `0.0.0.0/0` and leave
     `split-include` out.

6. **The peer and the identity:**

   ```txt title="RouterOS"
   /ip ipsec peer add name=trustaige-vpn exchange-mode=ike2 passive=yes profile=trustaige-vpn
   /ip ipsec identity add peer=trustaige-vpn auth-method=eap-radius \
       certificate=trustaige-vpn-gateway generate-policy=port-strict \
       mode-config=trustaige-vpn policy-template-group=trustaige-vpn
   ```

   `auth-method=eap-radius` authenticates the router by its certificate and
   passes the device's EAP-TLS through to Trustaige. Devices expect the router
   to identify itself as `<your-vpn-gateway>`, the **Gateway identity** on the
   VPN network's page, which must be a subject alternative name of its
   certificate.

## Check it works

1. Turn on logging for IPsec and RADIUS:

   ```txt title="RouterOS"
   /system logging add topics=ipsec,!packet
   /system logging add topics=radius,debug
   ```

2. Connect from a managed device that has received the VPN. The log shows the
   proposal chosen, the RADIUS exchange with Trustaige and the identity
   matched.
3. `/ip ipsec active-peers print` lists the device. In the hub, the site's
   **Recent joins** and the network's **Recent connections** show the
   decision, and **Connected now** shows the session.
4. Block the device in the hub. With **Takes disconnects** on, its peer leaves
   `/ip ipsec active-peers` within seconds.

If the device stays connected, RouterOS didn't act on the Disconnect-Request.
Turn **Takes disconnects** off in the hub and choose an interval under
**Connections sign in again every**, so Trustaige caps each connection's
`Session-Timeout` at that interval.

## The gateway checks the certificate

For a VPN whose **Server** is **The gateway checks the certificate**, the
router authenticates the device certificate itself. Nothing is registered at a
site. See [A gateway that checks the certificate](/manage/vpn-gateway-certificate)
for what changes for devices.

> **Important:** RouterOS checks revocation only by CRL, and its documentation names HTTP as
> the only way it fetches one; Trustaige publishes CRLs and OCSP over HTTPS
> only. RouterOS has no OCSP client. Until a router is confirmed to fetch your
> authority's CRL, assume it can't see a device lose its standing, and admits
> the device until its certificate expires. On MikroTik, prefer Trustaige RADIUS,
> which decides every connection.

1. **Import your authorities** as trusted, and nothing above them. On the
   network's page, open **Your VPN gateway**, download the trust bundle,
   upload it under **Files**, then:

   ```txt title="RouterOS"
   /certificate import file-name=acme-network-intermediates.pem trusted=yes
   ```

   Don't import the platform root as trusted: it signs every organization's
   authority, so the router would admit other organizations' devices.

2. **Change the identity** to authenticate the device by its certificate:

   ```txt title="RouterOS"
   /ip ipsec identity set [find peer=trustaige-vpn] auth-method=digital-signature \
       remote-id=ignore
   ```

   The router still checks that the device certificate chains to a trusted
   authority. `remote-id=ignore` stops it comparing the device's IKE identity
   with the certificate: Apple devices send `tq-` followed by the device ID,
   which the certificate carries as its common name, not as an alternative
   name. Keep no other authorities trusted on this router, since any of them
   would be accepted.

3. **Turn on CRL checking**, and look for your authority's CRL:

   ```txt title="RouterOS"
   /certificate settings set crl-use=yes crl-download=yes
   /certificate crl print
   ```

   If the list doesn't show a CRL from `id.trustaige.com` after a few minutes,
   the router can't fetch it, and can't see revocations.

## Troubleshooting

**The log shows “no suitable proposal found”**

The profile or proposal differs from the device's suite. Check
`enc-algorithm=aes-256`, `hash-algorithm=sha256` and `dh-group=ecp256` on the
profile, and `enc-algorithms=aes-256-gcm` with `pfs-group=ecp256` on the
proposal.

**The device refuses the router before any RADIUS request**

The device didn't accept the router's certificate. Check its subject
alternative names against the **Gateway identity**, `serverAuth`, the Subject
Key Identifier, and that its intermediate is imported.

**The RADIUS log shows a timeout**

Nothing came back from Trustaige. Check that outbound UDP to the hub's port is
allowed, that the router is registered at the address its requests come from,
and the shared secret.

**The hub shows a Disconnect-Request as not acknowledged**

The router didn't take it. Check `/radius incoming` (`accept=yes`, port 3799),
the firewall, and that accounting is reaching Trustaige: **Connected now**
lists the session only then.

**The tunnel comes up, but some office networks are unreachable**

A policy template or `split-include` entry is missing for one of the VPN's
**Office networks**. Add one for each.

## What hasn't been confirmed yet

- Trustaige's lab hasn't yet recorded RouterOS ending an IPsec tunnel on a
  Disconnect-Request, nor acting on `Session-Timeout` for one. The live test
  above shows which your router does.
- Whether a policy template narrower than `0.0.0.0/0` makes RouterOS offer
  only the office networks to Apple devices hasn't been recorded in the lab.
  MikroTik notes that a narrowed template can trouble some clients.
- Whether RouterOS accepts an authority below a root as its trust anchor,
  without the root itself, hasn't been recorded in the lab.

## MikroTik documentation

- [IPsec](https://help.mikrotik.com/docs/spaces/ROS/pages/11993097/IPsec): profiles, proposals, identities and the IKEv2 EAP RADIUS road warrior
- [Certificates](https://help.mikrotik.com/docs/spaces/ROS/pages/2555969/Certificates): import and CRL settings
- [RADIUS](https://manual.mikrotik.com/docs/7.25/authentication-authorization-accounting/radius/): services and incoming requests
