MARWAN docs NOC knowledge base
DocsRouting and high availability

BGP routing security at MARWAN

How MARWAN protects BGP routing for its members: route filtering, anti-spoofing, published contacts, and route origin validation with the AFRINIC IRR and RPKI. With the steps a member institution follows to register its own routes.

Published Sami Ait Ali Oulahcen

Why routing security matters#

BGP is the protocol that tells every network on the internet how to reach every other network. It was designed for a small group of networks that trusted each other, and it still believes almost anything it is told. Two kinds of incident follow from that:

  • Prefix hijack: a network announces address space that isn't its own, and traffic for those addresses goes to the wrong place.
  • Route leak or path manipulation: a network passes on routes it shouldn't, and traffic takes a path nobody intended.

Both happen often, usually by mistake. In 2008 Pakistan Telecom, asked to block a few videos nationally, announced YouTube's prefixes to the world and took YouTube offline for about two hours. There is no central authority that can stop this: routing security depends on each operator following good practice and checking what its neighbours send.

MARWAN (AS30983) applies the four actions of the MANRS initiative, and asks member institutions that run BGP to do the same.

Action What it means
Filtering Only accept and announce routes that are correct
Anti-spoofing Drop traffic with forged source addresses
Coordination Keep contact information public and up to date
Global validation Publish routing data so others can check it

MARWAN's registered routing data#

Anyone can check these records. They are what other networks use to decide whether a MARWAN announcement is genuine.

Resource Value Where
AS number AS30983 (MARWAN-AS) AFRINIC whois
IPv4 196.200.128.0/18, route object, origin AS30983 AFRINIC IRR
IPv6 2001:4310::/32, route6 object, origin AS30983 AFRINIC IRR
RPKI (IPv4) ROA for 196.200.128.0/18, max length /24 AFRINIC RPKI
RPKI (IPv6) ROA for 2001:4310::/32, max length /48 AFRINIC RPKI
Peering and contacts PeeringDB net 17736 PeeringDB
Looking glass lg.marwan.ma MARWAN

The ROA maximum lengths let MARWAN announce more specific prefixes (down to a /24 in IPv4 and a /48 in IPv6) for traffic engineering, while anything longer from anyone is marked invalid by networks that validate.

To check an announcement yourself:

$ curl -s "https://stat.ripe.net/data/rpki-validation/data.json?resource=AS30983&prefix=196.200.128.0/18"

The answer's status is valid, invalid or unknown (no ROA covers the prefix).

Filtering#

Left alone, BGP propagates everything everywhere. Without filters, a network with two upstreams passes one upstream's routes to the other and offers to carry traffic between them. Filters fix that in both directions.

Outbound, MARWAN announces only its own prefixes and the prefixes of members it provides transit for, checked by both prefix list and AS path.

Inbound from members, MARWAN accepts only the prefixes each member has registered in an IRR, with the member's own AS as origin. Before building a filter for a new member, the NOC checks in the AFRINIC whois that the member really holds the AS number and address space it asks to announce. A filter can say "AS64500 may announce 192.0.2.0/24"; only that check says the member is AS64500.

Always, MARWAN drops bogons (private, reserved and unallocated space), its own prefixes coming back from outside, and prefixes longer than /24 (IPv4) or /48 (IPv6).

Building filters from the IRR#

Prefix lists are generated from IRR data rather than typed by hand. bgpq4 reads the registry and prints a ready-made filter. For a member with AS64500:

$ bgpq4 -4 -S AFRINIC -l MEMBER-AS64500-V4 AS64500
no ip prefix-list MEMBER-AS64500-V4
ip prefix-list MEMBER-AS64500-V4 permit 192.0.2.0/24

$ bgpq4 -6 -S AFRINIC -l MEMBER-AS64500-V6 AS64500

If a member has its own customers, it publishes an as-set listing them, and the filter is built from the as-set instead of the single AS (bgpq4 -4 -S AFRINIC AS64500:AS-CUSTOMERS).

