Sie sind auf Seite 1von 10

A quick copy-and-paste summary on BGP attribute categorization.

WELL-KNOWN, MANDATORY
AS-path: A list of the Autonomous Systems (AS) numbers that a route passes through to reach the
destination. As the update passes through an AS the AS number is inserted at the beginning of the list.
The AS-path attribute has a reverse-order list of AS passed through to get to the destination.
Next-hop: The next-hop address that is used to reach the destination.
Origin: Indicates how BGP learned a particular route. There are three possible types -- IGP (route is
internal to the AS), EGP (learned via EBGP), or Incomplete (origin unknown or learned in a different way).

WELL-KNOWN, DISCRETIONARY
Local Preference: Defines the preferred exit point from the local AS for a specific route.
Atomic Aggregate: Set if a router advertises an aggregate causes path attribute information to be lost.

OPTIONAL, TRANSITIVE
Aggregator: Specifies the router ID and AS of the router that originated an aggregate prefix. Used in
conjunction with the atomic aggregate attribute.
Community: Used to group routes that share common properties so that policies can be applied at the
group level.

OPTIONAL, NON-TRANSITIVE
Multi-exit-discriminator (MED): Indicates the preferred path into an AS to external neighbors when
multiple paths exist.

A list of path attributes is contained in BGP update messages. The attribute is variable length and
consists of three fields: Attribute type consisting of a 1-byte attribute flags field and a 1-byte attribute code
field, Attribute length field that is 1 or 2 bytes, and a variable length attribute value field. The attribute type
codes used by Cisco are: 1-origin, 2-AS-path, 3-Next-hop, 4-MED, 5-Local preference, 6-Atomic
aggregate, 7-aggregator, 8-community, 9-originator-ID, and 10-cluster list.

Local Preference is one of the ways to alter the path taken by one AS to reach another AS. The difference
between Local Preference and Weight is that Weight is just locally signifant in the router while Local
Preference is what I call "Local AS significant". What I mean by that is that Local Preference is being
propagated Intra AS but not outside the AS.

Local preference is to influence your own AS how to get or exit to another AS.
MED is to influence other AS how to enter your AS.
The higher the local preference, the more preferred.

In this lab, local preference will be configured and will be using route map for more flexibility. Check the
diagram below for details.

R1, R2 and R3 belongs to AS 123. R4 is in AS4 and is advertising 4.4.4.4/32, 44.44.44.44/32 and
144.144.144.144/32
subnets.We need to set all routes learned from R3 to have local preference value of 300. After which, configure a
route-map that will assign a local preference of 500 in R2 for the network 144.144.144.144/32.

Here are the initial BGP configurations on the routers.

R1#
!
router bgp 123
no synchronization
bgp log-neighbor-changes
neighbor 12.12.12.2 remote-as 123
neighbor 13.13.13.3 remote-as 123
no auto-summary
R2#
!
router bgp 123
no synchronization
bgp log-neighbor-changes

neighbor 12.12.12.1 remote-as 123


neighbor 12.12.12.1 next-hop-self
neighbor 24.24.24.4 remote-as 4
no auto-summary
R3#
!
router bgp 123
no synchronization
bgp log-neighbor-changes
neighbor 13.13.13.1 remote-as 123
neighbor 13.13.13.1 next-hop-self
neighbor 34.34.34.4 remote-as 4
no auto-summary
R4#
!
router bgp 4
no synchronization
bgp log-neighbor-changes
network 4.4.4.4 mask 255.255.255.255
network 44.44.44.44 mask 255.255.255.255
network 144.144.144.144 mask 255.255.255.255
neighbor 24.24.24.2 remote-as 123
neighbor 34.34.34.3 remote-as 123
no auto-summary
Let's see what is the best path taken by R1 to reach the networks advertised by R4.

R1#sh ip bgp
BGP table version is 10, local router ID is 1.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
*>i4.4.4.4/32
12.12.12.2
* i
13.13.13.3
*>i44.44.44.44/32
12.12.12.2
* i
13.13.13.3
*>i144.144.144.144/32
12.12.12.2
* i
13.13.13.3
R1#sh ip route | beg Gateway
Gateway of last resort is not set

Metric LocPrf Weight Path


0
100
0 4 i
0
100
0 4 i
0
100
0 4 i
0
100
0 4 i
0
0

100
100

0 4 i
0 4 i

C
B
B
C
C
B

1.0.0.0/32 is subnetted, 1 subnets


