cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
897
Views
0
Helpful
8
Replies

Replace ASN bytes in BGP community

Erik Minkov
Level 1
Level 1

Hello!

 

Does IOS XR allow to edit community received from external BGP neighbor? What I want to do is to replace community ASN1:NN to ASN2:NN, keeping the last 2 bytes. Reading http://www.cisco.com/c/en/us/td/docs/routers/asr9000/software/asr9k_r5-1/routing/configuration/guide/b_routing_cg51xasr9k/b_routing_cg51xasr9k_chapter_01001.html didn't help a lot, maybe I'm missing something.

 

Thank you,

Erik

8 Replies 8

xthuijs
Cisco Employee
Cisco Employee

I dont think there is an easy way to achieve that, to do that replacing as you want it.

BUT you could do something else possibly:

keep the original community in tact, but use an RPL to identify the community and ADD some new values to the prefix on advertisement so you have both the original as well as the new values you want?

we do have variables now in XR, so you could set a variable based on a community value and re-use that somewhere else while the policy executes, but still it will be a painful exercise to split and modify communities the way you want ...

regards

xander

Thank you for your reply.

Keeping the original community is not an option for me.. Besides, I've got about 100 combinations of prefix control communities with the same ASN part. What I want is exactly to use variables and split community value into pair ASN:NN to modify them separately.

Am I right that XR doesn't allow to create variables inside route-policy or community statements (like ones in functions in common program languages)? 

Hi Erik,

starting 513 we have variables! yay :) See CSCum64512  supporting variables in policies.

Another option I was thinking of is doing something like this maybe?

  route-policy set-local-pref($as)
      if community matches-any ($as:110) then
        set local-pref 110
        pass
      endif
      if community matches-any ($as:140) then
        set local-pref 140
        pass
      endif
  end-policy

I think with these two things you can make it work the way you want to?

cheers!

xander

Variables are cool) 

The policy should be something like this:

 

route-policy change-asn-bytes($asn,$community)
var globalVar1 $asn
var globalVar2 ???
set community (globalVar1:globalVar2)
end-policy

 

The question is how to define var globalVar2) Logical operation might work:

var globalVar1 ($community AND 0x0000FFFF)

Can XR do something like that? In fact a some sort of a mask is required. 

now that I am thinking of it, we may not even need the vars!!

how about this Erik!

 

RP/0/RSP0/CPU0:A9K-BNG(config-rpl)#if community ?
  is-empty        Route has no BGP community attributes
  matches-any     The community value matches any element(s) of a community set
  matches-every   The community value matches all elements of a community set
  matches-within  Community values match atleast one element in the community set
RP/0/RSP0/CPU0:A9K-BNG(config-rpl)#if community matches-within ?
  (          Begin inline community set
  parameter  Identifier specified in the format: '$' followed by alphanumeric ch
aracters
  WORD       Community set name

 

and then set a new community.

cheers!!

xander

The problem is that I don't know how to define a new community keeping last two bytes of the matched community.

Of course in the worst case I can write about 100 if-then statements, but that's not a good idea))

Maybe ios-regex can help somehow? Though it's usually used for a match conditions

Xander,

 

I was looking for elaboration on the var feature you say is in XR 5.1.3.  I'm not finding anything.  Do you have any links or references other than the CSC case?

 

Thanks.

 

ERM

Bitwrangler for FirstLight Fiber Corp

Hi evan,

unfortunately, this is the best documentation in this discussion that I have on it.

basically the functionality allows us to save a variable for durign the policy execution and reference it in other clauses.

cheers!

xander