cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
91064
Views
5
Helpful
0
Comments
Edgar c Francis
Spotlight
Spotlight

 

BGP AS Path Prepending

 

AS Path is the fourth BGP attribute, AS Path is well known, mandatory attribute. BGP prefer the shortest AS path to get to destination. In other words path with shortest AS path list is more desirable.

 

 

You can manipulate this by using AS path prepending . Manual manipulation of AS path length is called AS path prepending.  The AS path should be extended with multiple copies of the AS number of the sender.

 

AS path prepending is used to:

  1.     

 

  1.             Ensure proper return path selection.
  2.        .    Distribution the traffic load for multi-homed customers.

 

 

Results of AS path prepending can be observed on the receiving router.

 

let see the configuration :-https://www.internetworks.in/2019/03/bgp-as-path-prepending.html

 

Topology:

as path prepending.png

 

Goal:

 

  • configure the topology as per the diagram and assign the IP address as per the topology.
  • configure IBGP and EBGP.
  • configure AS 650014 to ensure that all routes in AS 650014 should exit router_1 to reach AS 650003 (30.0.0.0) prefix.
  • configure AS 650014 to ensure that the traffic from 30.0.0.0 to 10.0.0.0 return traffic should use the same path as forwarding traffic routers_1_2_3.

 

 

 

R1#show ip interface brief

 

Interface              IP-Address      OK? Method Status                Protocol

FastEthernet0/0        10.1.1.1        YES manual up                    up

Serial3/0                    1.1.1.1         YES manual up                    up

Serial3/3                    4.1.1.2         YES manual up                    up

Loopback0               11.0.0.1        YES manual up                    up

 

 

R2#show ip interface brief

 

Interface              IP-Address      OK? Method Status                Protocol

FastEthernet0/0        20.1.1.1        YES manual up                    up

Serial3/0                    1.1.1.2         YES manual up                    up

Serial3/1                    2.1.1.1         YES manual up                    up

Loopback0               12.0.0.1        YES manual up                    up

 

 

R3#show ip interface brief

 

Interface              IP-Address      OK? Method Status                Protocol

FastEthernet0/0        30.1.1.1        YES manual up                    up

Serial3/1                    2.1.1.2         YES manual up                    up

Serial3/2                    3.1.1.1         YES manual up                    up

Loopback0               13.0.0.1        YES manual up                    up

 

R4#show ip interface brief

Interface              IP-Address      OK? Method Status                Protocol

FastEthernet0/0        40.1.1.1        YES manual up                    up

Serial3/2                    3.1.1.2         YES manual up                    up

Serial3/3                    4.1.1.1         YES manual up                    up

Loopback0               14.0.0.1        YES manual up                    up

 

 

 


R1(config)#router bgp 650014
R1(config-router)#neighbor 4.1.1.1 remote-as 650014
R1(config-router)#neighbor 1.1.1.2 remote-as 650002
R1(config-router)#network 10.0.0.0
R1(config-router)#network 1.0.0.0
R1(config-router)#network 4.0.0.0
R1(config-router)#network 11.0.0.0 mask 255.255.255.0
R1(config-router)#exit

 

R2(config)#router bgp 650002

R2(config-router)#neighbor 1.1.1.1 remote-as 650014

 

*Mar 13 12:23:30.111: %BGP-5-ADJCHANGE: neighbor 1.1.1.1 Up

 

R2(config-router)#neighbor 2.1.1.2 remote-as 650003

R2(config-router)#network 20.0.0.0

R2(config-router)#network 1.0.0.0

R2(config-router)#network 2.0.0.0

R2(config-router)#network 12.0.0.0 mask 255.255.255.0

R2(config-router)#exit

 

R3(config)#router bgp 650003

R3(config-router)#neighbor 2.1.1.1 remote-as 650002

 

*Mar 13 12:25:42.495: %BGP-5-ADJCHANGE: neighbor 2.1.1.1 Up

 

R3(config-router)#neighbor 3.1.1.2 remote-as 650014

R3(config-router)#network 30.0.0.0

R3(config-router)#network 3.0.0.0

R3(config-router)#network 2.0.0.0

R3(config-router)#network 13.0.0.0 mask 255.255.255.0

R3(config-router)#exit

 

R4(config)#router bgp 650014