Applied on a Cisco router:

Cisco IOS
router bgp 30983
 address-family ipv4
  neighbor 198.51.100.1 prefix-list MEMBER-AS64500-V4 in
  neighbor 198.51.100.1 filter-list 10 in
!
ip as-path access-list 10 permit ^64500(_64500)*$
Check generated filters before you load them

A wrong filter can cut a member off. Compare each new prefix list with the previous one and look at what was added or removed before you push it, especially when the change is large.

Route origin validation with RPKI#

RPKI does the same job as IRR route objects, but each record (a ROA) is signed by the address holder's regional registry, so it can't be faked. A validator such as Routinator downloads and checks all ROAs, and routers ask it about each route over the RTR protocol.

Cisco IOS XE
router bgp 30983
 bgp rpki server tcp 192.0.2.10 port 3323 refresh 600
 address-family ipv4
  neighbor 198.51.100.1 route-map RPKI-IN in
!
route-map RPKI-IN deny 10
 match rpki invalid
route-map RPKI-IN permit 20

Routes that are invalid (a ROA exists but the origin AS or the prefix length doesn't match) are dropped. Routes that are unknown (no ROA) are still accepted, since many networks have no ROAs yet.

Anti-spoofing#

Forged source addresses are the raw material of reflection and amplification DDoS attacks. The defence, described in BCP 38, is simple: a network only lets out packets whose source address belongs to it.

On interfaces toward members and campus networks, unicast reverse path forwarding (uRPF) drops any packet whose source address isn't reachable back through the interface it came in on:

Cisco IOS
interface <member-facing-interface>
 ip verify unicast source reachable-via rx
 ipv6 verify unicast source reachable-via rx

Use strict mode (rx) on single-homed links. On links where traffic may return by another path, use loose mode (any) or an ingress ACL that permits only the member's prefixes.

Campus networks should do the same at their own edge, so spoofed traffic never reaches MARWAN.

Coordination#

When something goes wrong, other operators need to reach the right people quickly. MARWAN keeps its contacts current in the AFRINIC whois, on its route objects (remarks: lines), and on PeeringDB:

Purpose Contact
Network operations noc@marwan.ma
Abuse reports abuse@marwan.ma
Security incidents soc@marwan.ma

Members with their own AS should keep their AFRINIC contacts current and add a PeeringDB record.

For member institutions: register your routes#

If your institution has its own address space or AS number and MARWAN announces it for you, register it so that MARWAN's filters accept it and other networks can validate it. All of this is done in MyAFRINIC with your organisation's account.

  1. Check your resources. Make sure your inetnum/inet6num, aut-num (if you have an AS) and contacts in the AFRINIC whois are correct.

  2. Create route objects. One route (IPv4) or route6 (IPv6) object per prefix you announce, with the AS that originates it. Add your contacts as remarks:

    AFRINIC IRR
    route:    192.0.2.0/24
    descr:    Example University
    origin:   AS64500
    remarks:  Network: noc@example.ac.ma
    mnt-by:   EXAMPLE-MNT
    source:   AFRINIC
    

    If MARWAN originates your prefix (you have address space but no AS), the origin is AS30983.

  3. Create ROAs. In MyAFRINIC, open the RPKI dashboard and create a ROA for each prefix with the same origin AS. Set the maximum length to the longest prefix you actually announce, not longer: a loose maximum length lets a hijacker announce a more specific route that still looks valid.

  4. Tell the MARWAN NOC at noc@marwan.ma which prefixes and AS you registered, so the filters for your session can be updated.

  5. Check the result with the RIPEstat command above, using your own AS and prefix. It should say valid.

Keep records in step with reality

Update your route objects and ROAs before you start announcing a new prefix, and remove them when you stop. A ROA that no longer matches what you announce makes your own routes invalid.

Further reading#