BGP LOCAL_PREF & AS-Prepend || BGP LAB Config || BGP Traffic Engineering

BGP LAB

BGP Lab with LOCAL_PREF & AS-Prepend

BGP Configuration is always a challenging and complex task to perform, when we implementing the BGP in an enterprise environment network. It required very deep understanding and strong network engineering skill with logical approach. This article has made it very easy for engineers to understand the BGP Concepts.

 Before going on BGP configuration, you should have at least the basic knowledge of BGP peer configuration, BGP attributes, iBGP, and eBGP, BGP Multihoming.

The BGP attributes algorithm used to find the best path selection how traffic enters or leaves an autonomous system. BGP does not use metrics to find the best path selection in a network. BGP uses path attributes to find its best path.

In this BGP Lab, we will be looking at more advanced capabilities of BGP and will eventually make you comfortable working with BGP.

Local preference and AS prepend BGP attributes most popular attributes being used in any network where BGP routing is being used.

This article will explain that how to control routing with optimal path while using BGP attributes.

Local preference and AS prepend two BGP attributes are being used in this lab, but before explain the lab configuration I would like to briefly describe about Local preference and AS prepend.


Local Preference (LOCAL_PREF) –

Let’s assume if you have multiple redundant paths in your AS, its might be important decision for routing engineering that how the inside traffic get exit to Local AS.In this case LOCAL_PREF can help to decide the exit path for any outbound traffic to your local AS.

Local preference attribute is a well-known BGP attribute and used to manipulate the best outbound path among the multiple exit point in an AS. LOCAL_PREF attribute value is exchange between iBGP routers in an AS, Also it keep informed iBGP routers how to exit the AS with preferred path for outgoing traffic.

When an iBGP speaker receives the same route more than once, they validate the local preference of the routes and pick the best route with highest preference considered it the best route and install it in routing table.

Default preference value is 100. By changing the value of LOCAL_PREF, path with higher Local preference value is becomes the preferred path.

LOCAL_PREF, path with higher Local preference value is becomes the preferred path.

Local Preference Configuration Examples –

BGP default local−preference – Option-1

Router bgp <AS>
neighbor x.x.x.x remote-as <AS>
bgp default local−preference <value>
!

Local preference with Route-Map – Option-2

Router bgp <AS>
neighbor x.x.x.x remote-as <AS>
neighbor x.x.x.x route-map Local-Map-AS200 in
!
!
route-map Local-Map-AS200 permit 10
set local-preference <Value>


 AS Prepend –

AS-Path prepend actually influence inbound traffic (the traffic that coming toward in your AS).So basically AS-Path prepending is a technique to manipulate the AS-Path attribute of a BGP route. BGP select the shortest AS path where the AS counting are less toward to a destination AS.

Let assume if you have two internet link from the different service provider (Multihoming) and both links have different bandwidth pipe (Primary link – 1 Gig and secondary link – 200 Mb).

In this scenario you will prefer incoming traffic on 1 Gig link instead 200 Mb. Since, 200 Mb will be used as a backup, if 1 Gig connection goes down. However, the question is how to control the incoming traffic and put on 1 Gig channel.

BGP AS path is a well-known mandatory attribute. AS-Path prepend methods that BGP can use to influence the choice of paths in another autonomous system is to modify the AS_PATH attribute.

Regardless, AS path prepending is probably the easiest way that one can use to influence inbound routing to your autonomous system.

Moreover, AS-Path prepend is an artificially way by adding own AS (Multiple times) advertise to a neighbor to make them consider that the path much longer than it actually is.

Due to this change the remote AS to sense it the longest path coming from neighbors AS and force them to drop the path and pick the other shortest path which engineer want to prefer.

AS prepend Configuration Example –

Router bgp <AS>
neighbor x.x.x.x remote-as <AS>
neighbor x.x.x.x route-map AS-PREPEND out
!
!
route-map AS-PREPEND permit 10
 set as-path prepend <AS> <AS> <AS>
!
!


BGP GNS3 LAB –

Let’s do the BGP Lab with LOCAL_PREF and AS prepend and see how inbound and outbound traffic engineering will be controlled with help of BGP attributes, and see how bi-directional traffic will be routing on 1 Gig Internet connection.

Local Preference used to influence Outbound Routing in an AS.
AS path-Prepend used to influence Inbound Routing to your AS.

ISP-1# Config


interface Loopback0
 ip address 10.1.1.1 255.255.255.0
!
interface Loopback1
 ip address 2.2.2.2 255.255.255.255
