Course contents

Module 5: Scaling and OperationsLesson 5.4 (4 of 7 in this module)34 of 43 in the BGP course

Session safeguards: maximum-prefix, TTL security, allowas-in

A session with another network is a trust relationship, and mistakes cross it. A neighbour can send you far too many routes, a stranger can spoof packets to your BGP port, and your own AS number can appear in a path you need to accept.

Advanced · 13 min read

You'll learn to configure maximum-prefix, ttl-security, allowas-in and as-override, and explain what each one protects or fixes.

Three problems, three tools

A BGP configuration that works is not necessarily safe. This lesson covers the settings that stop a neighbour from overwhelming you, stop an outsider from reaching your session, and handle the special case where loop prevention rejects a route you want.

The safeguards in this lesson
The safeguards in this lessonEach command and the problem it addresses.maximum-prefixA neighbour sends too many routes(leak or misconfiguration)ttl-securitySpoofed packets from a hostthat is not directly attachedallowas-inReceiver accepts its own ASnumber in the AS pathas-overrideSender replaces the receiver ASnumber in the path

On small screens, swipe sideways or focus the diagram and use the arrow keys.

The first two protect your router. The last two work around loop prevention for a specific design.

maximum-prefix: a limit on what a neighbour can send

What maximum-prefix does as the count grows
What maximum-prefix does as the count growsA limit of 1000 prefixes is set for a neighbour. Up to 750 prefixes, which is 75 percent, nothing is logged. At 750 the router logs a warning and the session stays up. Above 1000 it sends a NOTIFICATION with error code 6 subcode 1 and closes the session, and the session stays down until cleared unless a restart interval is set.neighbor 192.0.2.1 maximum-prefix 1000 750 to 750: normal751 to 1000over 100075% = 750limit = 1000Warning loggedsession stays upCease 6/1session closedrestart 5 adds a retry after 5 minuteswarning-only never closes the session

On small screens, swipe sideways or focus the diagram and use the arrow keys.

The warning threshold gives you time to react before the session closes. A restart interval brings the session back on its own after a set number of minutes, which suits a neighbour that might recover.

A customer who leaks the full internet table to you can fill your routing table and memory in seconds. A prefix limit makes the session fail before that happens. You set the number, an optional warning percentage and what to do on the breach.

router bgp 64500 address-family ipv4 unicast neighbor 192.0.2.1 maximum-prefix 1000 80

R1. Logs a warning at 80 percent of 1000 prefixes and closes the session when the limit is passed. The default warning threshold is 75 percent.

What the router does as prefixes arrive
What the router does as prefixes arriveWarning first, then the session closes.Below 80%NormalAt 80%Log message,keep goingOver 1000Cease sent,session closed

On small screens, swipe sideways or focus the diagram and use the arrow keys.

After the Cease, the state shows Idle (PfxCt) until cleared or restarted.
Illustrative Cisco IOS XE output written for this lesson, not a router capture
R1#show ip bgp summary
Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.0.2.1       4        64501    1120     310       42    0    0 00:00:12 Idle (PfxCt)
Idle (PfxCt) means the session was shut because the prefix count exceeded the limit. Fix the neighbour first, then clear ip bgp 192.0.2.1, or configure restart 5 to retry after five minutes automatically.
Choose how strict to be
Choose how strict to beThree behaviours when the limit is hit.DefaultClose the sessionStays downuntil clearedwarning-onlyLog a messageKeep the sessionKeep the routesor

On small screens, swipe sideways or focus the diagram and use the arrow keys.

warning-only is useful while you measure a neighbour. Enforcement is the safe default for customers.

ttl-security: only directly connected neighbours

How TTL security tells a neighbour from an attacker
How TTL security tells a neighbour from an attackerR1 and ISP A share a link. Each sends BGP packets with TTL 255. A packet from the directly connected neighbour arrives with TTL 255. An attacker several hops away can send with a TTL of 255 too, but every router on the way subtracts one, so it arrives with a lower value. With ttl-security hops 1 configured, R1 accepts only packets with TTL 254 or higher and discards the rest before BGP sees them.ISP Adirect neighbourR1ttl-security hops 1Attackerseveral hops awayTTL 255TTL 250 on arrivalArrives with 255accepted, BGP processes itArrives below 254dropped before BGP, CPU is sparedBoth ends must configure it, or the session drops.

