Вы находитесь на странице: 1из 25

Constructing the BGP Table

Joe Astorino www.astorinonetworks.com @jastorino

BGP Table Summary


The BGP table contains all the prefixes learned by BGP and the path attributes (PA) associated with those prefixes

In BGP, prefixes are technically called NLRI

The BGP table is actually comprised of three databases

Adj-RIBs-In Raw NLRI / PA information received from peers Loc-RIB The best NLRIs after route policies have been applied Adj-RIBs-Out Routes BGP will advertise to other BGP peers

BGP Table Sources


The local BGP table is built from three different sources

Network command Local Routes

BGP Updates iBGP or eBGP

Redistribution Redistributed

BGP Network Command


The network command adds routes to the local BGP table that the router wishes to advertise into BGP and ultimately send to BGP peers The network command specifies a prefix and a mask. For the prefix to be added to the BGP table, the prefix must match exactly a route already existing in the routing table! The prefix can match existing routes from connected, static or IGPs

R1#show ip interface brief | i Loopback Loopback0 1.1.1.1

YES NVRAM

up

up

R1#show ip route 1.1.1.1 Routing entry for 1.1.1.1/32 Known via "connected", distance 0, metric 0 (connected, via interface) R1#sh run | section bgp router bgp 65123 network 1.1.1.1 mask 255.255.255.255

Redistribution into BGP


Connected, static and IGP routes may be redistributed into BGP Many times the redistribution is tied to a route-map in order to manipulate the attributes of the redistributed prefixes By default, when redistributing OSPF into BGP, only intra and interarea routes are allowed. This can be changed during the redistribution
ip prefix-list AS65123 seq 5 permit 172.16.123.0/24 ge 26 le 26 ip prefix-list AS65123 seq 10 permit 10.0.123.0/29 ! route-map CONNECTED-BGP permit 10 match ip address prefix-list AS65123 set metric 100 set community 65123:110 ! router bgp 65123 network 1.1.1.1 mask 255.255.255.255 redistribute connected route-map CONNECTED-BGP redistribute ospf 1 match internal external 1 external 2 nssa-external

Auto Summarization
auto-summary summarizes prefixes added to BGP at classful boundaries The behavior is different depending on if the prefixes were added with the network command or through redistribution The default is no auto-summary since IOS 12.3

Redistribution Redistribute only the classful network Network Command Inject more specific and summary

BGP Path Attributes


A BGP path attribute (PA) is a characteristic of a BGP prefix Ultimately, BGP uses path attributes and the BGP best path selection algorithm to select a valid and best path for each NLRI Path attributes are categorized into one of four groups

Well-known
mandatory discretionary

Optional
transitive nontransitive

Path Attributes
Attribute ORIGIN AS_PATH NEXT_HOP LOCAL_PREF ATOMIC_AGGREGATE AGGREGATOR COMMUNITY MULTI_EXIT_DISC ORIGINATOR_ID CLUSTER_LIST Class well-known mandatory well-known mandatory well-known mandatory well-known discretionary well-known discretionary optional transitive optional transitive optional nontransitive optional nontransitive optional nontransitive

ORIGIN Path Attribute


How was this prefix entered into BGP? Where did it come from?

IGP (i)
Prefix was learned internal to the AS Prefixes added to BGP with the network command

EGP (e)
Prefix was learned via EGP

Incomplete (?)
Prefix was learned through some other method Redistributed routes have an origin of incomplete

ORIGIN Path Attribute


R1#show ip bgp | i 1.1.1.1 BGP table version is 188, local router ID is 1.1.1.1 *> 1.1.1.1/32 0.0.0.0 0

32768 i

R1#show ip bgp 1.1.1.1 | b Origin Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best R1#show ip bgp | i 10.0.45.0 *>i10.0.45.0/30 2.2.2.2 0 100 0 65004 ?

