Skip to main content
Version: 7.26

RPKI

Resource Public Key Infrastructure (RPKI) lets the holder of an IP address block publish which autonomous system (AS) is authorized to originate routes for it. The published object is a Route Origin Authorization (ROA): a prefix, a maximum prefix length and an origin AS. An Autonomous System Provider Authorization (ASPA) object lists the provider ASes of a customer AS.

An RPKI validator (relying party software) downloads and checks these objects. RouterOS does not validate the RPKI objects itself: it is an RPKI to Router (RTR) protocol client. It connects to a validator, receives the validated ROA and ASPA data, and checks BGP routes against it in a routing filter:

  • Prefix origin validation checks the prefix and the origin AS of a route against the ROAs.
  • ASPA validation checks the AS path of a route against the ASPA objects, to detect route leaks.

Validation only sets a state on the route. The routing filter decides what to do with it, for example reject routes with an invalid origin.

Standards:

Connect to a validator​

You need a validator that serves RTR, for example Routinator or StayRTR, on a server in your network. See a validator setup example on the APNIC blog.

In this example the validator listens on 10.0.0.10, TCP port 3323. Create an RPKI group named rpki1 with it:

/routing/rpki
add group=rpki1 address=10.0.0.10 port=3323

The address takes an IP address, not a host name, and the port has no default: set the port your validator listens on (RTR has no fixed port number).

Check the session. The sync state shows that the router has received the validator data:

[admin@MikroTik] > /routing/rpki/session/print detail
0 group=rpki1 address=10.0.0.10 port=3323 state=sync version=2 session=41287
serial=17 expires=1h59m53s

The version field shows the RTR protocol version in use. RouterOS connects with version 2 first. When the validator rejects version 2, RouterOS connects again with an earlier version (1 or 0), so it works with older validators without configuration. ASPA data is available only over version 2.

The route,rpki log topic shows the session progress:

[admin@MikroTik] > /log/print where topics~"rpki"
2026-12-01 10:57:07 route,rpki,info Group rpki1 reconfigure
2026-12-01 10:57:07 route,rpki,info Session { rpki1 10.0.0.10:3323 Idle } configured
2026-12-01 10:57:07 route,rpki,info Session { rpki1 10.0.0.10:3323 Idle } state change to Connecting
2026-12-01 10:57:07 route,rpki,info Session { rpki1 10.0.0.10:3323 Connecting } state change to Prepare
2026-12-01 10:57:07 route,rpki,info Session { rpki1 10.0.0.10:3323 Prepare } send reset query version: 2
2026-12-01 10:57:07 route,rpki,info Session { rpki1 10.0.0.10:3323 Prepare } session start 41287
2026-12-01 10:57:07 route,rpki,info Group rpki1 cache reset start
2026-12-01 10:57:07 route,rpki,info Session { rpki1 10.0.0.10:3323 Prepare } state change to Loading
2026-12-01 10:57:07 route,rpki,info Group rpki1 cache reset done
2026-12-01 10:57:07 route,rpki,info Session { rpki1 10.0.0.10:3323 Loading } sync created version: 2 id: 41287 serial: 17
2026-12-01 10:57:07 route,rpki,info Session { rpki1 10.0.0.10:3323 Loading } state change to Sync

Use several validators​

An RPKI group can have several validators: add more entries with the same group. The group uses one session at a time. The other entries stay in the idle state.

  • The entry with the highest preference is used. An entry with a preference is preferred over an entry without one.
  • Without preferences, the entry with the lowest address is used, and for the same address, the lowest port.
  • When you disable the used entry, the group connects to the next one.
  • When the validator of the used entry stops answering, the session goes to the error state and the group keeps its data. After retry-interval, the router tries that validator again. When that attempt fails too, the group connects to the next entry.
  • The group does not switch back when the preferred validator answers again. To return to it, disable and enable the entry in use.

Check a prefix​

rpki-check shows the prefix origin validation state of a prefix and an origin AS in the data of a group. In this example the validator data has a ROA for 192.0.2.0/24 with origin AS 64497 and maximum length 24, a ROA for 198.51.100.0/24 with origin AS 64511, and no ROA for 203.0.113.0/24:

[admin@MikroTik] > /routing/rpki/rpki-check group=rpki1 prefix=192.0.2.0/24 origin-as=64497
valid
[admin@MikroTik] > /routing/rpki/rpki-check group=rpki1 prefix=192.0.2.128/25 origin-as=64497
invalid
[admin@MikroTik] > /routing/rpki/rpki-check group=rpki1 prefix=198.51.100.0/24 origin-as=64497
invalid
[admin@MikroTik] > /routing/rpki/rpki-check group=rpki1 prefix=203.0.113.0/24 origin-as=64497
unknown