1.1.1.1 is directly connected, Loopback0
4.0.0.0/32 is subnetted, 1 subnets
4.4.4.4 [200/0] via 12.12.12.2, 00:04:00
144.144.0.0/32 is subnetted, 1 subnets
144.144.144.144 [200/0] via 12.12.12.2, 00:04:00
12.0.0.0/24 is subnetted, 1 subnets
12.12.12.0 is directly connected, Serial1/2
13.0.0.0/24 is subnetted, 1 subnets
13.13.13.0 is directly connected, Serial1/3
44.0.0.0/32 is subnetted, 1 subnets
44.44.44.44 [200/0] via 12.12.12.2, 00:04:00

It's clear that it prefers to take R2 to reach the networks in R4. Let's configure R3 so that all routes
received by R3 will have a Local preference of 300

R3#config t
R3(config)#router bgp 123
R3(config-router)#bgp default local-preference 300
R1#sh ip bgp
BGP table version is 13, local router ID is 1.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
* i4.4.4.4/32
12.12.12.2
*>i
13.13.13.3
* i44.44.44.44/32
12.12.12.2
*>i
13.13.13.3
* i144.144.144.144/32
12.12.12.2
*>i
13.13.13.3

Metric LocPrf Weight Path


0
100
0 4 i
0
300
0 4 i
0
100
0 4 i
0
300
0 4 i
0
0

100
300

0 4 i
0 4 i

Immediately, even without clearing the BGP process, R3 now became the more preferred path to reach
R4. Remember that in Local Preference, the higher the value, the more preferred.
Let's configure in R2 a route-map so the network 144.144.144.144/32 will have a local preference of 500.
This will make R2 the best path to reach the mentioned network.

R2(config)#access-list 1 permit host 144.144.144.144


R2(config)#route-map LOCALPREF500 permit 10
R2(config-route-map)#match ip address 1
R2(config-route-map)#set local-preference 500
R2#(config)# router bgp 123

R2(config-router)#neighbor 24.24.24.4 route-map LOCALPREF500 in


R2# clear ip bgp *
R1#sh ip bgp
BGP table version is 14, local router ID is 1.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
*>i4.4.4.4/32
13.13.13.3
*>i44.44.44.44/32
13.13.13.3
*>i144.144.144.144/32
12.12.12.2
* i
13.13.13.3

Metric LocPrf Weight Path


0
300
0 4 i
0
300
0 4 i
0
0

500
300

0 4 i
0 4 i

Firstly, why is that the route-map has an "in" direction. It's because we are receiving the route from
another router, R2 is not the one advertising. You can see now that path to 144.144.144.144/32 will have
R2 as the next hop. If you noticed also, why is that for 4.4.4.4/32 and 44.44.44.44/32, there is no other
path except through 13.13.13.3. Check the route-map above and you'll find the answer. There is no
succedding line after line 10, which means, it will block out the subnets and not advertised it to R1.
Let's configure the 20th sequence of the route-map.

R2(config)#route-map LOCALPREF500 permit 20


Let's see now if there are changes.

R1#sh ip bgp
BGP table version is 16, local router ID is 1.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
* i4.4.4.4/32
12.12.12.2
*>i
13.13.13.3
* i44.44.44.44/32
12.12.12.2
*>i
13.13.13.3
*>i144.144.144.144/32
12.12.12.2
* i
13.13.13.3

Metric LocPrf Weight Path


0
100
0 4 i
0
300
0 4 i
0
100
0 4 i
0
300
0 4 i
0
0

500
300

0 4 i
0 4 i

BGP Best Path Selection


Studying the BSCI for CCNP can be hard for the reason that you need to memorize some stuff like BGP
Best Path Selection. Few months ago I found this mnemonic helpful to memorize the BGP Path Selection
Process. It's easy as eating pancakes and it is We Love Oranges AS Oranges Mean Pure Refreshment.
By taking note of the letters in caps, one will immediately remember how BGP selects the best path by
the list below.

W
L
O
AS
O
M
P
R

We Love Oranges AS Oranges Mean Pure Refreshment


Weight (Highest)
LOCAL_PREF (Highest)
Originate (local) routes that are advertise through the
"network" command or redistributed from an IGP.
AS_PATH (shortest)
ORIGIN Code (IGP > EGP > Incomplete)
MED (lowest)
Paths (External > Internal)
RID (lowest)

BGP MED
BGP MED is an optional non-transitive attribute meaning its not propagated throughout the whole internet
but just to adjacent AS. The word "optional" means that this is not necessarily by default sent with the
BGP updates. The purpose of MED is to influence how other autonomous systems enter your AS to reach
a certain prefix. If the other attributes are set to default, MED will be the attribute used for path selection
however, if Weight or Local preference is configured on the adjacent AS router, then MED will not be
selected. The lower the MED the more preferred the path will be.