!
interface FastEthernet0/0
 ip address 172.16.1.1 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 172.16.3.1 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet1/0
 no ip address
 shutdown
 duplex auto
 speed auto
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 network 2.2.2.2 mask 255.255.255.255
 network 10.1.1.0 mask 255.255.255.0
 neighbor 172.16.1.2 remote-as 200
 neighbor 172.16.3.2 remote-as 1000
 no auto-summary
!

ISP-2# Config


interface FastEthernet0/0
 ip address 172.16.2.1 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 172.16.4.1 255.255.255.252
 duplex auto
 speed auto
!
router bgp 500
 no synchronization
 bgp log-neighbor-changes
 neighbor 172.16.2.2 remote-as 200
 neighbor 172.16.4.2 remote-as 1000
 no auto-summary
!
ip forward-protocol nd
!

R1# Config


interface FastEthernet0/0
 ip address 172.16.1.2 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 192.168.10.1 255.255.255.0
 duplex auto
 speed auto
 standby 0 ip 192.168.10.100
 standby 0 priority 150
 standby 0 preempt
!
router bgp 200
 no synchronization
 bgp default local-preference 200
 bgp log-neighbor-changes
 network 192.168.2.0
 network 192.168.10.0
 neighbor 172.16.1.1 remote-as 100
 neighbor 192.168.10.2 remote-as 200
 neighbor 192.168.10.2 next-hop-self
 no auto-summary
!
ip forward-protocol nd
ip route 192.168.2.0 255.255.255.0 192.168.10.10
!

R2# Config


interface FastEthernet0/0
 ip address 172.16.2.2 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 192.168.10.2 255.255.255.0
 duplex auto
 speed auto
 standby 0 ip 192.168.10.100
 standby 0 priority 145
 standby 0 preempt
!
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 network 192.168.2.0
 network 192.168.10.0
 neighbor 172.16.2.1 remote-as 500
 neighbor 172.16.2.1 route-map AS-PREPEND out
 neighbor 192.168.10.1 remote-as 200
 neighbor 192.168.10.1 next-hop-self
 no auto-summary
!
ip forward-protocol nd
ip route 192.168.2.0 255.255.255.0 192.168.10.10
!
!
no ip http server
no ip http secure-server
!
no cdp log mismatch duplex
!
!
!
route-map AS-PREPEND permit 10
 set as-path prepend 200 200 200
!
!

Core-Switch Config


!
interface FastEthernet1/0
 switchport access vlan 10
 duplex full
 speed 100
!
interface FastEthernet1/1
 switchport access vlan 10
 duplex full
 speed 100
!

interface FastEthernet1/5
 switchport access vlan 2
 duplex full
 speed 100
!
!
interface Vlan2
 ip address 192.168.2.1 255.255.255.0
!
interface Vlan10
 ip address 192.168.10.10 255.255.255.0
!
ip forward-protocol nd
ip route 0.0.0.0 0.0.0.0 192.168.10.100
!
!

PC-1> Config


PC-1> 

NAME : PC-1[1]
IP/MASK : 192.168.2.2/24
GATEWAY : 192.168.2.1
DNS :
MAC : 00:50:79:66:68:00
LPORT : 10040
RHOST:PORT : 127.0.0.1:10041
MTU: : 1500

PC-1>

Connectivity Testing 


Remote-Site#traceroute 192.168.2.2 source 10.10.10.1

Type escape sequence to abort.
Tracing the route to 192.168.2.2

1 172.16.3.1 12 msec 24 msec 20 msec
 2 172.16.1.2 32 msec 40 msec 36 msec
 3 192.168.10.10 [AS 200] 48 msec 24 msec 36 msec
 4 *
 192.168.2.2 [AS 200] 64 msec 48 msec
Remote-Site#

Remote-Site#ping 192.168.2.2 source 10.10.10.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.2, timeout is 2 seconds:
Packet sent with a source address of 10.10.10.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/48/68 ms
Remote-Site#

Remote-Site#sh ip bgp
BGP table version is 8, local router ID is 10.10.10.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
*> 2.2.2.2/32 172.16.3.1 0 0 100 i
*> 10.1.1.0/24 172.16.3.1 0 0 100 i
*> 10.10.10.0/24 0.0.0.0 0 32768 i
*> 192.168.2.0 172.16.3.1 0 100 200 i
*> 192.168.10.0 172.16.3.1 0 100 200 i
Remote-Site#


