Module 4: BGP Policy·Lesson 4.2 (2 of 8 in this module)·24 of 43 in the BGP course
Inbound and outbound filtering
A customer network with two ISPs can accidentally become a path between them. Filtering is what stops that: you decide what to accept, and you decide what to say.
Advanced · 14 min read
You'll learn to choose the right filter for a goal, apply it in the right direction, and stop the company AS from acting as a transit network between its two providers.
Where you can filter
Every BGP session has an inbound side and an outbound side. Inbound policy runs on routes a neighbour sends, before they enter your BGP table. Outbound policy runs on routes you are about to send. Choose the side by the goal: protect yourself with inbound, control what others learn with outbound.
Two policy points on every session, and why outbound filters matter
On small screens, swipe sideways or focus the diagram and use the arrow keys.
On small screens, swipe sideways or focus the diagram and use the arrow keys.
If you need an action as well as a match, you need a route map.
Pick the filter by what you need to match
On small screens, swipe sideways or focus the diagram and use the arrow keys.
Read each row across: the left box names the item, the others describe it.
Stop the company becoming a transit AS
The company AS should hand each ISP only its own routes. An AS-path list can say exactly that: ^$ matches an empty AS path, which is how a route looks when it originated in your own AS and has not yet left.
Without and with an outbound filter
On small screens, swipe sideways or focus the diagram and use the arrow keys.
A transit leak sends other networks traffic through your links.
ip as-path access-list 10 permit ^$
router bgp 64500
address-family ipv4 unicast
neighbor 192.0.2.1 filter-list 10 out
neighbor 192.0.2.5 filter-list 10 out
R1 and R2 apply to their own provider only. Only routes with an empty AS path, meaning the company's own, are advertised.
This works together with the prefix lists from earlier lessons. The prefix list limits which networks, the AS-path list limits where they came from, and either one alone already prevents transit.
Illustrative Cisco IOS XE output written for this lesson, not a router capture
R1#show ip bgp neighbors 192.0.2.1 advertised-routes
Network Next Hop Metric LocPrf Weight Path
*> 198.51.100.0 0.0.0.0 0 32768 i
Total number of prefixes 1
Only the company prefix is advertised. If you see an ISP B route here, the filter is missing or applied in the wrong direction.
Filter inbound as well
ip prefix-list NO-DEFAULT seq 10 deny 0.0.0.0/0
ip prefix-list NO-DEFAULT seq 20 permit 0.0.0.0/0 le 24
router bgp 64500
address-family ipv4 unicast
neighbor 192.0.2.1 prefix-list NO-DEFAULT in
Reject a default route from a provider and accept anything up to /24. Adjust to what the provider has agreed to send.
To test a policy change without bringing the session down, use a soft reset. The next lesson explains why that is safe.
Inbound filters protect you
On small screens, swipe sideways or focus the diagram and use the arrow keys.
Typical rejects: default (if unwanted), private ranges and your own prefix.
You want to stop the company advertising ISP A's routes to ISP B. Which filter fits best?
Predict · scenario 2
A provider mistakenly sends you a default route. Which direction should the protecting filter be applied?
Predict · scenario 3
Which command applies an AS-path access list to a neighbour?
FAQ
Why filter inbound when the ISP already filters?
You cannot rely on another network's configuration. Accepting only the prefixes you expect protects your routing table from a provider's mistake, such as a leaked default route or someone else's address space.
How does a company AS become a transit AS?
If R1 advertises routes learned from ISP A to ISP B, ISP B can send traffic for ISP A's networks through the company. Advertising only the company's own prefixes to each provider prevents it.
Prefix list or AS-path list?
Use a prefix list to match networks and an AS-path access list to match where a route came from. A common outbound pair is: only prefixes originated in my AS.