Acronym for Multi Exit Discriminator and otherwise known as "Metric" in the BGP table.
The lower the MED the more preferred.
It is an optional non-transitive attribute.
Can dictate how other AS enter your AS.

Configure R4 so that it will advertise a MED value of 30 to R3 and 20 to R2. Afterwards,


tweak the route map to set a MED of 10 for network 144.144.144.144/32 in R4 towards R3. The end
result should have traffic from AS123 to 4.4.4.4/32 and 44.44.44.44/32 take R2 but traffic for
144.144.144.144/32 should take R3. At the start BGP has been established on all routers.

To start lets configure 2 route maps and set the MED as required.

R4(config)#access-list 20 permit any


R4(config)#access-list 30 permit any
R4(config)#route-map R2SETMED20 permit 10
R4(config-route-map)#match ip address 20
R4(config-route-map)#set metric 20
R4(config-route-map)#route-map R3SETMED30 permit 10
R4(config-route-map)#match ip address 30
R4(config-route-map)#set metric 30

Access-list matches all routes. Now, lets apply the route map to the neighbors.

R4(config-router)#neighbor 24.24.24.2 route-map R2SETMED20 out


R4(config-router)#neighbor 34.34.34.3 route-map R3SETMED30 out
Its in the "out" direction because R4 is the one advertising the routes. Let's check what R2 and R3 see in
their BGP table.

R2#sh ip bgp
BGP table version is 31, local router ID is 24.24.24.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
*> 4.4.4.4/32
24.24.24.4
*> 44.44.44.44/32
24.24.24.4
*> 144.144.144.144/32
24.24.24.4

Metric LocPrf Weight Path


20
0 4 i
20
0 4 i
20

0 4 i

R3#sh ip bgp
BGP table version is 10, local router ID is 34.34.34.3
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
*> 4.4.4.4/32
34.34.34.4
*> 44.44.44.44/32
34.34.34.4
*> 144.144.144.144/32
34.34.34.4

Metric LocPrf Weight Path


30
0 4 i
30
0 4 i
30

0 4 i

Ok, its clear that the Metric now is changed to 20 and 30 for R2 and R3 respectively. Let's see how R1
sees the routes.

R1#sh ip bgp
BGP table version is 34, local router ID is 13.13.13.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
*>i4.4.4.4/32
24.24.24.4
* i
34.34.34.4
*>i44.44.44.44/32
24.24.24.4
* i
34.34.34.4
*>i144.144.144.144/32
24.24.24.4
* i
34.34.34.4

Metric LocPrf Weight Path


20
100
0 4 i
30
100
0 4 i
20
100
0 4 i
30
100
0 4 i
20
30

100
100

0 4 i
0 4 i

R1 sees two paths, but notice that the paths with ">" are with those with lower MED. Therefore it is going
to take those paths. Now, lets configure R4 so that the path R1 will take to 144.144.144.144/32 in R4 will
be through R3 then clear the BGP session after.

R4(config)#access-list 33 permit 144.144.144.144 0.0.0.0


R4(config)#route-map R3SETMED30 permit 10
R4(config-route-map)#match ip address 33
R4(config-route-map)#set metric 10
R4(config-route-map)#route-map R3SETMED30 permit 20
R4(config-route-map)#match ip address 30
R4(config-route-map)#set metric 30
R4#clear ip bgp *
Now, lets see the outputs.

R2#sh ip bgp | beg Network


Network
Next Hop
*> 4.4.4.4/32
24.24.24.4
*> 44.44.44.44/32
24.24.24.4
*> 144.144.144.144/32
24.24.24.4
R3#sh ip bgp | beg Network
Network
Next Hop
*> 4.4.4.4/32
34.34.34.4
*> 44.44.44.44/32
34.34.34.4
*> 144.144.144.144/32
34.34.34.4
R1#sh ip bgp | beg Network
Network
Next Hop
* i4.4.4.4/32
34.34.34.4
*>i
24.24.24.4
* i44.44.44.44/32
34.34.34.4

Metric LocPrf Weight Path


20
0 4 i
20
0 4 i
20

0 4 i

Metric LocPrf Weight Path


30
0 4 i
30
0 4 i
10

0 4 i

Metric LocPrf Weight Path


30
100
0 4 i
20
100
0 4 i
30
100
0 4 i

*>i
24.24.24.4
*>i144.144.144.144/32
34.34.34.4
* i
24.24.24.4

20

100

0 4 i

10
20

100
100

0 4 i
0 4 i

We can see a change in R3 that shows a MED of 10 for 144.144.144.144/32, while R1 shows the same
and will now take R3 to reach the subnet.

Das könnte Ihnen auch gefallen