R1#show ip bgp 10.0.45.0 | b Origin Origin incomplete, metric 0, localpref 100, valid, internal, best

AS_PATH Path Attribute


Generally, AS_PATH lists all the AS a prefix has gone through A router drops any BGP prefix that contains its own AS in the AS_PATH AS_PATH influences inbound routing (shortest AS_PATH wins) Technically, AS_PATH can contain four different sub-components
AS_SEQ
Ordered list of AS numbers

AS_SET
Unordered set of AS numbers enclosed in { } Used when prefixes have been aggregated

AS_CONFED_SEQUENCE
Similar to AS_SEQ but used in confederations

AS_CONFED_SET
Similar to AS_SET but used in confederations

AS_PATH Path Attribute


Router#sh ip bgp | b 10.64 *> 10.64.0.0/16 192.168.100.161 *> 10.65.0.0/16 192.168.100.161 *> 10.66.0.0/16 192.168.100.161 *> 10.67.0.0/16 192.168.100.161

500 500 500 500

0 0 0 0

13979 13979 13979 13979

21326 21326 21326 21326

4809 65103 i 4809 65106 i 4809 65107 i 65109 i

Router#sh ip bgp 10.64.0.0 BGP routing table entry for 10.64.0.0/16, version 2698 Paths: (1 available, best #1, table default) Advertised to update-groups: 1 2 Refresh Epoch 1 13979 21326 4809 65103, (aggregated by 65103 192.168.101.3) 192.168.100.161 from 192.168.100.161 (12.123.71.116) Origin IGP, localpref 500, valid, external, atomic-aggregate, best Community: 13979:5000

LOCAL_PREF Path Attribute


Local Preference Influences outbound path. Default is 100 and highest wins Well-known discretionary attribute only sent between iBGP peers
Diagram courtesy cisco.com

Configuring LOCAL_PREF
ip prefix-list PREFER_ME_PLEASE permit 1.1.1.1/32 ! route-map SET_LOCAL_PREF permit 10 match ip address prefix-list PREFER_ME_PLEASE set local-preference 500 ! router bgp 65123 neighbor 10.0.45.1 route-map SET_LOCAL_PREF in ! R5#sh ip bgp 1.1.1.1 BGP routing table entry for 1.1.1.1/32, version 183 Paths: (2 available, best #2, table Default-IP-Routing-Table) Advertised to update-groups: 2 65004 65123 6.6.6.6 (metric 156160) from 6.6.6.6 (6.6.6.6) Origin IGP, metric 0, localpref 100, valid, internal 65004 65123 10.0.45.1 from 10.0.45.1 (172.16.46.193) Origin IGP, localpref 500, valid, external, best

MULTI_EXIT_DISC Path Attribute


Multi-Exit-Discriminator (MED), sometimes known as metric Optional nontransitive attribute that influences inbound routing Default value is 0 and lowest wins MED is only compared when prefixes are coming from the same AS!!!
Diagram courtesy cisco.com

Configuring MED
ip prefix-list PREFER_ME_PLEASE permit 1.1.1.1/32 ! route-map SET_MED permit 10 match ip address prefix-list PREFER_ME_PLEASE set metric 50 ! route-map SET_MED permit 20 set metric 100 ! router bgp 65123 neighbor 10.0.45.1 route-map SET_MED out ! R5#sh ip bgp 1.1.1.1 BGP routing table entry for 1.1.1.1/32, version 183 Paths: (2 available, best #2, table Default-IP-Routing-Table) Advertised to update-groups: 2 65004 65123 6.6.6.6 (metric 156160) from 6.6.6.6 (6.6.6.6) Origin IGP, metric 50, localpref 100, valid, internal 65004 65123 10.0.45.1 from 10.0.45.1 (172.16.46.193) Origin IGP, localpref 500, valid, external, best

ATOMIC_AGGREGATE Path Attribute


