Friday, June 8, 2012

Configuring BGP - Local AS - One router multiple ASN

Wouldn't it be awesome if you had two first names and you had the choice to use whichever one you wanted based on some criteria? Well in BGP your first names are your ASN (Autonomous System Numbers). In BGP you can only spin up one instance of BGP with an ASN unlike OSPF or other routing protocols. For example, you will get this error message if you try to spin up more than one instance.


R2(config)#router bgp 200
R2(config-router)#exit
R2(config)#router bgp 201
BGP is already running; AS is 200

So what do you do when you need to have more than one ASN number on the same router? This is where local-as comes in handy. 

Consider this simple topology below and let's get started. 
Our objective here is to get R2 to peer with R3 using ASN 200 and R2 to peer with R4 using ASN 201. 

First, as usual let's get our interfaces configured. 

R2 interface configuration

R3 interface configuration

R4 interface configuration
Now let's get the BGP configured. 

Notice the command local-as which states that R2 should use 201 as its ASN when peering with R4 (2.2.2.2)

R3 BGP configuration

R4 BGP configuration. Notice in the neighbor statement ASN 201 and BGP is established.
Let's now advertise a route to R4 and see take a look at the AS PATH. 

R2(config)#ip route 10.10.10.10 255.255.255.255 null 0
R2(config)#router bgp 200
R2(config-router)#network 10.10.10.10 mask 255.255.255.255

R4#show ip bgp
BGP table version is 2, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.10.10.10/32   2.2.2.1                  0             0 201 200 i

Notice that the AS PATH contains the original ASN of 200. To remove this you can type 'neighbor 2.2.2.2 local-as 201 no-prepend replace-as' on R2. 

R2#sh run | sec bgp
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 network 10.10.10.10 mask 255.255.255.255
 neighbor 1.1.1.2 remote-as 300
 neighbor 2.2.2.2 remote-as 400
 neighbor 2.2.2.2 local-as 201 no-prepend replace-as
 no auto-summary


Now notice the R4 AS PATH. ASN 200 is no longer in the AS PATH. 


R4#sh ip bgp
BGP table version is 4, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.10.10.10/32   2.2.2.1                  0             0 201 i

Conclusion:

local-as comes in handy when you want to run multiple ASN in the same router. The no-prepend option is available for special cases where iBGP peers wont accept routes when they see their own ASN in the AS PATH. 

Many more articles to come so stay tuned. 

If you like my posts please comment/subscribe/+1. 

Thank you.