rpki-query lists the ROAs that cover a prefix: the ROA prefix, its maximum length and its origin AS. A ROA covers the prefix when the ROA prefix is the same or shorter. With exact, it lists only the ROAs for exactly that prefix.

Both commands print rpki group not ready when the group has no data, for example when no session has synchronized.

Filter BGP routes by origin​

In this example the router (AS 64496, 10.0.12.1) receives routes from its upstream provider (AS 64497, 10.0.12.2). The input filter of the BGP connection checks each route against the rpki1 group and rejects the routes with an invalid origin:

/routing/filter/rule
add chain=bgp-in rule="rpki-verify rpki1"
add chain=bgp-in rule="if (rpki invalid) { reject } else { accept }"
/routing/bgp/instance
add name=bgp1 as=64496 router-id=10.0.12.1
/routing/bgp/connection
add name=upstream instance=bgp1 remote.address=10.0.12.2 \
local.role=ebgp-customer input.filter=bgp-in

rpki-verify selects the group for the rest of the chain. Put it before the rules that match rpki. Without rpki-verify in the chain, no rpki state matches, not even unverified. The selected group also applies across jump and return: in the chain the rule jumps to, and in the calling chain after the return. See the rpki-verify command on the Route Selection and Filtering page.

Check the result. The rpki attribute of each route shows its state. The rejected routes stay in the table with the F (filtered) flag:

[admin@MikroTik] > /routing/route/print where bgp
Flags: F - FILTERED, A - ACTIVE; b - BGP
Columns: DST-ADDRESS, GATEWAY, AFI, ROUTING-TABLE, DISTANCE, SCOPE,
TARGET-SCOPE, IMMEDIATE-GW
DST-ADDRESS GATEWAY AFI ROUT DISTANCE SCOPE TA IMMEDIATE-GW
Ab 192.0.2.0/24 10.0.12.2 ip main 20 40 10 10.0.12.2%ether2
Fb 192.0.2.128/25 10.0.12.2 ip main 20 40 10 10.0.12.2%ether2
Ab 198.18.0.0/24 10.0.12.2 ip main 20 40 10 10.0.12.2%ether2
Ab 198.18.1.0/24 10.0.12.2 ip main 20 40 10 10.0.12.2%ether2
Fb 198.51.100.0/24 10.0.12.2 ip main 20 40 10 10.0.12.2%ether2
Ab 203.0.113.0/24 10.0.12.2 ip main 20 40 10 10.0.12.2%ether2
[admin@MikroTik] > /routing/route/print detail proplist=dst-address,rpki,bgp.as-path where bgp
Flags: F - FILTERED, A - ACTIVE; b - BGP
Ab dst-address=192.0.2.0/24 rpki=valid bgp.as-path="64497"

Fb dst-address=192.0.2.128/25 rpki=invalid bgp.as-path="64497"

Ab dst-address=198.18.0.0/24 rpki=valid bgp.as-path="64497,64498,64499"

Ab dst-address=198.18.1.0/24 rpki=unknown bgp.as-path="64497,64498"

Fb dst-address=198.51.100.0/24 rpki=invalid bgp.as-path="64497"

Ab dst-address=203.0.113.0/24 rpki=unknown bgp.as-path="64497"

192.0.2.128/25 is invalid because it is longer than the maximum length of the 192.0.2.0/24 ROA. 198.51.100.0/24 is invalid because its ROA names another origin AS. The validator data also has a ROA for 198.18.0.0/24 with origin AS 64499: the origin AS is the last AS of the path, so the route is valid. A route with an empty AS path, for example from an iBGP peer, has the local AS as its origin AS. A ROA with origin AS 0 makes the routes it covers invalid.

The prefix origin validation states are:

  • valid - A ROA covers the prefix, its origin AS is the origin AS of the route, and the prefix is not longer than the ROA's maximum length.
  • invalid - At least one ROA covers the prefix, and none of them is valid for the route: the origin AS differs, or the prefix is longer than the maximum length.
  • unknown - No ROA covers the prefix (NotFound in RFC 6811).
  • unverified - The group has no data, for example because none of its sessions has synchronized or the data has expired. The rpki attribute is not shown on the route. Match this state to decide what happens to routes when RPKI data is missing. /routing/route/print does not accept rpki=unverified: list these routes with where bgp and !rpki.

When the validator data changes, RouterOS checks the routes again: the state of a route changes without a reset of the BGP session.

The else { accept } branch of the example accepts the valid, unknown and unverified routes.

ASPA validation​

