Thursday, November 11, 2010


I'm going to go through BGP Attributes with the topology we used in the previous article:

I redrew the topology diagram to look a little neater. I also replaced all Serial links with straight lines so that it looks neater, but they're all still Serial links. Finally I've included the point-to-point subnet addresses for the various Serial links. The lower router number will get the first address of each point-to-point subnet. R4 and R6 are not neighbors so that you'll get two separate links. R2 and R3 are also not neighbors for the same reason.

We'll start from full configuration between AS 2, 3, and 4. R2 and R3 also has EBGP relationships with R3 and R6.

We'll begin configuration of the local Autonomous System (AS 1). Since the local AS only runs IBGP, you'll have to turn off Synchronization for all R1, R2 and R3:
no sync
clear ip bgp *

On all routers, we'll create a peer group as shown:
neighbor AS1 peer-group
neighbor AS1 remote-as 1
neighbor AS1 next-hop-self

On R1, we'll add R2 and R3 as neighbors:
neighbor peer-group AS1
neighbor peer-group AS1

We'll add R1 on R2:
neighbor peer-group AS1

And finally, we'll add R1 on R3:
neighbor peer-group AS1

You would have 8 routes, with 4 going to 30.0.x.0/24 and 4 going to 40.0.x.0/24.

At this point, the 30.0.x.0/24 networks would preferably be going through:
AS 2 3 4 ?
>AS 2 3 ?

The route to 40.0.x.0/24 would then be going through:
AS 2 4 3 i
>AS 2 4 i

Now we'll begin the first tuning of the BGP attributes. The first thing we can set is the Cisco proprietary Weight attribute. Weight is local to the router. Higher Weight routes are preferred, and the default Weight is 0.

To set the weight, we'll use:
neighbor weight 500
clear ip bgp *

What the above command does is to prefer routes coming from R2. If you check the topology table (with "show ip bgp"), you'd see that the routes coming from R2 are now preferred with the > symbol.

The preferred path to the 40.0.x.0/24 networks is now:
AS 2 3 4 i

We'll now remove the Weight command:
no neighbor weight 500
clear ip bgp *

Now, if we wish to temporarily disable a neighbor, we do not have to remove all the neighbor statements. We can simply type:
neighbor shutdown

This would restrict the neighbor relationship but will still retain the configurations so that it can be quickly brought back up using:
no neighbor shutdown

The origin is where a route came from. You can check the origin of a route using:
show ip bgp

Routes originated with the "network" command will be marked with "i". Routes originated with the "redistribute" command will be marked with "?".

We'll now talk about Local Preference. Local Preference is the industry standard method to modify route preferences in the AS. Local Preference is similar to Weight, but it's transitive within the AS.

If we wish all routes from R2 to be preferred Locally, we'll simply go into R2. From the BGP context, we'll type:
bgp default local-preference 101
clear ip bgp *

If we check back on R1, we'll see that the local preference for R2's routes are marked as 101 and the routes would be preferred.

You can change Local Preference for specific routes only. To do this, we'll need route-maps. We'll make R2 the preferred router for the 40.0.x.0/24 network and R3 the preferred router for the 30.0.x.0/24 network.

On R2, we'll make an access-list matching the 40.0.x.0/24 network:
ip access-l standard AS4
permit ip

We'll then create one for AS3's routes as well:
ip access-l standard AS3
permit ip

Now we'll make a route-map:
route-map LOCAL_PREFERENCE permit 10
match ip address AS4
set local-preference 101
route-map LOCAL_PREFERENCE permit 20
match ip address AS3
set local-preference 99
route-map LOCAL_PREFERENCE permit 30

We'll now apply the route-map on R2:
neighbor route-map LOCAL_PREFERENCE in is the IP of R4. At this point, R2 will automatically be preferred for 40.0.x.0/24 networks, while R3 will be the router for 30.0.x.0/24.

Now, notice that I made the incoming routes from R4 a higher local preference rather than outgoing routes to R1. This is so that R2 itself would be affected as well. If we actually change only the outgoing routes to R1, then R2's local preferences for those routes would still be default.

The Multi-Exit Discriminator or MED is also known as "Metric" in BGP. MED is used for "suggesting" which Exit to use if there are multiple entrances/exits into the same organization. The lowest MED is preferred. The way to remember this is to remember MED as a metric in a normal routing protocol, where lower is better.

The MED can be set with two methods as well. The first method is to go to the BGP context and type:
default-metric 100

This actually makes it less preferred than default. We'll also be able to set the MED for specific routes using route-maps just like how we did for Local Preference. For example, we can do a "match ip address ACCESS-LIST", then use a "set metric 100".

Don't you just love BGP?

No comments :

Post a Comment