BGP Hijack Detection: RIS Live, Alerts and Response Steps
BGP hijack detection comes down to watching how the rest of the internet sees your prefixes, not how your own routers see them. You subscribe to public route collectors such as RIPE RIS, compare every origin AS, upstream AS and prefix length against what you expect, and alert when something differs.
This guide covers a practical monitoring setup, what to do in the first hour of an incident, and how it fits with DDoS tunnels where your prefixes are announced from a scrubbing edge.
Three things you are looking for
| Event | What you see in the global table | Typical cause |
|---|---|---|
| Origin hijack | Your exact prefix with an unexpected origin AS | Misconfiguration or malicious announcement |
| More-specific hijack | A longer prefix (e.g. a /24 inside your /22) from another origin | Attacker wins by longest-prefix match |
| Route leak | Correct origin, but the AS path contains ASNs that should not carry your traffic | A customer or peer re-announcing routes to a provider or another peer |
Origin hijacks and more-specifics are easy to detect with a simple allow-list. Leaks need a path check, because the origin is still valid.
Step 1: Define what "normal" looks like
Write down the data your monitor will compare against:
- Every prefix you originate, including the maximum length you intend to announce.
- Allowed origin ASNs. Include any ASN that may legitimately originate your space, such as a scrubbing provider.
- Expected upstream ASNs, meaning the AS directly before your origin in the path.
- Your ROAs and IRR route objects.
Check what is currently published:
# RPKI validation state as seen by RIPEstat
curl -s "https://stat.ripe.net/data/rpki-validation/data.json?resource=AS64496&prefix=192.0.2.0/24"
# IRR route objects for your prefix
whois -h whois.radb.net -- "-i origin AS64496"
whois -h whois.radb.net 192.0.2.0/24
If the IRR shows route objects for origins you no longer use, note them. You will clean them up in step 5.
Step 2: Subscribe to public route collectors
RIPE RIS collects BGP updates from many peers worldwide. RIS Live streams them over a WebSocket, so you can filter for your prefixes in near real time. RouteViews, PCH and bgp.tools offer other views. Use more than one source for confirmation.
Here is a minimal Python monitor using RIS Live (pip install websockets):
import asyncio, json, ipaddress, websockets
MY_PREFIXES = ["192.0.2.0/24", "198.51.100.0/23"]
ALLOWED_ORIGINS = {64496}
EXPECTED_UPSTREAMS = {64500, 64501}
URL = "wss://ris-live.ripe.net/v1/ws/?client=example-hijack-monitor"
mine = [ipaddress.ip_network(p) for p in MY_PREFIXES]
async def main():
async with websockets.connect(URL) as ws:
for p in MY_PREFIXES:
await ws.send(json.dumps({"type": "ris_subscribe", "data": {
"prefix": p, "moreSpecific": True,
"lessSpecific": False, "type": "UPDATE"}}))
async for raw in ws:
msg = json.loads(raw)
if msg.get("type") != "ris_message":
continue
d = msg["data"]
path = d.get("path") or []
if len(path) < 2:
continue
origin, upstream = path[-1], path[-2]
for a in d.get("announcements", []):
for pfx in a.get("prefixes", []):
net = ipaddress.ip_network(pfx)
if isinstance(origin, list) or origin not in ALLOWED_ORIGINS:
print(f"ORIGIN ALERT {pfx} origin={origin} peer=AS{d['peer_asn']} path={path}")
elif net not in mine:
print(f"MORE-SPECIFIC ALERT {pfx} path={path}")
elif upstream not in EXPECTED_UPSTREAMS:
print(f"PATH ALERT {pfx} unexpected upstream AS{upstream} path={path}")
asyncio.run(main())
Replace print with a webhook, email or pager call. Two practical notes:
- Require several peers. A single RIS peer seeing something odd may be a local issue at that peer. Alert immediately on a multi-peer sighting, and log single-peer events at lower priority.
- Handle AS_SETs. The
pathmay contain a nested list when an AS_SET is present. Treat it as suspicious for your own prefixes.
If you prefer not to build your own, hosted and open-source alerting tools cover the same ground. Examples are BGPalerter (open source), RIPE NCC's MyASN, and BGPStream-style services that publish hijack and leak events. Whichever you choose, the allow-list from step 1 matters more than the tool.
Step 3: Check your own routers too
Public collectors tell you about the outside view. Your edge routers can also reveal more-specifics of your space that arrive from a peer or customer.
# Cisco IOS-XE
show bgp ipv4 unicast 192.0.2.0/24 longer-prefixes
# Juniper
show route 192.0.2.0/24 orlonger table inet.0
# MikroTik RouterOS v7
/routing/route print where dst-address in 192.0.2.0/24
If you see a route inside your own space that you did not originate, investigate before you do anything else. It can mean a customer is leaking, or that traffic is being pulled away from you.
Step 4: Respond in the first hour
Work through these actions in order. The order matters, because the early steps are the fastest.
- Confirm and collect evidence. Capture the prefix, the origin AS, the AS paths, the time and the RIS peers that saw it. Screenshots from RIPEstat or bgp.tools help when you escalate.
- Contact your upstreams. Send the evidence to your transit providers' NOCs. Ask them to filter the offending origin or path. Use PeeringDB for NOC and peering contacts, including the hijacker's upstream and any IXP route server operator where it appears.
- Check your ROAs. If you have a valid ROA, networks doing route origin validation (ROV) will drop a hijack with a wrong origin. If you do not have one, create it now. Propagation through RPKI repositories and validator caches takes time, so do not expect instant results.
- Announce more-specifics when possible. If the hijacker announced your /22, you can announce /24s and win on longest-prefix match. Make sure your ROA
maxLengthcovers them. Otherwise ROV networks will mark your own /24s invalid. This option does not exist for a hijacked IPv4 /24 or IPv6 /48, because most networks filter anything longer. - Treat prepending as a weak tool. Prepending only changes path length. It cannot beat a longer prefix, and an attacker who announces the same length can also win on path length from some vantage points. Use it for traffic engineering, not hijack defense. Prepending toward the leaking path can help with a route leak, but filtering by the leaker's upstream is the real fix.
Keep ROA maxLength tight in normal operations. A ROA that permits /24 for a /22 you only announce as a /22 gives an attacker room to forge a more-specific that still validates (with your origin prepended). You can pre-plan an emergency ROA procedure instead of loosening everything permanently.
Step 5: IRR and RPKI cleanup afterward
Once the incident is under control, remove the conditions that made it easier:
- Delete stale IRR route and route6 objects with old origins.
- Keep your AS-SET accurate. Upstreams often build prefix filters from it with tools such as bgpq4.
- Make sure every announced prefix has a ROA that matches reality: origin, prefix and a minimal
maxLength. - Enable ROV on your own edge so you reject invalid routes from others.
A minimal ROV setup on Juniper looks like this:
routing-options {
validation {
group RPKI {
session 203.0.113.10 { port 3323; }
}
}
}
policy-options {
policy-statement IMPORT-FROM-PEERS {
term rpki-invalid {
from { protocol bgp; validation-database invalid; }
then reject;
}
}
}
On Linux, BIRD 2 provides the equivalent with an rpki protocol and roa_check() in import filters.
Common mistakes
- Monitoring only your own routers. A hijack that never reaches your edge is invisible there.
- Alerting on every change. Without peer thresholds and allow-lists, the noise leads to ignored alerts.
- ROAs with loose
maxLength. This undermines the protection you were trying to get. - Forgetting temporary origins. If a provider announces your prefix on your behalf, that origin must be in both your ROAs and your allow-list.
- Stale IRR data. Old route objects can make a hijack look legitimate to filters built from IRR.
How this fits with DDoS tunnels
If you use a cloud scrubbing service where your prefixes are announced from the scrubbing edge, your routing legitimately changes whenever you switch from direct to scrubbed paths. This affects your monitoring in a few ways:
- Add the scrubbing origin and upstream ASNs to your allow-lists. Confirm with your provider which origin AS appears for your prefixes, and make sure your ROAs cover it. Otherwise ROV networks may drop your own announcement exactly when you need it.
- Keep your IRR route objects and AS-SET current. For NixGuard Edge, which requires your own ASN and at least one /24, the customer AS-SET can be used for prefix filtering, so stale data can block a legitimate announcement.
- Use RIS Live to verify that a scrubbing announcement is actually propagating after you turn on protection (always-on or on-demand).
- Correlate with traffic. A sudden drop in inbound traffic for a prefix, visible in NetFlow, IPFIX or sFlow data, can be an early sign that something is attracting your traffic elsewhere. Flow-based monitoring such as NixMon (15-day free trial, no credit card) can show that change per prefix alongside your attack thresholds.
BGP monitoring and DDoS detection answer different questions. One tells you who is announcing your space, the other tells you what is hitting it. Running both shortens the time it takes to tell a hijack from an attack.
Frequently asked questions
What is the fastest way to detect a BGP hijack of my prefix?
Subscribe to RIPE RIS Live for your prefixes, including more-specifics, and alert when the origin AS, prefix length or upstream AS differs from your allow-list. Require sightings from several collector peers to cut false positives.
Does a ROA stop a BGP hijack completely?
No. A ROA lets networks that perform route origin validation drop announcements with a wrong origin or excessive length. Networks that do not validate may still accept the hijack, so you also need monitoring and upstream escalation.
Can I defend against a hijacked /24 with a more-specific announcement?
Generally not for IPv4, because most networks filter prefixes longer than /24 (/48 for IPv6). In that case rely on RPKI, upstream filtering and escalation to the hijacker's providers.
Does prepending help against a BGP hijack?
Very little. Prepending lengthens your AS path, which does not beat a more-specific prefix and may even make a same-length hijack more attractive. It is a traffic engineering tool, not a hijack defense.