BGP is very important for Network study. We think the BGP study is very interesting according to other network topics because it is having too wide or deep network detail in itself. The Main is that if you have no knowledge about the other network protocols or else but you can easily understand BGP. We are telling you about what is BGP, and where its uses are. Why does it use? And which feature of BGP made him unique from other protocols.
BGP is a totally different protocol except for IGPs like EIGRP and OSPF. So right now please save your knowledge of IGP or switch into your mind memory and locked it for a time being.
The Full Form of BGP is Border Gateway Protocol
What is BGP: Border Gateway Protocol
Today the world is connected to the internet and the internet creates huge networks around all over the world in which all countries serve. Each country is connected with the other via the internet. Now above line looks very smooth to say but how is that internet handled on that huge network?
All devices like computers, mobile, and electronic internet machines have a unique MAC address, and internet communication has unique IP (internet protocol) address. Those IPs work on layer 3 devices like Routers, Switches, and Firewalls.
IPs are divided into two categories private and public.
Private IP is used for private purposes simply as I said. But here we have Public IPs that IPs provided by ISP (internet service providers) at a decided cost. There is an IANA (internet assigned numbers authority) that provides IPs and internet protocol resources coordination.
IP has two types of versions IPv4 and IPv6. Access use of IPv4 on ISP ends the shortage of IPs why the IPv6 version came and solve the problem of IPs.
Simply accessing the use of IP means unlimited routes travel in the ISP router routing table. And here no one IGP protocol can manage that Lac of routes. Only a Border Gateway Protocol has the superpower to handle Lac of routes. Border gateway protocol is an advanced-level routing protocol. It uses TCP protocol for providing full reliability.
Here are some points of BGP and IGP.
- IGPs work on a single AS (autonomous system) but it’s not too scalable for wide networks. For the biggest network, BGP is here.
- IGP is always looking for the shortest path to reach a destination. But in BGP we can manipulate the path with reachability and BGP do the same on the INTERNET.
- BGP is a layer 7 protocol
- BGP is a Classless protocol
- BGP support VLSMBGP use TCP protocol number 179
- BGP is more secure than other protocols.
- BGP supports manual summarization.
- BGP is a reliable protocol.
- BGP is a highly scalable protocol.
What are the Uses of BGP?
BGP exchange Routes between Autonomous Systems or different Autonomous Systems. Otherwise, for intercommunication, we are using redistribution. Redistribution has some issues like suboptimal routing and loop created in routing so come out for this problem we are using BGP.
BGP is more flexible and beneficial. I will get to know this after studying BGP in detail.
BGP has two types of ways of neighboring
- IBGP Internal BGP peer (IBGP)
- EBGP External BGP peer (EBGP)
IBGP: when you are forming a BGP neighbor between the same Autonomous System.
EBGP: when you are forming a BGP neighbor between different Autonomous systems.
Example:
R1 router and R2 Router in the same Autonomous System so it’s called IBGP neighborship and R2 and R4 or R1 and R3 in different Autonomous systems so it is called EBGP neighborship. We will discuss neighborship and how it’s formed further in detail.
Read Here: IBGP vs EBGP: Advantages | Use Cases | AD | AS | Loop Avoidance
What is Autonomous System ( AS ) in BGP?
In BGP, the Autonomous System has an important role. Simply the autonomous system is like a domain in which network devices work for the same domain or autonomous system and we can handle it by a single administrator. This Autonomous System clearly defines the route policies for the internet.
32-bit Autonomous System uses in IOS or BGP. Its range is defined as 0 to 65535
Autonomous Systems uses as public Autonomous Systems (Used for the Internet), private Autonomous Systems (Use internally), and reserved Autonomous Systems (Used by IANA for research purposes) as IPs.
NOTE* On a Router we can run only a single Autonomous System.
BGP Characteristics
- Reliability: BGP uses TCP protocol for reliability. It makes BGP a fully reliable protocol. TCP protocol for reliability first makes TCP session or 3-way handshake process with neighbor Router.
- Stability: Route dampening is a BGP feature that suppresses instability. In this feature, if any prefix does flapping create issues then it will be punished with a penalty and move into a dampening state.
- Scalability: BGP can handle lac of routes and hundreds of peer sessions.
- Flexibility: It has a robust path manipulation mechanism. Here path attributes provide flexibility to BGP and make BGP unique.
Little Drawback of BGP
- Only a Static neighborship will be formed.
- BGP convergence slow than IGP.
- In BGP, one router in a single Autonomous System work.
- Unicast message work.
Where we use BGP in the home, Business office, or ISP: with example
In BGP if a link will down then no effect on topology. In the above example, we have connected two ISP with each other here we cannot use the default route here only solution is BGP because ISP has a lac of routes in our database.
We have some customer types where we can use BGP
- Single homed customer
- Dual homed customer
- Single Multi-homed customer
- Dual multi-homed customer
How does Neighborship form in BGP?
Router# neighbor x.x.x.x remote-as XXXXX (neighbor command)
In other protocols, we have never done neighbor commands to enable neighbor ships between two routers because there is a dynamic neighbor ship created. But in BGP we are using the neighbor command for a neighborship between two routers.
In IGP network command is used for neighborship. This Network command is used for DND (dynamic neighbor discovery) and adds that network to the router database and topology table.
But in BGP we statically use the neighbor command for neighborship and the network command in BGP is used only to add the prefix in the database or topology table.
In IGP multicast hello message exchange between routers and match decided parameters after that neighbor ship formed then database exchange between them. But BGP uses TCP sessions or connections.
TCP session sends an open message to the neighbor router and exchange parameter after that continues to send a keep-alive message to check neighbor is up or down.
Neighborship Types of Ways of BGP
- IBGP Internal BGP peer (IBGP)
- EBGP External BGP peer (EBGP)
IBGP: when you are forming a BGP neighbor between the same AS (autonomous system).
EBGP: when you are forming a BGP neighbor between different AS (autonomous systems).
Above is the basic BGP neighboring behavior, but we have a concern about why we need IBGP.
As we know BGP is used for inter- Autonomous System communication which can be done by EBGP.
Then why IBGP?
IBGP requirement is very simple we show you an example. When we want to pass an Autonomous System route to another Autonomous System then we can do it with EBGP but right now in between two Autonomous Systems, there is a third Autonomous System that is called the transit Autonomous System. Transit Autonomous systems use to exchange internal routes. In the ISP end, we are using that for example:
A command to Check BGP Neighborship
- ROUTER# show BGP ipv4 unicast summary
- ROUTER# show IP BGP summary
Run this command output will provide information about the neighbor router.
BGP basic feature
1. Directly connected Check
This feature will work only for EBGP. EBPG router will initiate a TCP session when the Neighbour router or network will be directly connected if not directly connected then the router will not initiate the TCP session. This problem will come out of DCC (Directly connected Check) feature.
2. TTL (Time to Live)
In IBGP TCP message used by default, TTL is 255 means whether the neighbor is directly connected or not. But when we talk about the EBGP, that use by default TTL value is 1.
When a router sends TTL 1 to another and another router receives it with TTL 0 and we know that TTL 0 will always discard by a Router then how does it process EBGP packets? This problem solves by the TTL feature we will discuss in detail in the next blog.
3. UPDATE THE SOURCE
By default TCP message sync, it will check the routing table to reach out to the network specified in the neighbor command. By default, the exit interface IP address is used as the source IP address for all packets.
But when we are forming a neighborship with LOOPBACKs, then we have to update the SOURCE because the neighbor router expects that I will receive the TCP sync message from the neighbor IP assigned in the neighbor command. That will create a problem with the neighborship form and the solution is the UPDATE SOURCE feature.
4. NEXT HOPE SELF
IBGP and EBGP have different functions with the NEXT HOPE feature. Both have a next hope behavior, in IBGP it is used for loop prevention. Whenever a router advertises its own network it will forward its own next hope with it (both IBGP and EBGP case).
BGP Neighborship States
IDLE: No route to the neighbor (no way to go neighbor) in this state. Try to initiate the TCP session.
CONNECT: In this state, a TCP session is initiated (3-way Hand Shake), and if the TCP session establishes then the BGP state directly goes to the OPEN SENT state. And if the TCP session is not formed then the state is on hold at ACTIVE STATE try again the TCP session for a time being. For the new session, it will again start from IDLE STATE.
ACTIVE: Try a new TCP session here. Reset or hold the timer is 4 minutes, in this time if a TCP session establishes then go to OPEN SENT otherwise go back to CONNECT STATE.
OPEN SENT: In this state, a router sends an open message that open message will match the parameter for the neighboring if the parameter will match then the router goes to on next state called OPEN CONFIRM otherwise parameter does not match then the router will go back to ACTIVE state
OPEN CONFIRM: The parameter has been matched and neighborship formed now in this state KEEP ALIVE message will exchange with both routers to define the connectivity. Go on to the next state.
ESTABLISH: that is the last state of BGP where the peering is established. In this state UPDATE, MESSAGE will exchange with routers.
BGP Message Type
BGP messages travel over TCP. In the BGP 4 type of message.
- OPEN MESSAGE
- KEEPALIVE MESSAGE
- UPDATE MESSAGE
- NOTIFICATION MESSAGE
1. OPEN MESSAGE
In the OPEN message, BGP matches the parameter for a neighbor with another router. In the OPEN message, some parameter matches like BGP version, Type filed, ROTER ID, BGP router’s own Autonomous System number, and hold down timer.
Previously we have studied about BGP state in an OPEN state router sent an OPEN message if all these parameters will match then neighborship will form with another router otherwise neighborship will not form.
2. KEEPALIVE MESSAGE
We know the work of a keep-alive message in IGPs that is called a hello message. But in BGP OPEN message and KEEP ALIVE both together work as a hello message.
Let us explain the OPEN message is used for only parameter matching and KEEP ALIVE tells us whether the neighbor is up or down. It means KEEL ALIVE is used to check neighbor is alive or not.
For this work, it uses the timer or periodically sends a message (keel alive message every 60 sec send periodically and its hold-down timer is 180 sec). That timer is used in the parameter of OPEN MESSAGE. (TYPE CODE 4 travel in this message)
3. UPDATE MESSAGE
UPDATE message according to the name we can think it is used for giving an update to its neighbors. Right, it is giving information like routes that advertise in the BGP network and then the router adds that network into the routing table.
In the BPG UPDATE message, some info travels like NLRI (NETWORK LAYER REACHABILITY INFORMATION), Path Attributes info TAGG, and TYPE code 2.
4. NOTIFICATION MESSAGE
In this message notification travel when something will happen in the BGP network. It will show the breakdown of the neighborship and by this message, all sessions will be closed with that neighbor.
BGP Path Attributes
In BGP path attributes are used for path manipulation it depends on attribute features. In IGP we have metrics for path selection but in BGP we have path attributes.
BGP divides the path attributes into two category
- Well known attributes
- OPTIONAL attributes
Well, known attributes add by default in all updates of BGP, and BGP software knows this very well. OPTIONAL attributes are optional means we can use them manually if we want to add in BGP updates and BGP software does not understand them.
Now Well Know is also divided into two categories
- MANDATORY: these attributes travel in every update of BGP. Examples of Autonomous Systems are PATH, NEXT HOPE, etc.
- DISCRETIONARY: These attributes are not available in every BGP update. It depends on whether a neighborship is IBGP or EBGP like LOCAL Preference travel on in IBGP updates.
OPTIONAL attributes also divided into two categories
- TRANSITIVE: When we add these attributes in the BGP update then the router will forward it either understand or not. Like AGGREGATOR etc.
- NON-TRANSITIVE: When we add these attributes in the BGP update then the router will not forward it. Like MED etc.
BGP Path Decision Process
We are now discussing path manipulation or traffic manipulation by using the above attributes. We know that in a house door, we can come inside or can go outside so the way is very simple that’s also applied within BGP attributes.
Here is an Autonomous System two way is available for traffic first incoming traffic and second outgoing traffic. In the below diagram, we can easily understand whether traffic comes IN or come OUT in BGPO Autonomous System 100.
Accordingly, we have a different type of traffic influence we have BGP attributes. BGP attribute has its own different features that we can use for incoming or outgoing traffic. By default, BGP uses one PATH as a BEST.
Best Path Selection in BGP
BGP attributes to use for best-path selection and BGP has decided on serial-wise attributes for best-path selection.
- NEXT-HOPE reachability
- WEIGHT
- LOCAL PREFERENCE
- SELF ADVERTISE
- Autonomous System – PATH
- ORIGIN CODE
- MED
- EXTERNAL > INTERNAL
- IGP COST TO REACH NEXT HOPE
- OLDEST PATH FOR EBGP NEIGHBOUR
- ROUTER ID FOR IBGP NEIGHBOUR
- LOWER NEIGHBOUR ADDRESS
NEXT HOPE
For best path selection firstly BGP uses next hope attributes. NEXT HOPE checks the reachability with a neighbor, for example, R1 checks the reachability from R2 and R3 if it’s only from R2 then R2 routes are selected as the BEST PATH. If R2 and R3 both have reachability of NEXT HOPE then BGP uses the next criteria or attributes.
WEIGHT
When NEXT HOPE is in a tie situation then BGP checks the BEST path with the WEIGHT attribute. It is a CISCO proprietary and locally significant. It will not carry in BGP updates.
The router uses 32768 WEIGHT value for self and the higher value is preferred. All receiving routes carry 0 WEIGHT value. By default, R1 carries the same WEIGHT value from R2 or R3 and if the situation is a tie again then BGP uses the next attribute for best-path selection.
In BGP update LOCAL Preference time add or some time not add. It is mostly used for IBGP neighbors. By default, 100 values are used for internal prefixes and a higher LOCAL preference is preferred.
If in any case, a router has received two same routes from IBGP or EBGP then it will not compare LOCAL preference at that time router go on the next criteria.
SELF ADVERTISEMENT
In these criteria first, come get first place work. Mean SELF-advertisement first accepted is preferred.
Autonomous System – PATH
Autonomous System – PATH is a very important attribute in path manipulation. Autonomous System – PATH makes a list in the router in which the store received the Autonomous System list.
A maximum of 64 Autonomous systems can store on this list. Less no. of Autonomous System routes use for the best path. If it is also a tie then go on to the next criteria.
ORIGIN CODE
- (I > E >?) I: it is showing IBGP routes.
- E: it is showing EBGP routes.
- ?: It is showing redistribution routes.
For these three routes preferred the first IBGP and then EBGP after that redistribute routes.
MED
We can call it a metric. MED is used in the time of redistribution. When we are doing redistribution then MED adds with routes and a lower MED value is preferred first. By default, a 0 MED value is used. After this use the next criteria.
EXTERNAL>INTERNAL
External prefixes are preferred first as compared to internal prefixes.
IGP COST TO REACH NEXT_HOPE
Every link has its own cost value and a lower cost value is preferred. Serial link uses 64 COST value other side Ethernet link uses 1 COST value. In this both links, the Ethernet link is used as the best path selection. If the link is the same cost then use the next criteria.
OLDEST PATH
It is used only for EBGP neighbors. With the name its works like that. If routes receive first uses as the best path.
ROUTER ID
It is used for IBGP neighbors. The lower router ID is used for the best path. If the router ID received the same then use the next criteria.
LOWER NEIGHBOUR ADDRESS
It is the last criterion for the best path selection. In both neighbor routers which have lower neighbor addresses are used as the best path.
All the above is about the best path selection process in BGP via attributes. We have explained to you only simply work or feature of path selection attributes.
Further, we will describe all these attributes in a practical manner that how we can use and where we can use the attributes for inbound or outbound traffic. With these attributes we can do load balancing also we will show you all in detail in the next blogs.
BGP have more feature and that feature makes BGP unique. We are telling you basically all about those features.
BGP Local Autonomous System, no Prepend and Replace Autonomous System Feature
CUSTOMER uses AIRTEL. Assume that if in a case AIRTEL goes down or overtakes by another ISP like TATA above example is set for the understanding of the LOCAL Autonomous System feature.
You see here CUSTOMER has 300 Autonomous systems and AIRTEL has 200 Autonomous systems. In the case of overtaking AIRTEL via TATA then we cannot able the configuration on a customer router.
To come out with this problem we use the LOCAL Autonomous System feature. No, the PREPEND feature to use for that only customer Autonomous System will go to in the TATA router. REPLACE AS is used to avoid the local Autonomous System and customer Autonomous System.
BGP Filtering
We can filter routes in BGP via ACCESS LIST, PREFIX LIST, and ROUTE MAP. We can use the Autonomous System-PATH ACCESS LIST. BGP FILTERING can be inbound or outbound.
In BGP, filtering will be done on a per-neighbor basis, not on a process basis. By using a filter list we can directly call Autonomous System-PATH ACL in BGP. We can also call Autonomous System-PATH ACL in the route map in BGP.
AUTO Summary
When we enable auto-summary in BGP. The router will search for a subnet of a network that we advertised by network command. The router checks the routing table for the subnet.
If it is finding a subnet then it will add that network summary to the BGP table. Unlike IGPs, BGP has the summary only in the BGP table, not in the routing table.
Authentication in BGP
BGP Authentication will check when two routers form neighborship. If authentication will not match then neighborship cannot be from between that routers.
If a neighborship is already formed between two routers and then we apply authentication, it will have no impact on the neighborship until we will clear that neighborship.
Blackhole in BGP
A black hole is a condition when two routers form an indirect neighborship and exchange BGP updates but data flow is not taking place between them. This is called a black hole in BGP.
Routers R1 and R4 do not have routes to forward traffic. R1 and R3 will form indirect neighborship and exchange these routes but R2 does not know about these routes so, all data traffic will be dropped by R2. The black hole problem will always occur in BGP indirect neighborship.
When we have multiple links between two routers and we want an indirect neighbor ship but due to the black hole problem we are using loopback for neighborship. Mostly we are using LOOPBACK for an indirect neighborship. This was the basic about that in detail further we will write.
How Loop is Prevented in BGP?
Different Autonomous Systems – In different Autonomous Systems loop is prevented by Autonomous System-PATH. How to loop is prevented in different Autonomous systems is explained in the below example.
Whenever a router sends an update in another Autonomous System it will add its own Autonomous System number with all prefixes that it will send in updates. You can see in the above example how the X route starts from the R1 router.
R1 adds its own Autonomous System with prefixes and sends it to R2. But R2 and R3 are in the same Autonomous System (IBGP NEIGHBOUR SHIP) and the same Autonomous System will not add an Autonomous System number in updates.
R3 adds its own as for update of R4. Same as it is R4 also add your own Autonomous System number and sent it to R1. When R1 received this update from R4, it will find its own AS number in this update then it will discard it and prevent the network LOOP.
SAME Autonomous System – In the same Autonomous System, whenever the router receives an update from its IBGP neighbor then it will not forward this update to other IBGP neighbours so, that loop will not be formed. For example:
Whenever R3 receives an update of network X from a different Autonomous System, it will forward it to R2. R3 will not add its Autonomous System number because the same Autonomous System does not send its own Autonomous System with it. Then R2 sends it to R5 and R5 sends it to R4. R4 sends the same update to R3 so, that the control plane loop will be formed.
To resolve this problem a rule was made that if in the same Autonomous System whenever the router receives an update from its IBGP neighbor then it will not forward this update to another IBGP neighbor so, that loop will not be formed. This is the called IBGP loop prevention mechanism. This mechanism prevents the control plane loops.
Synchronization in BGP
The synchronization feature is used when BGP is redistributed into IGP to resolve the black-hole problem. But if redistribution fails to work or there is some problem in redistribution then a black hole will occur again.
To reduce this problem we are using synchronization. The synchronization feature will be enabled between two IBGP neighbors. According to this feature, a router will mark the routes best and install them in its routing table if these routes will get from BGP as well as IGP.
BGP Dynamic Neighborship
BGP dynamic neighborship supports BGP peering to a group of remote neighbors that are defined by the range of IP Addresses. BGP each range can be configured as a subnet IP address.
BGP neighbor is configured using a range of IP addresses and BGP peer groups. The benefit of using the BGP dynamic neighborship is that configuration will be reduced.
After a subnet range is configured for the BGP peer group and a TCP session is initiated by another router for the IP address in the subnet range, a new BGP neighbor is dynamically created.
Backdoor Feature
When a router receives routes with EBGP or IBGP. EBGP routes will always be best installed in the routing table of the router because of best AD is 20.
But we want to add IBGP routes in the routing table for that purpose we can use the BACKDOOR feature.
This feature increases the AD of EBGP routes above 200 so, that IBGP routes will be installed into the routing table. We will discuss this in detail with an example.
Multi-Protocol BGP
Simple BGP version 4 supported the IPV4 unicast address family. To overcome this problem or limitation we are using MP BGP (MULTI PROTOCOL BGP). MP BGP supports IPV4 and IPV6 unicast or multicast address families.
MP BGP works on MPLS VPN. MP BGP helps to exchange the VPN labels for all different family types. We will discuss this in detail with an example.
In BGP you can convert advertisements of routes based on condition. If a route exists or does not exist, they only advertise particular prefixes to neighbors otherwise not.
A few days ago I was looking for Border Gateway Protocol explanation and accidently today I found this Incredible article.
Thanks Gurpreet Ji