On small screens, swipe sideways or focus the diagram and use the arrow keys.

An attacker cannot make a packet arrive with a higher TTL than it was sent with. That is why checking the arriving TTL proves the sender is within the configured number of hops.

BGP runs over TCP port 179, so anyone who can send packets to your router can try to disturb the session. Normally eBGP packets are sent with a TTL of 1 because the peer is next door. The Generalized TTL Security Mechanism (GTSM, RFC 5082) turns that around: both sides send with a TTL of 255 and each discards anything that arrives with a lower value. A packet from a host several hops away cannot reach 255 on arrival, so it is dropped before BGP sees it.

How GTSM filters packets
How GTSM filters packetsLegitimate packets keep a high TTL.Peer sendsTTL 255One hopArrives withTTL 254Checkhops 1: accept254 or higherRemote hostArrives lower,dropped

On small screens, swipe sideways or focus the diagram and use the arrow keys.

An attacker can set any TTL on a packet, but cannot make it higher than 255 minus the hops it crosses.
router bgp 64500 neighbor 192.0.2.1 remote-as 64501 neighbor 192.0.2.1 ttl-security hops 1

R1. Both routers must be configured. hops 1 means the peer must be directly connected. A larger value allows a peer that many hops away.

When your own AS is in the path

Loop prevention rejects any route whose AS path already contains the AS number of the router receiving it. That is right on the internet. It is a problem when one customer uses the same AS number at two sites that connect through a provider.

Why Site 2 rejects a route from Site 1
Why Site 2 rejects a route from Site 1Site 1 and Site 2 both use AS 64500 and connect through a provider in AS 64501. Site 1 advertises 192.0.2.0/24. The provider passes it to Site 2 with the AS path 64501 64500. Site 2 finds its own AS number in the path and drops the route.Site 1AS 64500ProviderAS 64501Site 2AS 64500192.0.2.0/24192.0.2.0/24Path: (empty)Path: 64500Path: 64501 64500Site 2 sees its own 64500 and drops the route

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Loop prevention cannot tell a real loop from two sites that share an AS number. allowas-in on Site 2, or as-override on the provider, resolves it.

Site 1 advertises a prefix. The provider passes it to Site 2 with the path 64501 64500, and Site 2, which is also AS 64500, sees its own number and drops the route. Two ways to solve this:

Fix it on the receiver or on the sender
Fix it on the receiver or on the senderallowas-in and as-override.allowas-inOn the receiverAccepts its own ASUp to 3 times by defaultas-overrideOn the sender (PE)Replaces customer ASwith the provider ASor

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Use as-override when you control the provider side. Use allowas-in when you control only the customer router.
router bgp 64500 address-family ipv4 unicast neighbor 192.0.2.1 allowas-in 1

Customer router at Site 2. Accepts routes that contain its own AS number once. Without a number the default is 3.

router bgp 64501 address-family ipv4 unicast neighbor 192.0.2.2 as-override

Provider router facing Site 2. When sending routes to this neighbour, replaces any occurrence of the neighbour's AS (64500) in the path with 64501.

Technical reference: RFC 5082, The Generalized TTL Security Mechanism (GTSM). Output above is illustrative.

Check your understanding

Predict · scenario 1

A customer leaks 400000 routes to a router that has maximum-prefix 1000 80 configured with no other options. What does the session do?

Predict · scenario 2

You configure ttl-security hops 1 on R1 only. What is the likely result?

Predict · scenario 3

Two sites share AS 64500 through a provider. Site 2 drops routes from Site 1. Which provider-side setting fixes this?

FAQ

What happens when maximum-prefix is exceeded?
By default the router sends a Cease NOTIFICATION and closes the session. It stays down until you clear it, unless you configured a restart interval, or warning-only to log without closing.
Can I use ttl-security with ebgp-multihop?
No. They are mutually exclusive. ttl-security hops N already allows a peer up to N hops away.
What is the difference between allowas-in and as-override?
allowas-in is configured on the receiver and accepts routes that contain its own AS. as-override is configured on the sender and replaces the receiver's AS in the path, so the route is never rejected.