R4(config-router)#neighbor 3.1.1.1 remote-as 650003

 

*Mar 13 12:27:46.807: %BGP-5-ADJCHANGE: neighbor 3.1.1.1 Up

 

R4(config-router)#neighbor 4.1.1.2 remote-as 650014

 

*Mar 13 12:28:10.663: %BGP-5-ADJCHANGE: neighbor 4.1.1.2 Up

 

R4(config-router)#network 40.0.0.0

R4(config-router)#network 4.0.0.0

R4(config-router)#network 3.0.0.0

R4(config-router)#network 14.0.0.0 mask 255.255.255.0

R4(config-router)#exit

 

R1#show ip bgp summary

BGP router identifier 11.0.0.1, local AS number 650014

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

1.1.1.2         4       650002      14      16       21    0    0 00:08:00        7

4.1.1.1         4       650014      14      13       21    0    0 00:03:19        7

 

R2#show ip bgp summary

BGP router identifier 12.0.0.1, local AS number 650002

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

1.1.1.1         4       650014      17      15       14    0    0 00:09:06        9

2.1.1.2         4       650003      12      15       14    0    0 00:06:54        9

 

R3#show ip bgp summary

BGP router identifier 13.0.0.1, local AS number 650003

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

2.1.1.1         4       650002      16      13       18    0    0 00:07:58        9

3.1.1.2         4       650014      12      16       18    0    0 00:05:54        9

 

R4#sh ip bgp summary

BGP router identifier 14.0.0.1, local AS number 650014

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

3.1.1.1         4       650003      17      12       18    0    0 00:06:20        7

4.1.1.2         4       650014      15      17       18    0    0 00:05:56        7

 

R3#show ip bgp

BGP table version is 18, 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, m multipath, b backup-path, f RT-Filter,

              x best-external, a additional-path, c RIB-compressed,

Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

 

     Network          Next Hop            Metric LocPrf Weight Path

 *   1.0.0.0          3.1.1.2                                0 650014 i

 *>                   2.1.1.1                  0             0 650002 i

 *>  2.0.0.0          0.0.0.0                  0         32768 i

 *                    2.1.1.1                  0             0 650002 i

 *   3.0.0.0          3.1.1.2                  0             0 650014 i

 *>                   0.0.0.0                  0         32768 i

 *>  4.0.0.0          3.1.1.2                  0             0 650014 i

 *                    2.1.1.1                                0 650002 650014 i

 *>  10.0.0.0         3.1.1.2                                0 650014 i

 *                    2.1.1.1                                0 650002 650014 i

 *>  11.0.0.0/24      3.1.1.2                                0 650014 i

 *                    2.1.1.1                                0 650002 650014 i

 *   12.0.0.0/24      3.1.1.2                                0 650014 650002 i

 *>                   2.1.1.1                  0             0 650002 i

     Network          Next Hop            Metric LocPrf Weight Path

 *>  13.0.0.0/24      0.0.0.0                  0         32768 i

 *   14.0.0.0/24      2.1.1.1                                0 650002 650014 i

 *>                   3.1.1.2                  0             0 650014 i

 *   20.0.0.0         3.1.1.2                                0 650014 650002 i

 *>                   2.1.1.1                  0             0 650002 i

 *>  30.0.0.0         0.0.0.0                  0         32768 i

 *>  40.0.0.0         3.1.1.2                  0             0 650014 i

 *                    2.1.1.1                                0 650002 650014 i

 

R1#show ip bgp

BGP table version is 21, local router ID is 11.0.0.1

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,

              x best-external, a additional-path, c RIB-compressed,

Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

 

     Network          Next Hop            Metric LocPrf Weight Path

 *   1.0.0.0          1.1.1.2                  0             0 650002 i

 *>                   0.0.0.0                  0         32768 i

 * i 2.0.0.0          3.1.1.1                  0    100      0 650003 i

 *>                   1.1.1.2                  0             0 650002 i

 *>i 3.0.0.0          4.1.1.1                  0    100      0 i

 *                    1.1.1.2                                0 650002 650003 i

 * i 4.0.0.0          4.1.1.1                  0    100      0 i

 *>                   0.0.0.0                  0         32768 i

 *>  10.0.0.0         0.0.0.0                  0         32768 i

 *>  11.0.0.0/24      0.0.0.0                  0         32768 i

 *>  12.0.0.0/24      1.1.1.2                  0             0 650002 i

 *>i 13.0.0.0/24      3.1.1.1                  0    100      0 650003 i

 *                    1.1.1.2                                0 650002 650003 i

 *>i 14.0.0.0/24      4.1.1.1                  0    100      0 i

     Network          Next Hop            Metric LocPrf Weight Path

 *>  20.0.0.0         1.1.1.2                  0             0 650002 i

 *>i 30.0.0.0         3.1.1.1                  0    100      0 650003 i

 *                    1.1.1.2                                0 650002 650003 i

 *>i 40.0.0.0         4.1.1.1                  0    100      0 i

 

