BGP Attributes - AS Prepend

In the previous posts I explained how MED and Local Preference works. In this post I will explain how as prepend works.

As prepend is commonly used to manipulate how traffic enters your network. MED does the same this is simply another way to reach the same goal.

Below the network-diagram I used for this post, it is the same network-diagram which I used in the MED post.

MPLS

On router R2 I created two loopback interfaces :

R2 :


interface Loopback1
 ip address 10.10.2.2 255.255.255.0
!
interface Loopback2
 ip address 10.10.22.22 255.255.255.0
    

On router R13 and router R6 I pointed a route towards the two loopback addresses of router R2 and advertised them via BGP :

R13 :


ip route 10.10.2.0 255.255.255.0 150.1.61.2
ip route 10.10.22.0 255.255.255.0 150.1.61.2
!
router bgp 65010
 no synchronization
 bgp log-neighbor-changes
 network 10.10.2.0 mask 255.255.255.0
 network 10.10.13.0 mask 255.255.255.0
 network 10.10.22.0 mask 255.255.255.0
 neighbor 150.1.31.3 remote-as 1
 neighbor 150.1.61.6 remote-as 65010
 no auto-summary
    

R6 :


ip route 10.10.2.0 255.255.255.0 150.1.61.2
ip route 10.10.22.0 255.255.255.0 150.1.61.2
!
router bgp 65010
 no synchronization
 bgp log-neighbor-changes
 network 10.10.2.0 mask 255.255.255.0
 network 10.10.6.0 mask 255.255.255.0
 network 10.10.22.0 mask 255.255.255.0
 neighbor 150.1.46.4 remote-as 1
 neighbor 150.1.61.13 remote-as 65010
 no auto-summary
    

Now let’s take a look at router R5’s route table to see if the routes to the loopback ip-addresses of router R2 are learned via BGP :

R5 :


R5#sh ip bgp
BGP table version is 11, local router ID is 10.10.5.5
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.2.0/24     150.1.45.4                             0 1 65010 i
*> 10.10.5.0/24     0.0.0.0                  0         32768 i
*> 10.10.6.0/24     150.1.45.4                             0 1 65010 i
*> 10.10.13.0/24    150.1.45.4                             0 1 65010 i
*> 10.10.22.0/24    150.1.45.4                             0 1 65010 i
*> 150.1.31.0/24    150.1.45.4                             0 1 ?
r> 150.1.45.0/24    150.1.45.4               0             0 1 ?
*> 150.1.46.0/24    150.1.45.4               0             0 1 ?

Now let’s do a traceroute on router R5 to the 10.10.2.2 address :


R5#traceroute 10.10.2.2

Type escape sequence to abort.
Tracing the route to 10.10.2.2

  1 150.1.45.4 256 msec 176 msec 112 msec
  2 150.1.46.6 [AS 1] 28 msec 472 msec 220 msec
  3 150.1.61.2 756 msec 640 msec *

As you can see above the traffic flows via router R4 and router R6. Next we are going to let the traffic flow via R4 -> R1 -> R3 -> R13 to router R2. We will do this using As Prepend. As Prepend is often used to manipulate the way traffic enters your network.

See below the route-map created on router R6 :

R6 :


route-map ASPREP permit 10
 set as-path prepend 65010 65010 65010
!
    

Under BGP we set the route-map out :

R6 :


router bgp 65010
 no synchronization
 bgp log-neighbor-changes
 network 10.10.2.0 mask 255.255.255.0
 network 10.10.6.0 mask 255.255.255.0
 network 10.10.22.0 mask 255.255.255.0
 neighbor 150.1.46.4 remote-as 1
 neighbor 150.1.46.4 route-map ASPREP out
 neighbor 150.1.61.13 remote-as 65010
 no auto-summary
    

Now let’s see what happens if we do a traceroute to router’s R2 loopback ip-address 10.10.2.2 :

R5 :


R5#traceroute 10.10.2.2

Type escape sequence to abort.
Tracing the route to 10.10.2.2

  1 150.1.45.4 56 msec 96 msec 80 msec
  2 150.1.14.1 216 msec 160 msec 132 msec
  3 150.1.31.3 [AS 1] 236 msec 332 msec 140 msec
  4 150.1.31.13 [AS 1] 68 msec 176 msec 80 msec
  5 150.1.61.2 344 msec *  136 msec
    

As you can see the traffic now flows via router R13

Leave a comment

Your comment