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. Main is that if you have not knowledge about the other network protocols or else but you can easily understand BGP. We are telling you about what is BGP, where it use? Why does it use? And which feature of BGP is made him unique from other protocols.
BGP is a totally different protocol except for IGPs like EIGRP and OSPF. So right now you please save your knowledge of IGP or switching 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 connected with the internet and that the internet creates huge networks around all over the world in which all countries serve. Each country is connected with each other via this internet. Now above line looking very smooth to say but how that internet handle in that huge network.
All devices like computer, mobile and electronic internet machine having a unique MAC address and for internet communication have unique IP (internet protocol) address. That IPs work on layer 3 devices like ROUTERs Switches Firewalls. IPs divided into two categories private or public. I am not going the detail of the IP address.
Private IP use for private purposes simply I said. But here we have Public IPs that IPs provided by ISP (internet service providers) with a decided cost. There is an IANA (internet assigned numbers authority) who provide IPs and internet protocol resources coordination. IP having two types of version IPv4 and IPv6. Access use of IPv4 on ISP end the shortage of IPs that why the IPv6 version came and solve the problem of IPs.
Simply access use of IP means unlimited routes travel in the ISP router routing table. And here no one IGP protocol who can manage that Lac of routes. Only a Border Gateway Protocol having a superpower to handle Lac of routes. Border gateway protocol an advance level routing protocol. It uses TCP protocol for providing full reliability.
Here are some points of BGP and IGP.
- IGPs work on single AS (autonomous system) but it’s not too scalable for the wide networks. For 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 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.
Uses of BGP
BGP exchange Routes between Autonomous Systems or different Autonomous Systems. Otherwise, for intercommunication, we are using redistribution. Redistribution having some issues like suboptimal routing and loop create in routing so come out for this problem we are using BGP.
BGP is more flexible and beneficial. That will get to know after study BGP in detail.
BGP having two types of way of neighboring
- IBGP Internal BGP peer (IBGP)
- EBGP External BGP peer (EBGP)
IBGP: when you are forming BGP neighbor between the same Autonomous System.
EBGP: when you are forming BGP neighbor between different Autonomous System.
R1 router and R2 Router in the same Autonomous System so its call IBGP neighborship and R2 and R4 or R1 and R3 in different Autonomous System so it is called EBGP neighborship. We will discuss neighborship and how it’s formed further in detail.
Autonomous System ( AS ) in BGP
In BGP, the Autonomous System has an important role. Simply the autonomous system like a domain in which network devices working for the same domain or autonomous system and we can handle it by a single administrator. In this Autonomous System clearly defines the route policies for the internet.
32-bit Autonomous System uses in IOS or BGP. Its range is defined 0 to 65535
Autonomous System uses as a public Autonomous System (Use for Internet), private Autonomous System (Use for internally) and reserved Autonomous System (Use by IANA for research purpose) as like IPs.
NOTE* On a Router we can run only a single Autonomous System.
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 doing flapping creating issues then it will be punished a penalty and move into a dampening state.
Scalability: BGP can handle lac of route 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 a router in a single Autonomous System work.
- Unicast message work.
Where we use BGP in 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 one solution is BGP because ISP having 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 Neighborship formed in BGP
Router# neighbour x.x.x.x remote-as XXXXX (neighbour command)
In other protocols, we have never done neighbor command to enable neighbor ships between two routers because there is a dynamically neighbor ship created. But in BGP we are using the neighbor command for a neighborship between two routers.
In IGP network command use for neighborship. This Network command use for DND (dynamic neighbor discovery) and add that network to the router database and topology table. But in BGP we statically use neighbor command for neighborship and network command in BGP use only to add the prefix in 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 in BGP it uses TCP session or connection. TCP session sends an open message to the neighbor router and exchange parameter after that continue to send keep-alive message to check neighbor is up or down.
BGP having two types of way of neighborship
- IBGP Internal BGP peer (IBGP)
- EBGP External BGP peer (EBGP)
IBGP: when you are forming BGP neighbor between the same AS (autonomous system).
EBGP: when you are forming BGP neighbor between different AS (autonomous system).
Above is the basic BGP neighboring behavior, but we have a concern about why we need IBGP?
As we know BGP is using for inter- Autonomous System communication which can be done by EBGP then why IBGP?
IBGP requirement is very simple we show you with an example. When we want to pass an Autonomous System route to another Autonomous System we can do it with EBGP but right now in between two Autonomous System there is a third Autonomous System that is called transit Autonomous System. Transit Autonomous System use for exchange internal routes. In 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.
We some 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 by DCC (Directly connected Check) feature. We will discuss this in detail in the next blog.
2. TTL (Time to Live)
in IBGP TCP message use by default TTL is 255 mean that 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 other and other router receive it with TTL 0 and we know that TTL 0 will always discard by a Router then how its process EBGP packets. This problem solves by the TTL feature we will discuss in detail in the next blog.
3. UPDATE 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 used as the source IP address for all packets. But when we are forming neighborship with LOOPBACKs, then we have to update the SOURCE because the neighbor router expecting that I will receive the TCP sync message from the neighbor IP assigned in the neighbor command. That will create a problem with neighborship form and the solution is the UPDATE SOURCE feature.
4. NEXT HOPE SELF
IBGP and EBGP having 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 TCP session initiate (3 way Hand Shake) and if TCP session establishes then the BGP state directly goes to OPEN SENT state. And if TCP session not formed then state on hold at ACTIVE STATE try again 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 timer is 4 minutes, in this time if 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 neighboring if parameter will match then router go on next state called OPEN CONFIRM otherwise parameter not match then the router will go back on ACTIVE state
OPEN CONFIRM: Parameter has been matched and neighborship formed now in this state KEEP ALIVE message will exchange with both router to define the connectivity. Go on 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 message travel over TCP. In the BGP 4 type of message.
- OPEN MESSAGE
- KEEPALIVE MESSAGE
- UPDATE MESSAGE
- NOTIFICATION MESSAGE
1. OPEN MESSAGE
In OPEN message BGP match the parameter for a neighborship with another router. In OPEN message some parameter matches like BGP version, Type filed, ROTER ID, BGP router own Autonomous System number and hold down timer. Previously we have studied about BGP state in 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 called 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 that neighbor is up or down. It means KEEL ALIVE use 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 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 the information like routes that advertise in the BGP network and then router adds that network into the routing table. In BPG UPDATE message some info travel like NLRI (NETWORK LAYER REACHABILITY INFORMATION), Path Attributes info TAGG, TYPE code 2.
4. NOTIFICATION MESSAGE
In this message notification travel when something will happen in the BGP network. It will show on break down of neighborship and by this message, all sessions will be closed with that neighbor.
BGP Path Attributes
In BGP path attributes are using for path manipulation it depends on attributes features. In IGP we have metric for path selection but in BGP we have path attributes.
BGP divide 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 know this very well. OPTIONAL attributes are optional mean we can use it manually if we want to add in BGP updates and BGP software not understand it.
Now Well Know also divided into two categories
MANDATORY: these attributes travel in every update of BGP. Example Autonomous System – PATH, NEXT HOPE, etc.
DISCRETIONARY: these attributes not available in every BGP update. It depends on 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 BGP update then the router will forward it either understand or not. Like AGGREGATOR etc.
NON-TRANSITIVE: When we add these attributes in 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 second outgoing traffic. In the below diagram, we can easily understand about traffic come 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 own different feature where we can use for incoming or outgoing traffic. By default BGP use one PATH as a BEST.
Best Path Selection in BGP
BGP attributes use for best path selection and BGP has decided serial wise attributes for best-path selection.
- NEXT-HOPE reachability
- LOCAL PREFERENCE
- SELF ADVERTISE
- Autonomous System – PATH
- ORIGIN CODE
- EXTERNAL > INTERNAL
- IGP COST TO REACH NEXT HOPE
- OLDEST PATH FOR EBGP NEIGHBOUR
- ROUTER ID FOR IBGP NEIGHBOUR
- LOWER NEIGHBOUR ADDRESS
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 select as the BEST PATH. If R2 and R3 both have reachability of NEXT HOPE then BGP uses the next criteria or attributes.
When NEXT HOPE on tie situation then BGP check BEST path with WEIGHT attribute. It is a CISCO proprietary and locally significant. It will not carry in BGP updates. Router use 32768 WEIGHT value for self and the higher value is preferred. For all receiving routes carry 0 WEIGHT value. By default, R1 carries the same WEIGHT value from R2 or R3 and the situation is a tie again then BGP uses the next attribute for best-path selection.
In BGP update LOCAL Preference some time add or some time not add. It is mostly used for IBGP neighbors. By default 100 value use for internal prefixes and higher LOCAL preference 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.
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. Maximum 64 Autonomous System 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 the next criteria.
(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 then EBGP after that redistribute routes.
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 lower MED value prefer first. BY default 0 MED value is used. After this use the next criteria.
External prefix preferred first as compare internal prefixes.
IGP COST TO REACH NEXT_HOPE
Every link have own cost value and lower cost value preferred. Serial link uses 64 COST value other side Ethernet link use 1 COST value. In this both link Ethernet link use as the best path selection. If the link is the same cost then use the next criteria.
It is used only for EBGP neighbors. With the name its work like that. If routes receive first it uses as the best path.
It is used for IBGP neighbors. The lower router ID is used for the best path. If 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 address use as the best path.
All above about the best path selection process in BGP via attributes. We have explained 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. By 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 use AIRTEL. Assume that if in a case AIRTEL goes down or overtake by other ISP like TATA above example is set for the understanding of the LOCAL Autonomous System feature. You see here CUSTOMER has 300 Autonomous System and AIRTEL has 200 Autonomous System. In the case of overtaking AIRTEL via TATA then we cannot able to 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 use to avoid the local Autonomous System and customer Autonomous System.
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 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.
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 in the BGP table. Unlike IGP’s, 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 from between that routers. If a neighborship 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 exchanging BGP updates but data flow is not taking place between them. This is called a black hole in BGP.
Router R1 and R4 do not have routes to forward traffic. R1 and R3 will form indirectly 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 System – In different Autonomous Systems loop is prevented by Autonomous System-PATH. How to loop is prevented in different Autonomous System 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 that how the X route starts from the R1 router.
R1 adds own Autonomous System with prefix 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 Autonomous System number in updates.
R3 adds its own as for update of R4. Same as it is R4 also add own Autonomous System number and sent it to R1. When R1 received this update from R4, it will find that it’s 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 neighbors so, that loop will not be formed. For example:
Whenever R3 receives an update of network X from different Autonomous System, it will forward it to R2. R3 will not add it’s Autonomous System number because of the same Autonomous System not send 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 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
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 black-hole will occur again. To reduce this problem we are use synchronization. Synchronization feature will be enabled between two IBGP neighbors. According to this feature, a router will mark the routes best and install it in its routing table if these routes will get from BGP as well as IGP.
BGP Dynamic Neighborship
BGP dynamic neighbor ship 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.
When a router receives routes with EBGP or IBGP. EBGP routes will always best and install it 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.
Simple BGP version 4 supported 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 family. MP BGP work 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 advertisement of routes based on condition. If a route exists or not exist, they only advertise particular prefixes to neighbors otherwise not.