R1#show ip bgp 30.1.1.1

BGP routing table entry for 30.0.0.0/8, version 20

Paths: (2 available, best #1, table default)

  Advertised to update-groups:

     1

  Refresh Epoch 1

  650003

    3.1.1.1 from 4.1.1.1 (14.0.0.1)

      Origin IGP, metric 0, localpref 100, valid, internal, best

      rx pathid: 0, tx pathid: 0x0

  Refresh Epoch 1

  650002 650003

    1.1.1.2 from 1.1.1.2 (12.0.0.1)

      Origin IGP, localpref 100, valid, external

      rx pathid: 0, tx pathid: 0

 

 ( by default AS_650014 EXIT VIA R4 to reach AS 650003 route (30.0.0.0) prefix because of shortest AS-PATH)

 

 

R1(config)# access-list 10 permit 30.0.0.0 0.255.255.255

 

R1(config)#route-map cisco permit 10

R1(config-route-map)#match ip address 10

R1(config-route-map)#set local-preference 300

R1(config-route-map)#exit

 

R1(config)#route-map cisco permit 20

R1(config-route-map)#exit

 

 

 

 

R1#show ip bgp 30.1.1.1

BGP routing table entry for 30.0.0.0/8, version 22

Paths: (1 available, best #1, table default)

  Advertised to update-groups:

     2

  Refresh Epoch 2

  650002 650003

    1.1.1.2 from 1.1.1.2 (12.0.0.1)

      Origin IGP, localpref 300, valid, external, best

      rx pathid: 0, tx pathid: 0x0

 

 

                                               ( now configure return traffic)

 

 

R3#show ip bgp

BGP table version is 18, 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, m multipath, b backup-path, f RT-Filter,

              x best-external, a additional-path, c RIB-compressed,

Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

 

     Network          Next Hop            Metric LocPrf Weight Path

 *   1.0.0.0          3.1.1.2                                0 650014 i

 *>                   2.1.1.1                  0             0 650002 i

 *>  2.0.0.0          0.0.0.0                  0         32768 i

 *                    2.1.1.1                  0             0 650002 i

 *   3.0.0.0          3.1.1.2                  0             0 650014 i

 *>                   0.0.0.0                  0         32768 i

 *>  4.0.0.0          3.1.1.2                  0             0 650014 i

 *                    2.1.1.1                                0 650002 650014 i

 *>  10.0.0.0         3.1.1.2                                0 650014 i

 *                    2.1.1.1                                0 650002 650014 i

 *>  11.0.0.0/24      3.1.1.2                                0 650014 i

 *                    2.1.1.1                                0 650002 650014 i

 *   12.0.0.0/24      3.1.1.2                                0 650014 650002 i

 *>                   2.1.1.1                  0             0 650002 i

     Network          Next Hop            Metric LocPrf Weight Path

 *>  13.0.0.0/24      0.0.0.0                  0         32768 i

 *   14.0.0.0/24      2.1.1.1                                0 650002 650014 i

 *>                   3.1.1.2                  0             0 650014 i

 *   20.0.0.0         3.1.1.2                                0 650014 650002 i

 *>                   2.1.1.1                  0             0 650002 i

 *>  30.0.0.0         0.0.0.0                  0         32768 i

 *>  40.0.0.0         3.1.1.2                  0             0 650014 i

 *                    2.1.1.1                                0 650002 650014 i

 

 

 

R3#show ip bgp 10.1.1.1

BGP routing table entry for 10.0.0.0/8, version 13

Paths: (2 available, best #1, table default)

  Advertised to update-groups:

     1

  Refresh Epoch 1

  650014

    3.1.1.2 from 3.1.1.2 (14.0.0.1)

      Origin IGP, localpref 100, valid, external, best

      rx pathid: 0, tx pathid: 0x0

  Refresh Epoch 2

  650002 650014

    2.1.1.1 from 2.1.1.1 (12.0.0.1)

      Origin IGP, localpref 100, valid, external

      rx pathid: 0, tx pathid: 0

 

R4(config)#access-list 10 permit 10.0.0.0 0.255.255.255

 

R4(config)#route-map cisco permit 10

R4(config-route-map)#match ip address 10

R4(config-route-map)#set as-path prepend 650014 650014 650014 650014

R4(config-route-map)#exit

 

R4(config)#route-map cisco permit 20

R4(config-route-map)#exit

 

R4(config)#router bgp 650014

R4(config-router)#nei

R4(config-router)#neighbor 3.1.1.1 rou

R4(config-router)#neighbor 3.1.1.1 route-m

R4(config-router)#neighbor 3.1.1.1 route-map cisco out

R4(config-router)#end

 

 

 

R3#show ip bgp

BGP table version is 19, 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, m multipath, b backup-path, f RT-Filter,

              x best-external, a additional-path, c RIB-compressed,

Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

 

     Network          Next Hop            Metric LocPrf Weight Path

 *   1.0.0.0          3.1.1.2                                0 650014 i

 *>                   2.1.1.1                  0             0 650002 i

 *>  2.0.0.0          0.0.0.0                  0         32768 i

 *                    2.1.1.1                  0             0 650002 i

 *   3.0.0.0          3.1.1.2                  0             0 650014 i

 *>                   0.0.0.0                  0         32768 i

 *>  4.0.0.0          3.1.1.2                  0             0 650014 i

 *                    2.1.1.1                                0 650002 650014 i

 *   10.0.0.0         3.1.1.2                                0 650014 650014 650014 650014 650014 i

 *>                   2.1.1.1                                0 650002 650014 i

 *>  11.0.0.0/24      3.1.1.2                                0 650014 i

 *                    2.1.1.1                                0 650002 650014 i

 *   12.0.0.0/24      3.1.1.2                                0 650014 650002 i

     Network          Next Hop            Metric LocPrf Weight Path

 *>                   2.1.1.1                  0             0 650002 i

 *>  13.0.0.0/24      0.0.0.0                  0         32768 i

 *   14.0.0.0/24      2.1.1.1                                0 650002 650014 i

 *>                   3.1.1.2                  0             0 650014 i

 *   20.0.0.0         3.1.1.2                                0 650014 650002 i

 *>                   2.1.1.1                  0             0 650002 i

 *>  30.0.0.0         0.0.0.0                  0         32768 i

 *>  40.0.0.0         3.1.1.2                  0             0 650014 i

 *                    2.1.1.1                                0 650002 650014 i

 

 

R3#show ip bgp 10.1.1.1

BGP routing table entry for 10.0.0.0/8, version 19

Paths: (2 available, best #2, table default)

  Advertised to update-groups:

     1

  Refresh Epoch 3

  650014 650014 650014 650014 650014

    3.1.1.2 from 3.1.1.2 (14.0.0.1)

      Origin IGP, localpref 100, valid, external

      rx pathid: 0, tx pathid: 0

  Refresh Epoch 3

  650002 650014

    2.1.1.1 from 2.1.1.1 (12.0.0.1)

      Origin IGP, localpref 100, valid, external, best

      rx pathid: 0, tx pathid: 0x0

 

 

 

R1#traceroute 30.1.1.1

Type escape sequence to abort.

Tracing the route to 30.1.1.1

VRF info: (vrf in name/id, vrf out name/id)

  1 1.1.1.2 52 msec 56 msec 28 msec

  2 2.1.1.2 [AS 650002] 120 msec 140 msec 176 msec

 

 

R3#traceroute 10.1.1.1

Type escape sequence to abort.

Tracing the route to 10.1.1.1

VRF info: (vrf in name/id, vrf out name/id)

  1 2.1.1.1 36 msec 44 msec 64 msec

  2 1.1.1.1 [AS 650002] 112 msec 92 msec 76 msec

 

internetworks

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: