Tuesday, January 31, 2012

BGP Next-hop-self

There are three most important keywords which we should have in mind while setting up BGP neighbor relationship. Even sometimes when we have successful BGP relationship, we are not able to see routes in the routing table. Following are the three important keywords.
1)ebgp-multihop :- In EBGP, neighbor relationships are only formed if we have directly connected networks. We would require to use ebgp-multihop  keyword with neighbor statement so that neighbors which are not directly connected can form relationship with each other. We need to specify a number with ebgp-multihop keyword, number can be between 1-255. This number represents how many hop counts is the router away.
2)update-source. We need to specify the interface which will be used to update neighbor table incase routers are not directly connected. Without update-source we will not be able to form BGP neighbor relationships. update-source keyword will update the interface which will be used to form neighbor relationship. see configuration example below for better understanding.
3) next-hop-self:- When ebgp relation replicates , next hop always changes.IBGP  routers only connected with other ibgp routers in same AS will not be able to talk with routers outside the AS, if they are not directly connected with each other. We would require a next-hop-self keyword in the ibgp router which is directly connected with ebgp neighbor so that other router in same AS (IBGP) can talk with ebgp routers. Refer to configuration examples below:-
Lets assume that we have three routers and we have to setup a ebgp relationship in between them.  Router A ( AS :- 34 Serial0 192.168.1.1 , loopback0 1.1.1.1) , RouterB ( AS 34, loopback0 2.2.2.2 , Serial0 192.168.1.2 , Serial1 172.16.1.1), RouterC ( AS 400 , loopback0 3.3.3.3, Serial0 172.16.1.2)
Lets start configuring Router A
router BGP 34 –> As soon as we type 34 BGP process will start in the background
neighbor 192.168.1.2 remote-as 34  –> Bgp will know that this is IBGP looking at  AS

Router B
router BGP 34
neighbor 192.168.1.1 remote-as 34
neighbor 172.16.1.2 remote-as 400  –> neighbor relationship with ebgp peer.
neighbor 3.3.3.3 remote-as 400
neighbor 3.3.3.3 ebgp-multihop 255  –>  255 is number of hops that neighbor is away. we can use any number from 1-255, it can be more specific by using 1 or 2 but my personal fav is 255 as it avoids confusion.
neighbor 3.3.3.3 update-source loopback 0 –> Here is the idea, when its sourcing the packets its sourcing it from serial interface, we need to inform the otherside that source interface is not serial interface, it is looback interface so that it cann match ip ip’s with the right interface and form neighbor relationship.
we would require to do similar configuration on router c
router bgp 400
neighbor 172.16.1.1 remote-as 34
neighbor 2.2.2.2 remote-as 34
neighbor 2.2.2.2 ebgp-multihop 255
neighbor 2.2.2.2 update-source loopback 0
Now after forming the neighbro relationships we’ll use network commands to add neighbors in routing table. Network command in BGP is bit different then Network command in other routing protocols. we ‘ll  need to define mask keywork with network command in order to advertise clasless network where as if it is using a default mask we can ignore the same.
Example
Router C
router bgp 400
neighbor 172.16.1.0 mask 255.255.255.0
note:- i cannot use network 172.16.0.0 command without mask keyword as it will treat this as  class B network. For any customised subnetting scheme we ‘ll need to specify subnet mask with mask keyword in network command.
Even after configuring above, Router A will not be able to talk with Router C. If we will use show ip bgp command on Router A. we’ll see that it has a valid route for Router C but it will not be able to ping router c. This is because next hop will be 3.3.3.3 which is not directly connected with Router A. . First thing which will come in our mind is that rule of synchronisation has taken in to effect but even after disabling synchronisation between router a and router B, Router C will not be reachable. we would need a special command on Router B so that all IBGP peers of AS 34 can talk with AS 400
To troubleshoot this we can use “debug ip bgp updates” but before using this debug we should use ” clear ip bgp *” command. We’ll see that it will show us that there is no valid path for networks in Router C. Next hop should be Router B but in the updates it will show next hp as router c. to avoid the we will use next-hop self keyword in Router B.
Router B
router bgp 34
neighbor 192.168.1.1 next-hop-self
When Router B is sending an update to Router A it is sending the update without changging its next hop so router A will receive next hop as Router C which is not directly connected. To avoid this we will use next-hop-self command in Router B so that router A should receve valid route.
Related Posts Plugin for WordPress, Blogger...