Saturday, 9 May 2020

BGP CHAPTER 15 - BGP - AS PATH PREPEND

Today in this post we will focus on an very important BGP Attribute -AS PATH . 

We will also how we can use AS-PATH PREPEND to manipulate the path selection .


AS PATH ATTRIBUTE 

  • It is well-known Mandatory attribute 
  • Present in each and every BGP update.
  • When a BGP router sends a update to its eBGP neighbor it adds its own AS number to the left of the AS path.
  • The AS Path allows us to see  which autonomous system needs to be crossed inorder to reach the destination.
  • When a router receives a route and which includes its own AS number the router will not accept the router . 
  • BGP AS PATH attributes is also used in loop prevention.  
  • BGP refers shortest AS path to reach the destination 
Lets see an lab for AS Path and also we will see how we can use AS Path prepending to manipulate the path selection .


Lets check the interfaces of all the routers - R1 , R2 ,R3 and R4

R1#sh int des
Interface                      Status         Protocol Description
Fa0                            admin down     down
Se0                            up             up       to R2
Se1                            up             up       to R3
Se2                            admin down     down
Se3                            admin down     down
R1#
R1#sh ip int brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0              unassigned      YES NVRAM  administratively down down
Serial0                    12.0.0.1        YES NVRAM  up                    up
Serial1                    13.0.0.1        YES NVRAM  up                    up
Serial2                    unassigned      YES NVRAM  administratively down down
Serial3                    unassigned      YES NVRAM  administratively down down

R2#sh int des
Interface                      Status         Protocol Description
Fa0                            admin down     down
Se0                            up             up       to R1
Se1                            up             up       to R4
Se2                            admin down     down
Se3                            admin down     down
R2#sh ip int brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0              unassigned      YES NVRAM  administratively down down
Serial0                    12.0.0.2        YES NVRAM  up                    up
Serial1                    24.0.0.2        YES NVRAM  up                    up
Serial2                    unassigned      YES NVRAM  administratively down down
Serial3                    unassigned      YES NVRAM  administratively down down

R3#sh int des
Interface                      Status         Protocol Description
Fa0                            admin down     down
Se0                            up             up       to R4
Se1                            up             up       to R1
Se2                            admin down     down
Se3                            admin down     down
R3#sh ip int brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0              unassigned      YES NVRAM  administratively down down
Serial0                    34.0.0.3        YES NVRAM  up                    up
Serial1                    13.0.0.3        YES NVRAM  up                    up
Serial2                    unassigned      YES NVRAM  administratively down down
Serial3                    unassigned      YES NVRAM  administratively down down

R4#sh int des
Interface                      Status         Protocol Description
Fa0                            admin down     down
Se0                            up             up       to R3
Se1                            up             up       to R2
Se2                            admin down     down
Se3                            admin down     down
R4#
R4#sh ip int brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0              unassigned      YES NVRAM  administratively down down
Serial0                    34.0.0.4        YES NVRAM  up                    up
Serial1                    24.0.0.4        YES NVRAM  up                    up
Serial2                    unassigned      YES NVRAM  administratively down down
Serial3                    unassigned      YES NVRAM  administratively down down

BGP Configuration is already done , lets check out the BGP Configuration and BGP Neighborship.

R1#sh run | section bgp
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 neighbor 12.0.0.2 remote-as 200
 neighbor 13.0.0.3 remote-as 300
 no auto-summary


R1#sh ip bgp summary
BGP router identifier 13.0.0.1, local AS number 100
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
12.0.0.2            4   200      19         19                1           0    0       00:16:15        0
13.0.0.3            4   300      19         19                1           0    0       00:16:12        0

R2#sh run | section bgp
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 neighbor 12.0.0.1 remote-as 100
 neighbor 24.0.0.4 remote-as 200
 no auto-summary


R2#sh ip bgp summ
BGP router identifier 24.0.0.2, local AS number 200
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
12.0.0.1          4   100      20           20             1            0    0         00:17:51        0
24.0.0.4          4   200      20           20             1            0    0         00:17:48        0

R3#sh run | section bgp
router bgp 300
 no synchronization
 bgp log-neighbor-changes
 network 100.0.0.0 mask 255.255.255.0
 neighbor 13.0.0.1 remote-as 100
 neighbor 34.0.0.4 remote-as 200
 no auto-summary

R3#sh ip bgp sum
BGP router identifier 34.0.0.3, local AS number 300
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
13.0.0.1          4   100      22           22              1          0    0          00:19:40        0
34.0.0.4          4   200      22           22              1          0    0          00:19:40        0

R4#sh run | section bgp
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 neighbor 24.0.0.2 remote-as 200
 neighbor 24.0.0.2 next-hop-self
 neighbor 34.0.0.3 remote-as 300
 no auto-summary


R4#sh ip bgp summary
BGP router identifier 34.0.0.4, local AS number 200
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
24.0.0.2          4    200      28         28               1           0    0          00:25:03        0
34.0.0.3         4     300      28         28               1           0    0          00:25:02        0

Lets configure a loopback interface on R3 

R3(config)#int loopback 0
R3(config-if)#ip address 100.0.0.1 255.255.255.0
R3(config-if)#^Z

Advertising the network 100.0.0.0/24 in BGP on R3

R3#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#router bgp 300
R3(config-router)#network 100.0.0.0 mask 255.255.255.0
R3(config-router)#^Z

Now we check on R1 that the network is learnt via two paths -

- path 1 - AS200 -AS300
- path 2- AS 300


R1#sh ip bgp
BGP table version is 4, local router ID is 13.0.0.1
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
*  100.0.0.0/24     12.0.0.2                                            0       200 300 i
*>                         13.0.0.3                 0                         0       300 i

& we can see that path2 is best path .

Now lets manipulate the path selection and make Path1 as best path by  using AS Path prepending.

Let us first understand what is AS Path Prepend

AS Path Prepend 

AS Path Prepend means adding one or more AS number to the left side of the AS Path.

R1(config)#route-map TECHSTUFF

R1(config-route-map)#set as-path ?
  prepend  Prepend to the as-path
  tag      Set the tag as an AS-path attribute

R1(config-route-map)#set as-path pre
R1(config-route-map)#set as-path prepend ?
  <1-65535>  AS number
  last-as    Prepend last AS to the as-path
  <cr>

R1(config-route-map)#set as-path prepend 299 298 297
R1(config-route-map)#^Z

R1(config)#router bgp 100
R1(config-router)#neighbor 13.0.0.3 route-map TECHSTUFF ?
  in   Apply map to incoming routes
  out  Apply map to outbound routes

R1(config-router)#neighbor 13.0.0.3 route-map TECHSTUFF in
R1(config-router)#^Z

R1#clear ip bgp * soft in

R1#sh ip bgp
BGP table version is 3, local router ID is 13.0.0.1
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
*  100.0.0.0/24     13.0.0.3                 0                     0       299 298 297 300 i
*>                         12.0.0.2                                        0       200 300 i


As we can check now that the path2 via R2 is best path .


In this way we can use AS Prepend to manipulate the path selection by adding AS Path on left of AS path.


Hope this is informative !!!!!!

Thanks for reading

No comments:

Post a Comment