Loop icon
Download icon
Get icon
Script icon
If icon
SlackIncomingWebhook icon
Set icon
Schedule icon

Detect BGP Hijacks and RPKI Problems on Your IP Prefixes

Watch your IP prefixes with public RIPE RIS data and alert in Slack on unexpected origin ASNs, more-specific hijacks, lost visibility or invalid RPKI.

Categories
Infrastructure

If another network announces your IP prefix, or a more-specific piece of it, part of the internet sends your traffic there: that is a BGP hijack or a route leak, and it is usually noticed only when customers complain. A prefix can also silently lose visibility after a router change, or become RPKI-invalid when a ROA expires or a new origin is added without one, and then networks that validate routes drop it.

This blueprint checks each prefix you announce against RIPE RIS, the public route collectors that peer with hundreds of networks, through the free RIPEstat Data API. It reports, once each, and again when they clear:

  • an origin ASN other than yours (or an allowed one) announcing the prefix;
  • a more-specific of the prefix announced by an ASN you did not allow;
  • visibility below min_visibility_percent of RIS peers;
  • an RPKI status other than valid for your origin ASN (unknown means no ROA, invalid_asn or invalid_length means a ROA exists but does not match).

How it works

For each entry in prefixes (Loop, four at a time):

  1. fetch_routing_status downloads the origins, more-specifics and peer visibility.
  2. fetch_rpki downloads the RPKI validation for your origin ASN and the ROAs that cover the prefix.
  3. load_previous reads the findings reported at the last run from the Kestra KV store.
  4. evaluate compares what the internet sees with what you expect and lists new and cleared findings.
  5. if_changed skips Slack when nothing changed.
  6. alert_owner posts the findings, the current origins, visibility and RPKI status, and a RIPEstat link.
  7. remember_findings stores the findings, after the alert, so each one is posted once.

Prerequisites

  • A Slack Incoming Webhook. RIPEstat is public and needs no key; the flow identifies itself with the sourceapp parameter, as RIPE asks.
  • The prefixes exactly as you announce them. A covering aggregate you do not announce has no origin and zero visibility, so list the announced prefixes instead.

Secrets

  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL for alerts and failures.

In the open-source edition, secrets are environment variables on the Kestra container, prefixed with SECRET_ and base64-encoded. See how to manage secrets.

Inputs

  • prefixes (JSON): list of {"prefix", "origin", "allowed_origins", "owner"} objects. Add your DDoS protection or transit provider's ASN to allowed_origins if it announces your prefix or more-specifics during mitigation.
  • min_visibility_percent (INT, default 80): the visibility alert threshold.

Quick start

  1. Add the Slack secret and replace the default prefixes (Cloudflare's and GitHub's) with yours.
  2. Execute the flow. Existing problems, such as a missing ROA, are posted once.
  3. Enable every_15_minutes. From then on, Slack hears when routing changes and when it recovers.

To see a prefix the way the flow does, open https://stat.ripe.net/<prefix>.

Outputs

  • {{ outputs.evaluate.vars }} per iteration: origins, visibility, rpki_status, new_findings, cleared.
  • KV entries bgp_watch_<prefix>: the findings already reported.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.