Bgp routing protocol
IGP versus EGP
Interior gateway protocol (IGP)
A routing protocol operating within an Autonomous System (AS).
RIP, OSPF, and EIGRP are IGPs.
Exterior gateway protocol (EGP)
A routing protocol operating between different AS.
IGP versus EGP
AS numbers can be between 1 to 65,535.
RIRs manage the AS numbers between 1 and 64,512.
The 64,512 - 65,535 numbers are reserved for private use (similar to IP Private addresses).
The IANA is enforcing a policy whereby organizations that connect to a single provider use an
AS number from the private pool.
Note:
The current AS pool of addresses is predicted to run out by 2012.
For this reason, the IETF has released RFC 4893 and RFC 5398.
These RFCs describe BGP extensions to increase the AS number from the two-octet (16-bit)
field to a four-octet (32-bits) field, increasing the pool size from 65,536 to 4,294,967,296 values.
3
BGP Tables
• Neighbor table
• List of BGP neighbors
• BGP table (forwarding database)
• List of all networks learned from each neighbor
• Can contain multiple paths to destination networks
• Contains BGP attributes for each path
• IP routing table
• List of best paths to destination networks
BGP Neighbor Relationship
External bgp NEIGHBORs
R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.12.2 remote-as 2
R2(config)#router bgp 2
R2(config-router)#neighbor 192.168.12.1 remote-as 1
R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.12.2 remote-as 12
R2(config)#router bgp 2
R2(config-router)#neighbor 192.168.12.1 remote-as 12
Internal BGP Neighbors
R2(config)# router bgp 65101
R2(config-router)# neighbor 172.16.1.1 remote-as 65100
R2(config-router)# neighbor 192.168.3.3 remote-as 65101
R2(config-router)# neighbor 192.168.3.3 update-source loopback0
R2(config)# router eigrp 1
R2(config-router)# network 10.0.0.0
R2(config-router)# network 192.168.2.0
R3(config)# router bgp 65101
R3(config-router)# neighbor 192.168.1.1 remote-as 65102
R3(config-router)# neighbor 192.168.2.2 remote-as 65101
R3(config-router)# neighbor 192.168.2.2 update-source loopback0
R3(config)# router eigrp 1
R3(config-router)# network 10.0.0.0
R3(config-router)# network 192.168.3.0
External BGP Neighbors
R1(config)# router bgp 65102
R1(config-router)# neighbor 172.16.1.1 remote-as 65101
R1(config-router)# neighbor 172.16.1.1 update-source loopback0
R1(config-router)# neighbor 172.16.1.1 ebgp-multihop 2
R1(config)# ip route 172.16.1.1 255.255.255.255 10.1.1.2
R1(config)# ip route 172.16.1.1 255.255.255.255 10.2.2.2
R2(config)# router bgp 65101
R2(config-router)# neighbor 172.17.1.1 remote-as 65102
R2(config-router)# neighbor 172.17.1.1 update-source loopback0
R2(config-router)# neighbor 172.17.1.1 ebgp-multihop 2
R2(config)# ip route 172.17.1.1 255.255.255.255 10.1.1.1
R2(config)# ip route 172.17.1.1 255.255.255.255 10.2.2.1
BGP full mesh ibgp
BGP Summarization
R3(config-router)# aggregate-address 172.16.0.0 255.255.248.0 summary-
only
R4# show ip bgp
Network Next Hop Metric LocPrf Weight Path
*> 172.16.0.0/21 10.0.0.9 0 0 30 i
BGP authentication and default route
R1(config)# router bgp 100
R1(config-router)# neighbor 12.0.0.2 remote-as 200
R1(config-router)# neighbor 12.0.0.2 password BGP-Pa55w0rd
R1(config-router)# neighbor 12.0.0.2 default-originate
R2(config)# router bgp 200
R2(config-router)# neighbor 12.0.0.1 remote-as 100
R2(config-router)# neighbor 12.0.0.1 password BGP-Pa55w0rd
BGP verification
Command Description
show ip bgp neighbors Displays all received routes (both accepted
{address} received-routes and rejected) from the specified neighbor.
Displays all routes that are received and
accepted from the specified neighbor.
show ip bgp neighbors
{address} routes This output is a subset of the output
displayed by the received-routes
keyword.
show ip bgp Displays entries in the BGP table.
show ip bgp neighbors Displays all BGP routes that have been
{address} advertised-routes advertised to neighbors.
BGP verification
Command Description
Displays entries in the BGP table.
show ip bgp Specify a network number to get more specific
information about a particular network.
Displays detailed information about the TCP and BGP
show ip bgp neighbors
connections to neighbors.
show ip bgp summary Displays the status of all BGP connections.
show ip bgp neighbors
Displays all BGP routes that have been advertised to
{address} advertised-
routes neighbors.
Displays BGP routes that were not installed in the
show ip bgp rib-
failure routing information base (RIB), and the reason that
they were not installed.
debug ip bgp
[dampening | events |
keepalives | updates]
BGP Path Attributes
the BGP Decision Process
BGP Route Selection Process
• Prefer the route with highest • Prefer the route with the lowest
weight. MED.
• Prefer the EBGP route over IBGP
• Prefer the route with highest route.
LOCAL_PREF.
• Prefer the route through the
• Prefer the locally generated closest IGP neighbor.
route (network or aggregate
routes).
• Prefer the oldest EBGP route.
• Prefer the route with the
shortest AS-PATH.
• Prefer the route with the lowest
neighbor BGP router ID value.
• Prefer the route with the lowest
ORIGIN (IGP<EGP<incomplete)
Weigh attribute
Weight 0
• Cisco proprietary
• Local to the router, not sent to
any BGP neighbor
• Paths with the highest weight
• Range from 0 to 65535, default 0
Weight 50
Weigh attribute
R1#sh ip bgp | beg Net
Network Next Hop Metric LocPrf Weight Path
* 100.1.1.0/24 13.0.0.3 0 0 23 i
*> 12.0.0.2 0 0 23 i
R1#
R1(config)#router bgp 100
R1(config-router)#neigh 13.0.0.3 weight 50
R1#sh ip bgp | beg Net
Network Next Hop Metric LocPrf Weight Path
* 100.1.1.0/24 12.0.0.2 0 0 23 i
*> 13.0.0.3 0 50 23 i
R1#
R1(config)# ip prefix-list TEST permit 100.1.1.0/24
R1(config)#route-map SETWEIGHT permit 10
R1(config-route-map)#match ip address prefix TEST
R1(config-route-map)#set weight 50
R1(config-router)#neighbor 13.0.0.3 route-map SETWEIGHT in
LOCAL preference attribute
LP 100
LP 200
• Used to select the outbound EBGP path
• Sent within the local AS to IBGP neighbors only
• Default value = 100
• Paths with the highest local preference value are preferred
LOCAL preference attribute
R4#sh ip bgp | beg Net
Network Next Hop Metric LocPrf Weight Path
*>i 1.1.1.0/24 2.2.2.2 0 100 0 100 i
* i 3.3.3.3 0 100 0 100 i
R4#
R3(config)#router bgp 234
R3(config-router)#bgp default local-preference 200
R4#sh ip bgp | beg Net
Network Next Hop Metric LocPrf Weight Path
*>i 1.1.1.0/24 3.3.3.3 0 200 0 100 i
* i 2.2.2.2 0 100 0 100 i
R4#
R3(config)#ip prefix-list TEST permit 1.1.1.0/24
R3(config)#route-map LOCALPREF permit 10
R3(config-route-map)#match ip address prefix TEST
R3(config-route-map)#set local-preference 200
R3(config)#router bgp 234
R3(config-router)#neighbor 4.4.4.4 route-map LOCALPREF out
AS PATH attribute
AS PATH PREPEND 12 12 12
• Fourth BGP path selection criteria
• Prefer shorter AS paths (only length is compared)
• Influences the path selection in an AS
• AS path prepending:
-Manual manipulation of AS path length
-Influences the inbound path selection in other autonomous systems
-Configured per neighbor with route-maps
AS PATH attribute
ISP3#sh ip bgp | beg Net
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/24 26.0.0.1 0 2 12 i
* 27.0.0.2 0 4 12 i
* 2.2.2.0/24 27.0.0.2 0 4 12 i
*> 26.0.0.1 0 2 12 i
ISP3#
ISP3#tracer 1.1.1.1 sou 3.3.3.3 ISP3#tracer 2.2.2.2 sou 3.3.3.3
Type escape sequence to abort. Type escape sequence to abort.
Tracing the route to 1.1.1.1 Tracing the route to 1.1.1.1
VRF info: (vrf in name/id, vrf out name/id) VRF info: (vrf in name/id, vrf out name/id)
1 26.0.0.1 96 msec 60 msec 60 msec 1 26.0.0.1 96 msec 60 msec 60 msec
2 24.0.0.2 136 msec 180 msec 132 msec 2 24.0.0.2 136 msec 180 msec 132 msec
3 12.0.0.1 156 msec 152 msec 176 msec 3 12.0.0.1 156 msec 152 msec 176 msec
ISP3# ISP3#
R1(config)#ip prefix-list TEST permit 1.1.1.0/24
R1(config)#ip prefix-list TEST permit 2.2.2.0/24
R1(config)#route-map PREPEND permit 10
R1(config-route-map)#match ip address prefix TEST
R(config-route-map)#set as-path prepend 12 12 12
R1(config)#router bgp 12
R1(config-router)#neighbor 12.0.0.2 route-map PREPEND out
AS PATH attribute
ISP3#sh ip bgp | beg Net
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/24 27.0.0.2 0 4 12 i
* 26.0.0.1 0 2 12 12 12 12 i
*> 2.2.2.0/24 27.0.0.2 0 4 12 i
* 26.0.0.1 0 2 12 12 12 12 i
ISP3#
ISP3#tracer 1.1.1.1 sou 3.3.3.3 ISP3#tracer 2.2.2.2 sou 3.3.3.3
Type escape sequence to abort. Type escape sequence to abort.
Tracing the route to 1.1.1.1 Tracing the route to 2.2.2.2
VRF info: (vrf in name/id, vrf out name/id) VRF info: (vrf in name/id, vrf out name/id)
1 27.0.0.2 96 msec 72 msec 76 msec 1 27.0.0.2 92 msec 84 msec 4 msec
2 25.0.0.1 164 msec 96 msec 104 msec 2 25.0.0.1 168 msec 144 msec 120 msec
3 13.0.0.2 180 msec 112 msec 156 msec 3 13.0.0.2 144 msec 164 msec 136 msec
4 23.0.0.1 172 msec 192 msec 204 msec ISP3#
ISP3#
MED attribute
MED 700
MED 500
• This is called the BGP metric
• The lowest MED is preferred
• It is sent to EBGP peers to announce the metric for the inbound traffic
• It is only significant for the neighbor AS
MED attribute
R1#sh ip bgp | beg Net
Network Next Hop Metric LocPrf Weight Path
* 44.44.44.0/24 13.0.0.3 0 234 i
*> 12.0.0.2 0 234 i
R2(config)#ip prefix-list TEST permit 44.44.44.0/24
R2(config)#route-map MED permit 10
R2(config-route-map)#match ip address prefix TEST
R2(config-route-map)#set metric 700
R2(config)#router bgp 234
R2(config-router)#neighbor 12.0.0.1 route-map MED out
R3(config)#ip prefix-list TEST permit 44.44.44.0/24
R3(config)#route-map MED permit 10
R3(config-route-map)#match ip address prefix TEST
R3(config-route-map)#set metric 500
R3(config)#router bgp 234
R3(config-router)#neighbor 13.0.0.1 route-map MED out
R1#sh ip bgp | beg Net
Network Next Hop Metric LocPrf Weight Path
* 44.44.44.0/24 12.0.0.2 700 0 234 i
*> 13.0.0.3 500 0 234 i
BGP FILTERING
Filter 44.44.44.0/24 update
coming from R2 to R1.
BGP FILTERING
R1(config)#do sh ip bgp | beg Net
Network Next Hop Metric LocPrf Weight Path
* 44.44.44.0/24 12.0.0.2 700 0 234 i
*> 13.0.0.3 500 0 234 i
*> 144.4.4.0/24 12.0.0.2 0 234 i
* 13.0.0.3 0 234 i
R1(config)#
R1(config)#ip prefix-list FILTER deny 144.4.4.0/24
R1(config)#ip prefix-list FILTER permit 0.0.0.0/0 le 32
R1(config)#route-map RMAP permit 10
R1(config-route-map)#match ip add prefix-list FILTER
R1(config)#router bgp 100
R1(config-router)#neighbor 12.0.0.2 route-map RMAP in
R1#sh ip bgp | beg Net
Network Next Hop Metric LocPrf Weight Path
* 44.44.44.0/24 12.0.0.2 700 0 234 i
*> 13.0.0.3 500 0 234 i
*> 144.4.4.0/24 13.0.0.3 0 234 i
R1#
BGP FILTERING
Filter 3.3.3.0/24 route
coming from ISP1 to BR-1.
BGP FILTERING
R1#sh ip bgp | beg Net
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/24 0.0.0.0 0 32768 i
*>i 2.2.2.0/24 23.0.0.2 0 100 0 i
* i 3.3.3.0/24 23.0.0.2 0 100 0 4 3 i
*> 12.0.0.2 0 2 3 i
R1#
R1#sh ip route bgp | beg Gate
Gateway of last resort is not set
2.0.0.0/24 is subnetted, 1 subnets
B 2.2.2.0 [200/0] via 23.0.0.2, 00:00:37
3.0.0.0/24 is subnetted, 1 subnets
B 3.3.3.0 [20/0] via 12.0.0.2, 00:00:37
R1#
R1(config)#ip prefix-list FILTER deny 3.3.3.0/24
R1(config)#ip prefix-list FILTER permit 0.0.0.0/0 le 32
R1(config)#route-map RMAP permit 10
R1(config-route-map)#match ip add prefix-list FILTER
R1(config)#router bgp 2
R1(config-router)#neighbor 12.0.0.2 route-map RMAP in
BGP FILTERING
R1(config)#ip prefix-list FILTER deny 3.3.3.0/24
R1(config)#ip prefix-list FILTER permit 0.0.0.0/0 le 32
R1(config)#route-map RMAP permit 10
R1(config-route-map)#match ip add prefix-list FILTER
R1(config)#router bgp 2
R1(config-router)#neighbor 12.0.0.2 route-map RMAP in
R1#sh ip bgp | beg Gate
R1#sh ip bgp | beg Net
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/24 0.0.0.0 0 32768 i
*>i 2.2.2.0/24 23.0.0.2 0 100 0 i
*>i 3.3.3.0/24 23.0.0.2 0 100 0 4 3 i
R1#
R1#sh ip route bgp | beg Gate
Gateway of last resort is not set
2.0.0.0/24 is subnetted, 1 subnets
B 2.2.2.0 [200/0] via 23.0.0.2, 00:00:49
3.0.0.0/24 is subnetted, 1 subnets
B 3.3.3.0 [200/0] via 23.0.0.2, 00:00:49
R1#