When aggregating prefixes that came from different AS_PATHs, AS_PATH information is lost When aggregating, BGP sets the ATOMIC_AGGREGATE path attribute

Signals to receiving routers that AS_PATH information has been lost A router that receives a prefix with ATOMIC_AGGREGATE set cannot advertise a more specific prefix of the aggregate, and must keep ATOMIC_AGGREGATE set on updates

Additionally, the AGGREGATOR path attribute is set

AGGREGATOR specifies the RID and AS that aggregated the prefix

Configuring BGP Aggregation


At least one subnet of the aggregate must be present By default, BGP will advertise the aggregate and more specific prefix
R5#sh ip bgp | i 172.16.56 *> 172.16.56.0/26 0.0.0.0 *> 172.16.56.64/26 0.0.0.0 *>i172.16.56.128/26 6.6.6.6 *>i172.16.56.192/26 6.6.6.6 router bgp 65056 aggregate-address 172.16.56.0 255.255.255.0 R5#sh ip bgp | i 172.16.56 *> 172.16.56.0/26 0.0.0.0 *> 172.16.56.0/24 0.0.0.0 *> 172.16.56.64/26 0.0.0.0 *>i172.16.56.128/26 6.6.6.6 *>i172.16.56.192/26 6.6.6.6 0 0 0 0 100 100 32768 32768 32768 0 0 ? i ? ? ? 0 0 0 0 32768 32768 0 0 ? ? ? ?

100 100

router bgp 65056 aggregate-address 172.16.56.0 255.255.255.0 summary-only R5#sh ip bgp | i 172.16.56 s> 172.16.56.0/26 0.0.0.0 *> 172.16.56.0/24 0.0.0.0 s> 172.16.56.64/26 0.0.0.0 s>i172.16.56.128/26 6.6.6.6 s>i172.16.56.192/26 6.6.6.6 0 0 0 0 100 100 32768 32768 32768 0 0 ? i ? ? ?

AS_SET
Due to AS_PATH information being lost during aggregation, routing loops are a possibility The AS_SET path attribute helps address this by placing an unordered list of all the AS from the more specific prefixes into AS_SET Additionally, AS_SEQ is still set to the aggregating routers AS No more need to set ATOMIC_AGGREGATE AS_SET is dynamic If more specific routes downstream fail, AS_SET can be updated on the fly, and those changes are advertised

Configuring AS_SET

Diagram courtesy cisco.com

RouterC(config)#router bgp 300 aggregate-adddress 160.0.0.0 255.0.0.0 summary-only as-set

RouterD# show ip bgp | b Network Network *> 160.0.0.0/8 Next Hop 4.4.4.1 Metric LocPrf Weight Path 0 300 {200,100} i

Adding a Default Route to the BGP Table


There are multiple ways to get a default route into the BGP table

network 0.0.0.0
0.0.0.0/0 must already exist in the routing table

default-information originate
0.0.0.0/0 must already exist in the routing table Requires redistribution of 0.0.0.0/0 to work

neighbor default-originate
Unconditionally advertises 0.0.0.0/0 to a specific neighbor

Conditional Default Routing


Option 1: route-map
ip prefix-list MUST_EXIST permit 10.1.1.1/32 ! route-map CONDITION permit 10 match ip address prefix-list MUST_EXIST ! Router bgp 65123 neighbor 10.0.123.2 default-originate route-map CONDITION

Option 2: advertise-map
ip prefix-list MUST_EXIST permit 10.1.1.1/32 ip prefix-list DEFAULT_ROUTE permit 0.0.0.0/0 ! route-map MUST_EXIST permit 10 match ip address prefix-list MUST_EXIST ! route-map DEFAULT_ROUTE match ip address prefix-list DEFAULT_ROUTE ! router bgp 65123 neighbor 10.0.123.2 advertise-map DEFAULT_ROUTE exist-map MUST_EXIST

BGP Lab Diagrams

Lab L2/L3 Diagram

Вам также может понравиться