ISP-2#sh ip bgp
BGP table version is 8, local router ID is 172.16.4.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
* 2.2.2.2/32 172.16.2.2 0 200 200 200 200 100 i
*> 172.16.4.2 0 1000 100 i
* 10.1.1.0/24 172.16.2.2 0 200 200 200 200 100 i
*> 172.16.4.2 0 1000 100 i
* 10.10.10.0/24 172.16.2.2 0 200 200 200 200 100 1000 i
*> 172.16.4.2 0 0 1000 i
*> 192.168.2.0 172.16.4.2 0 1000 100 200 i
* 172.16.2.2 0 0 200 200 200 200 i
*> 192.168.10.0 172.16.4.2 0 1000 100 200 i
* 172.16.2.2 0 0 200 200 200 200 i
ISP-2#

ISP-2#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
 D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
 N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
 E1 - OSPF external type 1, E2 - OSPF external type 2
 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
 ia - IS-IS inter area, * - candidate default, U - per-user static route
 o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

2.0.0.0/32 is subnetted, 1 subnets
B 2.2.2.2 [20/0] via 172.16.4.2, 00:15:59
B 192.168.10.0/24 [20/0] via 172.16.4.2, 00:15:59
 172.16.0.0/30 is subnetted, 2 subnets
C 172.16.4.0 is directly connected, FastEthernet0/1
C 172.16.2.0 is directly connected, FastEthernet0/0
 10.0.0.0/24 is subnetted, 2 subnets
B 10.10.10.0 [20/0] via 172.16.4.2, 00:15:59
B 10.1.1.0 [20/0] via 172.16.4.2, 00:15:59
B 192.168.2.0/24 [20/0] via 172.16.4.2, 00:15:59
ISP-2#

ISP#sh ip bgp
BGP table version is 6, local router ID is 10.1.1.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
*> 2.2.2.2/32 0.0.0.0 0 32768 i
*> 10.1.1.0/24 0.0.0.0 0 32768 i
*> 10.10.10.0/24 172.16.3.2 0 0 1000 i
*> 192.168.2.0 172.16.1.2 0 0 200 i
*> 192.168.10.0 172.16.1.2 0 0 200 i
ISP#

R1#sh ip bgp
BGP table version is 6, local router ID is 192.168.10.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
*> 2.2.2.2/32 172.16.1.1 0 0 100 i
*> 10.1.1.0/24 172.16.1.1 0 0 100 i
*> 10.10.10.0/24 172.16.1.1 0 100 1000 i
* i192.168.2.0 192.168.10.2 0 100 0 i
*> 192.168.10.10 0 32768 i
* i192.168.10.0 192.168.10.2 0 100 0 i
*> 0.0.0.0 0 32768 i
R1#

R2#sh ip bgp
BGP table version is 6, local router ID is 192.168.10.2
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
* 2.2.2.2/32 172.16.2.1 0 500 1000 100 i
*>i 192.168.10.1 0 200 0 100 i
* 10.1.1.0/24 172.16.2.1 0 500 1000 100 i
*>i 192.168.10.1 0 200 0 100 i
* 10.10.10.0/24 172.16.2.1 0 500 1000 i
*>i 192.168.10.1 0 200 0 100 1000 i
* i192.168.2.0 192.168.10.1 0 200 0 i
*> 192.168.10.10 0 32768 i
* i192.168.10.0 192.168.10.1 0 200 0 i
*> 0.0.0.0 0 32768 i
R2#

R2#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
 D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
 N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
 E1 - OSPF external type 1, E2 - OSPF external type 2
 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
 ia - IS-IS inter area, * - candidate default, U - per-user static route
 o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

2.0.0.0/32 is subnetted, 1 subnets
B 2.2.2.2 [200/0] via 192.168.10.1, 00:18:37
C 192.168.10.0/24 is directly connected, FastEthernet0/1
 172.16.0.0/30 is subnetted, 1 subnets
C 172.16.2.0 is directly connected, FastEthernet0/0
 10.0.0.0/24 is subnetted, 2 subnets
B 10.10.10.0 [200/0] via 192.168.10.1, 00:18:37
B 10.1.1.0 [200/0] via 192.168.10.1, 00:18:37
S 192.168.2.0/24 [1/0] via 192.168.10.10
R2#

PC-1> trace 10.10.10.1
trace to 10.10.10.1, 8 hops max, press Ctrl+C to stop
 1 192.168.2.1 6.009 ms 10.007 ms 11.006 ms
 2 192.168.10.1 31.023 ms 20.013 ms 20.036 ms
 3 172.16.1.1 33.002 ms 29.023 ms 29.022 ms
 4 *172.16.3.2 43.030 ms (ICMP type:3, code:3, Destination port unreachable)

PC-1>

Author: Ronnie Singh

Your Feedback is Valuable for us. Pls do comments.