Playing with BGP Local-AS
In some situation you might have to change the BGP AS number used by a router. When the router peers with several other routers it is not always easy to change all the peering at the same time… Luckily you may do it one by one with the “local-as” neighbor command under bgp process.
This small article shows the different options of local-as command and their impact on the received and advertised routes.
First let’s have a look at the test setup before we use local-as

Now let’s say we want to change the local AS from 12 to 1200 without having to reconfigure the complete AS… We can achieve this with local-as. With local-as alone, the real AS# and the local AS# are in the AS_PATH

R2(config-router)#do sh run | s router bgp router bgp 12 no synchronization bgp log-neighbor-changes neighbor 10.10.12.1 remote-as 12 neighbor 10.10.23.3 remote-as 34 neighbor 10.10.23.3 local-as 1200 no auto-summary R1(config-router)#do sh ip bgp BGP table version is 11, local router ID is 11.11.11.11 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 *> 11.11.11.11/32 0.0.0.0 0 32768 i *> 44.44.44.44/32 10.10.12.2 0 0 1200 34 i R4(config-router)#do sh ip bgp BGP table version is 10, local router ID is 44.44.44.44 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 *> 11.11.11.11/32 10.10.34.3 0 0 1200 12 i *> 44.44.44.44/32 0.0.0.0 0 32768 i
With local-as no-prepend, same results for the advertise routes. Received routes’s AS_PATH do not contain the “fake” AS number. “no-prepend” is used to prevent incoming eBGP updates to be prepended with the configured local AS#. From that perspective, it looks a bit like confederations.

R2(config-router)#do sh run | s router bgp router bgp 12 no synchronization bgp log-neighbor-changes neighbor 10.10.12.1 remote-as 12 neighbor 10.10.23.3 remote-as 34 neighbor 10.10.23.3 local-as 1200 no-prepend no auto-summary R1(config-router)#do sh ip bgp BGP table version is 11, local router ID is 11.11.11.11 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 *> 11.11.11.11/32 0.0.0.0 0 32768 i *> 44.44.44.44/32 10.10.12.2 0 0 34 i R4(config-router)#do sh ip bgp BGP table version is 10, local router ID is 44.44.44.44 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 *> 11.11.11.11/32 10.10.34.3 0 0 1200 12 i *> 44.44.44.44/32 0.0.0.0 0 32768 i
With local-as no-prepend replace-as, received routes’s AS_PATH do not contain the “fake” AS number. The real AS number do not appear in the AS_PATH of the advertised routes, it is replaced by the configure local AS#. In that perspective, it looks a bit like confederations…

R2(config-router)#do sh run | s router bgp router bgp 12 no synchronization bgp log-neighbor-changes neighbor 10.10.12.1 remote-as 12 neighbor 10.10.23.3 remote-as 34 neighbor 10.10.23.3 local-as 1200 no-prepend replace-as no auto-summary R1(config-router)#do sh ip bgp BGP table version is 11, local router ID is 11.11.11.11 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 *> 11.11.11.11/32 0.0.0.0 0 32768 i *> 44.44.44.44/32 10.10.12.2 0 0 34 i R4(config-router)#do sh ip bgp BGP table version is 10, local router ID is 44.44.44.44 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 *> 11.11.11.11/32 10.10.34.3 0 0 1200 i *> 44.44.44.44/32 0.0.0.0 0 32768 i