BGP AS Path Filter Example

Hi Rene,

 

urgent help…what if your advertising subnet is coming in as /24, however you want to send it out to the customer for argument sake as separate slash /32 addresses?

example:

192.168.1.0/24

want to advertise this via bgp as /32

192.168.1.8

192.168.1.9

and so on?

Hi Adil,

Normally it’s the other way around, people want to advertise larger prefixes, not smaller :slight_smile:

I don’t think there’s an easy answer to this. You can’t summarize from /24 to /32. It would be best if they advertise /32 routes in the first place to you.

If you want to do it on your router then I guess you could use an EEM script that installs /32 routes to the same next hop of your /24 route and then advertise these (with a BGP condition map) to your other neighbor.

Rene

Very nice post, have been struggling in this topic, now problem solved

Rene, I have a question about using the same route-map to both set local preference and match an as-path access-list at the same time. Basically I want to set local pref on a specific neighbor, but also filter the routes they are sending. Could I do this in the same route-map, since they would both have to be in-bound?

Something like this (please let me know if this will work or not)

ip as-path access-list 1
 permit ^46435_[0-9]*$
!
route-map filter-and-local-pref permit 10
 set local-preference 200
route-map filter-and-local-pref permit 20
 match as-path 1 
!
neighbor x.x.x.x route-map filter-and-local-pref in

I just had a thought… maybe I should use a filter-list inbound on the neighbor and just use the route-map for setting local pref. So, something like this…

ip as-path access-list 1
permit ^46435_[0-9]*$
!
route-map localpref permit 10
 set local-preference 200
!
neighbor x.x.x.x route-map localpref in
neighbor x.x.x.x filter-list 1 in

Hi @cradlepoint,

It is possible to mix route-maps, filter-lists, distribute-lists etc. but it’s better to stick to a single route-map.

The route-map can do everything you want and it allows you to keep everything in one place. If you want to match on an AS path and set the local preference for those routes, you can do something like this:

ip as-path access-list 1
 permit ^46435_[0-9]*$
!
route-map filter-and-local-pref permit 10
  match as-path 1
 set local-preference 200
!
neighbor x.x.x.x route-map filter-and-local-pref in

Without the empty permit 20 statement, all other prefixes that don’t match your AS path will be denied.

Rene

Hi Rene,

Will BGP AS Path Filter work if I have only one IP transit provider (default) and this provider doesn’t support any BGP communities? I want to announce my routes only to few my providers upstreams and to stop incoming traffic from others.

Hi Mikhail,

The AS path will always be in your BGP updates so yes, you don’t need communities for that.

Rene

Is there a show command for as-paths access-lists, or do you need to filter it out of the running config?

Hello Chris

The command show ip as-path access-list displays information about IP AS path access lists.

I hope this has been helpful!

Laz

Hello

please If I have below configuration , what does it do?

route-map CC-IN, deny, sequence 2
  Match clauses:
    as-path (as-path filter): 15 
  Set clauses:
  Policy routing matches: 0 packets, 0 bytes

show ip as-path-access-list 15
AS path access list 15
     permit ^39216$

  neighbor 192.168.100.1 route-map CC-IN in

thanks for your support.

Hi Rawaz,

The first statement (sequence 2) denies everything in AS-path 15.

AS path access-list 15 matches only on AS number 39216, nothing else.

Your route-map, however, doesn’t have any permit statements, so because of the implicit (invisible) deny any, everything will be denied.

If your goal is to deny only whatever you have in AS path access-list 15, add an additional sequence number in your route-map. Something like:

route-map CC-IN permit 10

The things you then deny in sequence 2 are denied, and everything else will be permitted because of sequence 10 (which is empty which means it matches on everything).

Hope this helps!

Rene

Can AS-Path Prepend be used to influence incoming routes, outgoing routes, or both? Thank you

Hello Brian

AS-Path Prepend is used to influence incoming traffic. What it does is a router adds its own AS multiple times in the AS path, thus making this path appear longer, and thus less favourable. Like all methods of influencing incoming traffic, it can always be overridden by the routers in other AS’s.

Take a look at the relevant lesson below for more information:

I hope this has been helpful!

Laz

1 Like

for this issue: Deny prefixes that originated from AS 56203 and permit everything else
why cant we use
ip as-path access-list 1 deny ^56203$ <-- then you are only matching an AS path that only has 56203 in it and nothing else
ip as-path access-list 1 permit .*

Please advise. Thanks

I think I got it. Cant use ^ coz it means it has to be a directly connect AS or the 1st AS in path.
Am i right ?

Hello Sahil

Yes you are correct. When you use the “^” you are indicating that ONLY this AS is being matched. However, using _56203$ you are matching strings that END with 56203 which means that such prefixes ORIGINATED from AS 56203.

I hope this has been helpful!

Laz

I did try to run some of the examples. I unfortunately got the issue in the printscreen attached. When I copy/past a command in the telnet windows, all spaces are removed, except the one after “show”.

Hello Maodo

This may have something to do with the way in which the windows Command Line application interprets the spaces copied from a web page. If you want to copy and paste commands, I suggest you first paste them into Notepad, make sure they are correct, and then copy them from there and paste them into the command line. This will ensure that the spaces are correctly interpreted and pasted. Alternatively, you can simply type the commands in.

I hope this has been helpful!

Laz

Issue solved.

Telneting route-server.as3257.net does allow only the show route command. Pasting any other show command does recognize only show, then one space, and the concatenation of all the following words (without keeping spaces between them).

Telnetting route-views.optus.net.au did allow me to try all the commands in the article.

1 Like