The place of BGP in your routed world
- EGP is the original External Gateway Protocol. The only EGP used now is BGP.
- For a corporate site, the main purpose of BGP is to make the Internet access redundant. : multi-homing.
The facts about BGP
- BGP runs on top of TCP (port 179)
- TCP used for reliability
- Updates (of course) are incremental and triggered
- Metric is the biggest you've ever seen !
- Slowest routing protocol on the planet to converge
Styles of BGP Implementation
- Default route only. A default route is used on the first ISP and the other ISP is used as a backup default route. However, the incoming traffic is coming from the 2 ISPs.
- Partial Updates. We receives some partial updates about some partners or the head office. We don't need to have all the Internet routes, we just have the routes updates about what we wants. Like that it possible to use one or the other ISP to go to a specific partner with the best route.
- Full Updates. We receive the entire Internet routing table. The routing table is more than 100MB. This is the most flexible style BGP implementation. However this is the most resource consuming implementation.
Three different kinds of AS exists :
- Stub AS : The AS has only one connection to an other AS (example : small company)
- Multi-homed AS :The AS has connections with several AS but it does not carry transit traffic (example : a large company)
- Transit AS : The AS has connections with several AS and carries transit traffic (example : an ISP)
How BGP finds the best route
- BGP is technically a distance vector protocol, but most call it a "path vector" protocol.
- Without tuning, BGP behaves just like RIP !!!
- By default, the best path is determined by hop count. However, a hop is not a router but an AS (Autonomous System).
BGP Packets and Tables
- Open: starts the session
- Update: network reachability exchanges
- Notification: something bad has happened; close session
- Neighbor Table: the connected BGP friends
- BGP Table: a list of All BGP routers (can be big !). It could be 2-3... times bigger than the routing table depending on how many ISPs we have.
- Routing Table: a list of the BEST routes
Implementation and Tuning
Understanding IBGP vs EBGP
- I means Internal : IBGP is used between routers in the same AS. IBGP routers does not need be be directly connected, they used internal routing protocol such as OSPF to communicate over other routers.
It is possible to act as a Transit Network. If internal routers does not know routers learned from BGP, we create a Black Hole.
- E means External : EBGP is used between different AS.
In EBGP, Routers must be directly connected.
Establishing BGP Neighbor Relationships
Start the BGP process
R1(config)# router bgp AS
A router could only run BGP for one AS:
R1(config)# router bgp 6500 R1(config-router)# exit R1(config)# router bgp 6501 BGP is already running: AS is 6500
R1(config-router)# neighbor 10.65.12.1 remote-as 5500
Neighbors are configured manually.
R1#sh ip bgp summary BGP router identifier , local AS number 6500 Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 10.65.12.1 4 5500 0 0 0 0 0 00:01:34 Idle
When the remote-as number is the same AS the router bgp AS, routers detects automatically that it is a IBGP relationship.
When routers have multiple interfaces for redundancy in the network, we use loopback address to create neighbor relationship in IBGP. We must then set the source address for the routing updates.
R1(config)# int loopback 4 R1(config-if)# ip address 220.127.116.11 255.255.255.255 R1(config)# router bgp 5500 R1(config-router)# neighbor 18.104.22.168 remote-as 5500 R1(config-router)# neighbor 22.214.171.124 update-source loopback 4
In EBGP, routers must be directly connected. Then, if we want to use loopback address, the ebgp-multihop argument must be used.
R1(config-router)# neighbor 126.96.36.199 ebgp-multihop 2
Most of the times, we should not use more than 5 hops.
Advertising Networks into BGP
Two ways to get networks into BGP:
- Network Command. This command is very different from other routing protocols. In OSPF for example, the network command tells what network to advertise but it also tells what interface is to form relationships on. In BGP, the network command only tells what network to advertise.
R1(config)# router bgp 5500
The next command will advertise the classfull A network.
R1(config-router)# network 188.8.131.52
To advertise a specifi network, we must use the mask argument. Using mask, the exact network/mask must be in the routing table.
R1(config-router)# network 184.108.40.206 mask 255.255.255.0
So the only way to summarize with the network command is to use a classfull network.
- Redistribution. Like other routing protocols, it is possible to create an access-list, then a route-map to filter redistribution. It is possible to redistribute other routing protocols such as RIP, OSPF or EIGRP but it is already possible to redistribute static route or connected network.
R1(config-router)# redistribute connected route-map FILTER
Show the BGP routing table
R1#sh ip bgp BGP table version is 8, local router ID is 10.14.15.16 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 220.127.116.11/24 0.0.0.0 0 32768 i *> 18.104.22.168 10.14.15.17 0 0 6500 i
- the * means that the router is valid
- the > means that this route is the best and will appear in the routing table.
- The next hop of 0.0.0.0 means that this network in on my router.
Auto-Summary is off by default on IOS ≥ 12.2(8)T. In earlier IOS, we have to deactivate it manually.
R1(config)# router bgp 5500 R1(config-router)# no auto-summary
Understanding BGP Synchronization
Do not use or advertise a route learned via IBGP until the same route has been learned from the interal routing protocol.
Routers running IBGP should not have to be directly connected. So if a router send a packet to a network learned only by IBGP, other routers running only the internal running protocol will not be able to route this packet because they have never learned this route.
BGP Synchronization is off by default on IOS ≥ 12.2(8)T.
R1(config)# router bgp 5500 R1(config-router)# no synchronization
How BGP Handles Next Hop Addresses
- For EBGP Peers : change next hop address on advertised routers
- For IBGP Peers : do not change next hop address on advertised routes. So when a router announce a route learned by a EBGP peers to a IBGP neighbor, it will not change the next hop address. The internal IBGP peer will then do not know how to reach this external next-hop. The router running EBGP and IBGP peers, instead of advertising its EBGP peers as the next-hop have to inform the IBGP peers that he is the next-hop.
R1(config)# router bgp 5500 R1(config-router)# neighbor 22.214.171.124 next-hop-self
Understanding BGP peer groups
BGP Peer Groups : Allow you to assign configurations in groups rather than to each individual neighbor.
- We create a group with all the global commands
R1(config)# router bgp 5500 R1(config-router)# neighbor IBGP_PEERS peer-group R1(config-router)# neighbor IBGP_PEERS remote-as 5500 R1(config-router)# neighbor IBGP_PEERS next-hop-self R1(config-router)# neighbor IBGP_PEERS update-source loopback 1
- then apply it to all individual neighbor.
R1(config-router)# neighbor 126.96.36.199 peer-group IBGP_PEERS R1(config-router)# neighbor 188.8.131.52 peer-group IBGP_PEERS
BGP split-horizon : do not send update that you've learned from IBGP to another IBGP.
How BGP neighbor relationships form
1. IDLE : verifying route to neighbor
2. ACTIVE : attempting connectivity to neighbor
3. OPEN SENT : open message (HELLO) sent to neighbor
4. OPEN CONFIRM : neighbor replied with open message
4a. ACTIVE : neighbor failed to reply or mismatched parameters
A general rewiew of 'show' and 'debug' command
BGP Summary and Neighbor relationship
R1# show ip bgp summary
A very detailed and not useful command to show neighbor is:
R1# show ip bgp neighbors
It is the equivalent of sh ip interface and sh ip interface brief. The brief command show me everything I need.
The BGP routing table
R1# show ip bgp
Show the Routing Information Based Failure
R1# show ip bgp rib-failure
It shows for example why a BGP route is not in the routing table. For example a route with a lowest administrative distance. This command is very basic and is not available on all IOS.
R1# debug ip bgp events
To clear a BGP peer
We have to clear peer everytime we change a neighbor policy.
- It is possible to clear all peers
R1# clear ip bgp *
- Or it is possible to clear peers with a specific AS number or a specific neighbot
R1# clear ip bgp 6500 R1# clear ip bgp 184.108.40.206
What are the BGP Attributes ?
- The BGP metric is not simple
- Attributes are ways that you can 'tag' incoming or outgoing BGP routes
- Some Attributes are Well-known (everyone supports) while others are Optional.
- Some attributes are Manditory (must be in the update) while others are Discretionary.
- some attributes are Transitive (travel from router to router) while others are Non-transitive.
Well Known Attributes
- Autonomous System Path (AS-Path - Mandatory)
- Next Hop Address (Mandatory)
- Origin (Mandatory)
- Local Preference (Discretionary)
- Atomic Aggregate (Discretionay)
- Multi-Exit Discriminator (Med/Metric)
How BFP uses attributes to find the best path
0. Ignore routes with an inaccessible next hop address
1. Prefer the path with the highest WEIGHT.
2. Prefer the path with the highest LOCAL_PREF.
3. Prefer the path that was locally originated via a network or aggregate BGP subcommand or through redistribution from an IGP.
4. Prefer the path with the shortest AS_PATH.
5. Prefer the path with the lowest origin type.
6. Prefer the path with the lowest multi-exit discriminator (MED).
7. Prefer eBGP over iBGP paths.
8. Prefer the path with the lowest IGP metric to the BGP next hop.
9. Determine if multiple paths require installation in the routing table for BGP Multipath.
10. When both paths are external, prefer the path that was received first (the oldest one).
11. Prefer the route that comes from the BGP router with the lowest router ID.
12. If the originator or router ID is the same for multiple paths, prefer the path with the minimum cluster list length.
13. Prefer the path that comes from the lowest neighbor address.
The first line that breaks the tie permit to take a decision.
- Line 1 and 2 must be set by the administrator of the routeur. By default, these lines will not break the tie.
- WEIGHT is a local parameter and is Cisco proprietary. Set to 0 by default.
- A path without LOCAL_PREF is considered to have had the value set with the bgp default local-preference command, or to have a value of 100 by default.
- Line 4 usually break the tie. This step is skipped if you have configured the bgp bestpath as-path ignore command.
- Line 13 is completly random decision but will permit to break the tie.
Weight, Local_Pref and AS_Path could be seen in the sh ip bgp command.
R1#sh ip bgp BGP table version is 8, local router ID is 10.1.13.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path * i220.127.116.11/24 10.1.24.2 100 0 777 911 711 i *>i 10.1.36.2 0 100 0 777 711 i
The basics of modifying BGP attributes
Weight : prefere a route over another. The highest is the best.
- Set up on a per neighbor basis
R1(config)# router bgp 5500 R1(config-router)# neighbor 18.104.22.168 weight 500 R1# clear ip bgp *
Origin : where the route came from.
When we show the BGP route with the sh ip bgp command, on the right of the AS path, it is possible to see de Origin of the route. i > e > ?
- i - IGP : most of the time, it came from somebody entering the network command.
- ? - incomplete : most of the time, it came from somebody redistribute route into BGP.
- e - EGP : this is the predecessor of BGP. We should never seen a route with this origin code, because EGP is gone.
Local Preference : this is the equivalent of Weight but it could be advertise to all other routers of the AS. Weight is configure localy on the router and stay on the router. The higher is better.
- Change Local Preference for all routes
R1(config)# router bgp 5500 R1(config-router)# bgp default local-preference 500
- Change Local Preference for specific routes
R1(config)# ip access-list standard ROUTES_FOR_R3 R1(config-std-nacl)# permit 22.214.171.124 0.0.0.255 R1(config-std-nacl)# permit 126.96.36.199 0.0.0.255 R1(config)# ip access-list standard ROUTES_FOR_R2 R1(config-std-nacl)# permit 200.0.0 0.255.255.255
R1(config)# route-map LOCAL_PREF permit 10 R1(config-route-map)# match ip address ROUTES_FOR_R3 R1(config-route-map)# set local-preference 500 R1(config)# route-map LOCAL_PREF permit 20 R1(config-route-map)# match ip address ROUTES_FOR_R2 R1(config-route-map)# set local-preference 10 R1(config)# route-map LOCAL_PREF permit 30
The last empty permit line is important, because without it, the route-map will act as an ACL an other routes will not be advertise.
R1(config)# router bgp 5500 R1(config-router)# neighbor 188.8.131.52 route-map LOCAL_PREF in
Metric or MED (multi-exit discriminator) : this is the only attribte that we have to influence other AS. We suggest a neighbor AS to use a path over another. Lower is better.
- Configure it globally for all routes
R1(config)# router bgp 5500 R1(config-router)# default-metric 200
- Configure it for specific route with route-map
... R1(config)# route-map LOCAL_PREF permit 10 R1(config-route-map)# match ip address ROUTES_FOR_R3 R1(config-route-map)# set metric 200 ...
Turn off a neighbor wittout loosing all the configuration. Insteand of typing a no neighbor... command for every options, it is possible to type
R1(config-router)# neighbor 184.108.40.206 shutdown