Would like to put some facts about most famous routing protocol.
BGP – Border Gateway Protocol
According to Wikipedia currently we are using the version (BGP4), which was published as RFC 4271 in 2006.
BGP4 has been in use on the Internet since 1994.
Basically the world was changed by the 3 napkin protocol(picture was found on Network Collective Podcast):
Its simplified finite state machine is (taken from wiki) :
Some basics from BGP :
- Autonomous routing protocol based on path vector mechanism
- Slowest routing protocol
By default if route goes down BGP won’t flap it, will wait for 30 seconds before notifying
- Helps you to be reachable from multiple service providers
- To fastly reconverge BGP uses internal routing protocols, it relies on lower layer IGP
- Opposite to other routing protocols BGP has not trust for the neighbors(have multiple filters, you need to agree with you BGP peers how and what will be traversed through he link before you can establish it.
- BGP runs on top of TCP port 179
- Has triggered updates (5 seconds internal, 30 seconds external)
- 13 Different metrics for finding the best route. (largest wieght, highest local preference, locally originated, shortest as path, lowest origin type,lowest med and etc.)
- All neighbors needs to be manually set –
neighbor ip remote-as as_number
- RFC rule about the traffic and BGP – when the packet leaves your AS – it’s not your traffic anymore, so basically you can’t tell anyone else what to do with their traffic.
- Neighbor must be manually set and directly reachable
- Multiple session to same neighbor are not permitted and will be dropped.
- Network command will work differently – you really need to have the network which you want to advertise in your routing table, otherwise it won’t be advertised.It needs to be a direct match to the routing table
- BGP packets :
- Open – After configuring neighbor send a hello to neighbor router
- Update – Used to update the routing table or send any updates for changes
- Keep alive – BGP has it’s on keepalive mechanism
- Notification – Any BGP error condition events or any changes would generate a notification messages
- BGP states
- Idle – Have a neighbor connected but didn’t talked yet – usually we would see router stuck in this status when something is miss-configured.
- Active – Tries to establish a communication – a lot of issues also happens here
- Open sent
- Open confirm
- Established – all good
- Enabling BGP and adding neighbor is really simple :
- conf t
- router xx
- neighbor x.x.x.x remote-as xx
- Default hold time is 180 seconds – this is the interval after which neighbor will be considered as dead.
- After applying any BGP rule you need to clear the session : clear ip bgp * (dangerous 🙂 don’t use this in production
- BGP won’t advertise anything until you won’t specify what to advertise
- Usually ISP is putting the filter so you will be able to send only those routes which you have agreed with them
- Filtering is happening by using the route maps
- When reading the AS-Path value read it from right to left, you will be able to understand in how many autonomous systems this route has passed. Also this is the anti-loop mechanism, if router will see it’s own AS in the path it will drop it.
- BGP attributes are attached to every route advertisement
- Route-map is something similar to access-lists, it performs a if then statements which are called match/set – used for modifying the bgp attributes, policy routing, route filtering.
- EBGP is used to receive the routes and exchange them to uplinks
- IBGP – used for connection in the same AS
- IBGP does not modify any BGP attributes
- IBGP has no loop prevention mechanism
- BGP split horizon rule is to never advertise a route you received via ibgp to another ibgp peer. – So because of this you need to have a full mesh between your ibgp neighbors or use the route reflectors
- IBGP peers should be formed by using a loopback interfaces – just to have a multiple paths in case of link failure.
- IBGP and EBGP have different ad distance : EBGP learned path AD = 20; IBGP = 200
- EBGP neighbors must be directly connected, but to bend a rules a bit we can use the ebgp_multihop option.
neighbor xx.xx.xx.xx
ebgp-multihop 2 ( in case if we are using loopback for EBGP)
- Default route 0.0.0.0 won’t allow to form a EBGP
- Don’t foget to remove the private-as numbers before advertising to other EBGP peers.
- Don’t forget to put the route reflectors in cluster – to avoid loops
- To create AS in the AS confederations can be used.
And there is many more, BGP nowadays is being used everywhere and often for other goals as it was designed, anyway if you want to learn more I would suggest to visiting following links :
http://packetpushers.net/podcast/podcasts/show-355-whats-wrong-bgp-ietf-99/
http://thenetworkcollective.com/2017/09/hon-li-bgp/
https://www.cbtnuggets.com/it-training/cisco-ccip-bgp-642-661