BGP Next Hop Self

next-hop-self

BGP Next Hop Self Command

In this post, we will talk about an important and mostly used command of Border Gateway Protocol, This is BGP Next Hop Self command. BGP Next Hop Self command is used under the BGP process in the router and the usage is like below:

 

neighbor {ip-address | peer-group-name} next-hop-self

 

In the routing, route advertisement is a common term. And for the route advertisement, the next hop is common. A route is advertised via its next hop ip address. This means that, “You can come to me via this door”.

 


You can also check bgp ebgp-multihop and bgp neighbor update-source loopback commands. 


 

In BGP configuration, route advertisement is also done between external peers. During this advertisement, the non directly connected routers to this external peer, the IBGP peers, need to learn how to go to the advertised route. Because their routing table do not have this information and without any information, they can not go to the destination.

 

To give this information to the IBGP peers, “next-hop-self” command is used. With next-hop-self command, we force BGP to use a specific next hop instead of protocol’s choice.

 

Let’s see how, with a configuration example. The topology used for this next-hop-self command is below:

bgp next-hop-self command example
BGP Next-Hop-Self Command
In this topology, Router A1 and Router B1 are external BGP peers. And the Router A2 and Router B2 are their internal BGP peers. Router A2 advertises its 20.0.0.0/24 network with the next hop 10.0.0.1 (ip address of Router A1’s external interface).Because of the fact that, this 10.0.0.1 ip address is not in the routing table of Router B2, it do not know this route.

 

This is also like the same for Router B2’s 40.0.0.0/24 route advertisement. This time Router B2 will send 40.0.0.0/24 route with the next hop 10.0.0.2. And the Router A2 will not know this route. Because Router A2 do not know anything about the 10.0.0.2 route.

 

RouterA1(config)# interface gigabitEthernet 0/0
RouterA1(config-if)# ip address 10.0.0.1 255.255.255.0
RouterA1(config-if)# no shutdown
RouterA1(config-if)# interface gigabitEthernet 0/1
RouterA1(config-if)# ip address 20.0.0.1 255.255.255.0
RouterA1(config-if)# no shutdown
RouterA1(config-if)# exit
RouterA1(config)# router bgp 64600
RouterA1(config-router)# neighbor 10.0.0.2 remote-as 64700
RouterA1(config-router)# neighbor 20.0.0.2 remote-as 64600
RouterA1(config-router)# network 20.0.0.0 mask 255.255.255.0

 

RouterB1(config)#interface gigabitEthernet 0/0
RouterB1(config-if)# ip address 10.0.0.2 255.255.255.0
RouterB1(config-if)# no shutdown
RouterB1(config-if)# interface gigabitEthernet 0/1
RouterB1(config-if)# ip address 40.0.0.2 255.255.255.0
RouterB1(config-if)# no shutdown
RouterB1(config-if)# exit
RouterB1(config)# router bgp 64700
RouterB1(config-router)# neighbor 10.0.0.1 remote-as 64600
RouterB1(config-router)# neighbor 40.0.0.2 remote-as 64700
RouterB1(config-router)# network 40.0.0.0 mask 255.255.255.0

 

RouterA2(config)# interface gigabitEthernet 0/1
RouterA2(config-if)# ip address 20.0.0.2 255.255.255.0
RouterA2(config-if)# no shutdown
RouterA2(config)# router bgp 64600
RouterA2(config-router)# neighbor 20.0.0.1 remote-as 64600

 

RouterB2(config)# interface gigabitEthernet 0/1
RouterB2(config-if)# ip address 40.0.0.2 255.255.255.0
RouterB2(config-if)# no shutdown
RouterB2(config)# router bgp 64700
RouterB2(config-router)# neighbor 40.0.0.1 remote-as 64700

 

To sum up without next-hop-self command, Router A2 and B2 do not know how to go to the next hop of advertised route by the other end.

 

RouterA2#show ip bgp
BGP table version is 3, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,
r RIB-failure, S Stale
Origin codes: i – IGP, e – EGP, ? – incomplete

Network Next Hop Metric LocPrf Weight Path
r>i20.0.0.0/24 20.0.0.1 0 100 0 i
* i40.0.0.0/24 10.0.0.2 0 100 0 65100 i

 

RouterA2# show ip route
Codes: C – connected, S – static, R – RIP, M – mobile, B – BGP
D – EIGRP, EX – EIGRP external, O – OSPF, IA – OSPF inter area
N1 – OSPF NSSA external type 1, N2 – OSPF NSSA external type 2
E1 – OSPF external type 1, E2 – OSPF external type 2
i – IS-IS, su – IS-IS summary, L1 – IS-IS level-1, L2 – IS-IS level-2
ia – IS-IS inter area, * – candidate default, U – per-user static route
o – ODR, P – periodic downloaded static route

Gateway of last resort is not set

20.0.0.0/24 is subnetted, 1 subnets
C 20.0.0.0 is directly connected, gigabitEthernet0/1

 

To solve this issue, next-hop-self command is configured on the external BGP peers (on Router A1 and Router B1). The aim of this command is to change next-hop attribute for external networks that will be advertised to Router A2 and Router B2.

 

RouterA1(config-router)#neighbor 20.0.0.2 next-hop-self

 

RouterB1(config-router)#neighbor 40.0.0.2 next-hop-self

 

After configuring next-hop-self command on the routers, the A2 and B2 can reach the other end’s advertised route.

 

RouterA2# show ip bgp
BGP table version is 3, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,
r RIB-failure, S Stale
Origin codes: i – IGP, e – EGP, ? – incomplete

Network Next Hop Metric LocPrf Weight Path
r>i20.0.0.0/24 20.0.0.1 0 100 0 i
* i40.0.0.0/24 20.0.0.1 0 100 0 65100 i

 

RouterA2# show ip route
Codes: C – connected, S – static, R – RIP, M – mobile, B – BGP
D – EIGRP, EX – EIGRP external, O – OSPF, IA – OSPF inter area
N1 – OSPF NSSA external type 1, N2 – OSPF NSSA external type 2
E1 – OSPF external type 1, E2 – OSPF external type 2
i – IS-IS, su – IS-IS summary, L1 – IS-IS level-1, L2 – IS-IS level-2
ia – IS-IS inter area, * – candidate default, U – per-user static route
o – ODR, P – periodic downloaded static route

Gateway of last resort is not set

20.0.0.0/24 is subnetted, 1 subnets
C 20.0.0.0 is directly connected, gigabitEthernet0/1
B 40.0.0.0/24 [200/0] via 20.0.0.1, 00:01:05

Lesson tags: BGP, routing
Back to: CCIE Enterprise Infrastructure > BGP

Leave a Reply

Your email address will not be published. Required fields are marked *

CCIE Enterprise Infrastructure

Collapse
Expand