An ASPA object authorizes a set of provider ASes for a customer AS. RouterOS validates the BGP AS path against ASPA objects to detect route leaks that prefix origin validation cannot detect. ASPA validation complements prefix origin validation. Use both to detect invalid origins and route leaks.

Prerequisites:

  • A validator that supports RTR protocol version 2 and serves validated ASPA data. The session version is 2.
  • An RFC 9234 role set with local.role on the eBGP connection: ebgp-provider, ebgp-customer, ebgp-peer, ebgp-rs or ebgp-rs-client. The ibgp, ibgp-rr and ebgp roles do not provide the role information ASPA validation needs, so ASPA validation does not run for sessions that use them. ASPA validation uses the local role: the peer does not have to confirm it, and the session also comes up when the peer sends no role. See Route leak prevention.
  • rpki-aspa-verify in the input filter chain.

The following example adds ASPA validation to the connection of the previous example. The new chain validates both the prefix origin and the AS path of the routes from the upstream provider:

/routing/filter/rule
add chain=bgp-in-aspa rule="rpki-verify rpki1"
add chain=bgp-in-aspa rule="rpki-aspa-verify rpki1"
add chain=bgp-in-aspa rule="if (rpki invalid || rpki-aspa invalid) { reject } else { accept }"
/routing/bgp/connection
set [find name=upstream] input.filter=bgp-in-aspa

The rpki-verify command selects the group for prefix origin validation. The rpki-aspa-verify command selects the group for ASPA validation. Both commands can use the same group. Without rpki-aspa-verify in the chain, no rpki-aspa state matches, not even unverified.

The role describes the local router: local.role=ebgp-customer means that this router is the customer and the peer is its provider.

ASPA validation states​

The rpki-aspa filter property and the rpki-aspa route attribute have the following values:

The check depends on the direction the route comes from, as given by the role. For a route from a customer, a lateral peer, a route server or a route server client, the expected path only goes up: each AS of the path is a provider of the AS before it. For a route from a provider, the expected path goes up to one top AS and then only down.

  • valid - The ASPA data authorizes each hop of the AS path for its direction.
  • invalid - The ASPA data proves that the path breaks this rule: for a path that is expected to only go up, at least one AS is not an authorized provider of the AS before it; for a route from a provider, the path goes down and then up again. The route is likely a route leak.
  • unknown - The path is neither proven valid nor invalid, because ASes of the path have no ASPA object.
  • unverified - ASPA validation did not run, for example because the BGP session has no RFC 9234 role. The /routing/route output does not show the rpki-aspa attribute in this state.

ASPA validation only provides the state. The filter rules define the action. The else branch of the example accepts routes with the valid, unknown and unverified state. Add stricter rules to handle those states according to your routing policy.

Verify ASPA validation​

Check that the session uses version 2 with /routing/rpki/session/print detail, then check the ASPA state of the routes:

/routing/route/print detail where rpki-aspa=invalid

The rpki-check and rpki-query commands check prefix origin data only. The ASPA state depends on the complete AS path and the BGP role, so use the rpki-aspa route attribute or a filter rule to check it.

Technical details​

Session states​

The state field of /routing/rpki/session shows:

  • idle - The session is not connected, for example another entry of the group is used.
  • connecting - The router opens the TCP connection to the validator.
  • prepare - The router sent a Reset Query (for the complete data) or a Serial Query (for the changes) and waits for the Cache Response.
  • loading - The router receives data.
  • sync - The data is complete. The session, serial and version fields are shown.
  • error - The connection failed, for example the validator does not listen on the port. A session that has not synchronized yet tries again after a few seconds. When a query of a synchronized session fails, the session connects again after retry-interval.

Timers​

  • refresh-interval (default 3600 seconds, range 1 to 86400) - How often the router asks the validator for new data (an RTR serial query).
  • expire-interval (default 7200 seconds, range 600 to 172800) - How long the data of a session stays valid when no update arrives. The expires field of the session counts it down, and each successful query starts it again.
  • retry-interval (default 600 seconds, range 1 to 7200) - How long the router waits before it connects again after a failed query.

The router uses the configured intervals. The timer values that a version 1 or 2 validator sends with its data do not change them.

When the validator stops answering, the session goes to the error state and the group keeps its data until expires reaches zero. Then the group has no data: rpki-check prints rpki group not ready and the routes are unverified.

A validator can also notify the router of new data. The router then asks for the changes without waiting for the refresh interval.

Where the connection goes​

The RTR session is a TCP connection from the router to the validator, in the routing table of the vrf parameter (default main). The VRF page lists RPKI among the VRF-aware services. The connection is plain TCP: RouterOS has no settings for an SSH, TLS or TCP-AO transport.

Properties of all menus: /routing/rpki, /routing/rpki/session, rpki-check, rpki-query.