# Set up MikroTik switches for Trustaige RADIUS

> Run RouterOS 7's dot1x server on a MikroTik switch against Trustaige RADIUS, with MAC authentication fallback, dynamic VLANs and accounting.

Source: https://docs.trustaige.com/manage/switch-mikrotik

Replace these placeholders with your organization's own values:

- `<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-restricted-vlan>`: Restricted VLAN, for example `30`. The Restricted VLAN for headless devices on the wired network’s settings in the hub.
- `<your-radius-secret>`: RADIUS shared secret, a secret. The hub shows it once, when you register your RADIUS server at a site.

RouterOS's dot1x server asks RADIUS about each port. It prefers 802.1X and,
after three `retrans-timeout` periods without one, falls back to MAC
authentication. By default it sends the MAC as the user name alone, with no
password, which Trustaige accepts when the user name is the same MAC as
`Calling-Station-Id`.

Read [Run a wired office on Trustaige RADIUS](/manage/wired-8021x) first for
the hub's side. Register the switch with the make **MikroTik**.

## Before you start

| You need | Why |
|---|---|
| RouterOS 7.15 or later | From 7.15, RouterOS adds Message-Authenticator to every RADIUS request but accounting. Trustaige drops requests without it. |
| Ports on a bridge with `vlan-filtering=yes` | The dot1x server places a device in a VLAN only on a VLAN-filtering bridge. |
| The VLANs Trustaige will name, as static bridge VLANs | The switch adds the port to a VLAN that already exists; it doesn't create it. |

## RADIUS and disconnects

```txt title="RouterOS"
/radius add service=dot1x address=<your-radius-server> secret="<your-radius-secret>" \
    authentication-port=1812 accounting-port=1813 comment=trustaige
/radius incoming set accept=yes port=3799
```

- Set `authentication-port` to the hub's **Port**, and `accounting-port` to
  the port after it. Add a second entry for the secondary server.
- `require-message-auth` stays at its default, which Trustaige meets: it signs
  every reply.
- **`/radius incoming`** listens on UDP 1700 unless told otherwise; the hub
  sends to 3799 for **MikroTik**. Allow UDP 3799 in from the addresses the
  hub lists when you choose **Disconnects on UDP 3799**, and from nowhere
  else.

## The VLANs

```txt title="RouterOS"
/interface bridge set bridge vlan-filtering=yes
/interface bridge vlan add bridge=bridge vlan-ids=<your-restricted-vlan> tagged=bridge,sfp-sfpplus1
```

Add the wired network's **VLAN** the same way, tagged on the uplink.

## The dot1x server

```txt title="RouterOS"
/interface dot1x server add interface=ether10 auth-types=dot1x,mac-auth \
    mac-auth-mode=mac-as-username retrans-timeout=10s \
    accounting=yes interim-update=5m
```

- **`auth-types=dot1x,mac-auth`** tries 802.1X first, then the MAC. With
  `retrans-timeout=10s`, the fallback comes after 30 seconds; the default,
  30 seconds, makes it 90.
- **`mac-auth-mode`** can stay at `mac-as-username`, or be
  `mac-as-username-and-password`, which adds the MAC as a PAP password.
  Trustaige accepts both. `radius-mac-format` can stay at its default.
- Leave `guest-vlan-id`, `reject-vlan-id` and `server-fail-vlan-id` unset, so
  a device Trustaige refused gets no network.

The dot1x server places the device in the VLAN Trustaige names in
`Tunnel-Private-Group-ID`.

> **Important:** The dot1x server opens a port for every device behind it once one has
> authenticated. A port with a PC behind an IP phone is open to anything
> plugged into the phone once either joins. Give headless devices admitted by
> MAC a port each.

## Check it works

1. Plug a managed PC into the port, then, on another port, a printer.
2. On the switch:

   ```txt title="RouterOS"
   /interface dot1x server active print
   /interface dot1x server state print
   ```

   Each device shows its MAC, user name, VLAN and how it authenticated.
3. In the hub, **Recent joins** shows each decision, and the activity names
   the port.
4. Block the PC in the hub, and check whether its entry leaves `active print`
   within seconds.

## Troubleshooting

**Activity says “The access point does not sign its requests. Turn on Message-Authenticator in its RADIUS settings.”**

The switch runs a release before 7.15. Update RouterOS.

**The printer is accepted but has no network**

The VLAN Trustaige named isn't a static bridge VLAN, or the bridge doesn't
filter VLANs. Add it under `/interface bridge vlan`.

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

Check `/radius incoming` (`accept=yes`, port 3799) and the firewall. If both
are right, the dot1x server isn't acting on the request; see below.

## What hasn't been confirmed yet

- Whether the dot1x server ends a session on a Disconnect-Request isn't
  documented. MikroTik's RADIUS page describes Disconnect-Requests in general,
  without naming the services that act on them.
- Whether the dot1x server acts on `Session-Timeout` with `Termination-Action`
  `RADIUS-Request` isn't documented; it re-authenticates at `reauth-period`
  when one is set.
- Trustaige's lab has exercised MAC authentication as RouterOS sends it, not
  a real switch's request.

## MikroTik documentation

- [Dot1X](https://manual.mikrotik.com/docs/7.25/authentication-authorization-accounting/dot1x/): the dot1x server, MAC authentication and dynamic VLANs
- [RADIUS](https://manual.mikrotik.com/docs/7.25/authentication-authorization-accounting/radius/): services, `require-message-auth` and incoming requests
- [RouterOS 7.15 changelog](https://download.mikrotik.com/routeros/7.15/CHANGELOG): Message-Authenticator in every request
