BGP Attribute AS Path Prepend Mikrotik Lab

BGP Prepend is the one of BGP attribute to select best path to destination. BGP Prepend will manipulate AS-Path to select best path. Keep in mind thet shortest AS path will selected by BGP.
AS path is route from source to destination path. Path mentioned here is an AS number of each router. For example if you from R2 (AS2) will going to R4 (AS4) you have 2 way. You can go via R3 (AS3) or R1(AS1).
to see which router you are passing through you can use /ip route print details

Before Configuring Prepend
R2 sent will use AS1 when go to 4.4.4.4/32 which is under AS4
[admin@R2] > ip route print detail where dst-address=4.4.4.4/32
Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,
B - blackhole, U - unreachable, P - prohibit
 0 ADb  dst-address=4.4.4.4/32 gateway=12.12.12.1 gateway-status=12.12.12.1 reachable via  ether1 distance=20
        scope=40 target-scope=10 bgp-as-path="1,4" bgp-origin=incomplete received-from=R1

 1  Db  dst-address=4.4.4.4/32 gateway=23.23.23.2 gateway-status=23.23.23.2 reachable via  ether2 distance=20
        scope=40 target-scope=10 bgp-as-path="3,4" bgp-origin=incomplete received-from=R3

Tracert going via R1 (AS1)
[admin@R2] > tool traceroute 4.4.4.4
 # ADDRESS          LOSS SENT    LAST     AVG    BEST   WORST STD-DEV STATUS
 1 12.12.12.1       0%    3   0.7ms     5.7     0.7    15.7     7.1
 2 4.4.4.4          0%    3   2.1ms     1.7       1     2.1     0.5

Configuring BGP Prepend
BGP prepend is set on R1, because traffic going through R1. Keep in mind that you should apply BGP prepend on link which you will not use. We will prepend 2 times.
/routing filter
add chain=prepend-4.4.4.4 disabled=yes prefix=4.4.4.4/32 set-bgp-prepend=2

You should apply prepend to link which is going to R2
/routing bgp peer set 0 out-filter=prepend-4.4.4.4

[admin@R2] > ip route print detail where dst-address=4.4.4.4/32
Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,
B - blackhole, U - unreachable, P - prohibit
 0 ADb  dst-address=4.4.4.4/32 gateway=23.23.23.2 gateway-status=23.23.23.2 reachable via  ether2 distance=20
        scope=40 target-scope=10 bgp-as-path="3,4" bgp-origin=incomplete received-from=R3

 1  Db  dst-address=4.4.4.4/32 gateway=12.12.12.1 gateway-status=12.12.12.1 reachable via  ether1 distance=20
        scope=40 target-scope=10 bgp-as-path="1,1,4" bgp-origin=incomplete received-from=R1

See on highlighted output. Because I prepend 2 times so the path will written 2 time (1,1,x) you can put as many as you want. Depending your need. Let’s me test using traceroute

[admin@R2] > tool traceroute 4.4.4.4
 # ADDRESS           LOSS SENT    LAST     AVG    BEST   WORST STD-DEV STATUS
 1 23.23.23.2        0%    6   0.9ms     1.1     0.7     2.1     0.5
 2 4.4.4.4           0%    6   1.2ms     4.3     0.9    20.5     7.3

Now traffic passing through R3 (AS3)

Tulis komentar anda... Conversion Conversion Emoticon Emoticon

Thanks for your comment