November 18, 2012 BGP next-hop-self getnetworking.net/bgp/bgp-next-hop-self BGP is an autonomous system by autonomous system routing protocol, and next hop value of BGP network updates that leave an AS, is the IP address of the router at the exit point from AS. Further, that advertisement is sent through iBGP to neighbors, but next hop attribute remains the same. Usually, a router inside AS, does not have a route to external IP address from next hop attribute. To overcome this issue, use next command: neighbor {ip-addr | group-name } next-hop-self This command will change next hop attribute for received updates to its own IP address. Type this command under BGP configuration mode on Router at the entry point in AS. Let’s consider an example. When ISP2 Router advertise its network 192.168.0.0/24, next hop ip address will be 10.0.0.2 (its fa0/0 interface). ISP1 advertise this network to Branch router with the same 10.0.0.2 next hop attribute. Let’s configure those routers, but won’t change next hop attribute for now. ISP1 1/4 ISP1(config)#interface fastEthernet 0/0 ISP1(config-if)#ip address 10.0.0.1 255.255.255.252 ISP1(config-if)#no shutdown ISP1(config-if)#interface fastEthernet 0/1 ISP1(config-if)#ip address 10.0.1.1 255.255.255.252 ISP1(config-if)#no shutdown ISP1(config-if)#exit ISP1(config)#router bgp 65000 ISP1(config-router)#neighbor 10.0.1.2 remote-as 65000 ISP1(config-router)#neighbor 10.0.0.2 remote-as 65100 ISP1(config-router)#network 10.0.1.0 mask 255.255.255.252 Branch Branch(config)#interface fastEthernet 0/0 Branch(config-if)#ip address 10.0.1.2 255.255.255.252 Branch(config-if)#no shutdown Branch(config)#router bgp 65000 Branch(config-router)#neighbor 10.0.1.1 remote-as 65000 ISP2 ISP2(config)#interface fastEthernet 0/0 ISP2(config-if)#ip address 10.0.0.2 255.255.255.252 ISP2(config-if)#no shutdown ISP2(config-if)#interface lo 0 ISP2(config-if)#ip address 192.168.0.1 255.255.255.0 ISP2(config-if)#exit ISP2(config)#router bgp 65100 ISP2(config-router)#neighbor 10.0.0.1 remote-as 65000 ISP2(config-router)#network 192.168.0.0 mask 255.255.255.0 Now will check next hop attribute on Branch router for network 192.168.0.0: Branch#show ip bgp BGP table version is 3, local router ID is 10.0.1.2 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>i10.0.1.0/30 10.0.1.1 0 100 0 i * i192.168.0.0 10.0.0.2 0 100 0 65100 i Branch# As you can see, next hop for 192.168.0.0 network is 10.0.0.2 which is outsite of 65000 AS, and Branch router doesn’t have a route to it. BGP will not put 192.168.0.0 into routing table because it doesn’t know how to reach next hop, you can see this below: 2/4 Branch#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 10.0.0.0/30 is subnetted, 1 subnets C 10.0.1.0 is directly connected, FastEthernet0/0 Branch# Now, I will type next-hop-self command on ISP1 to change next-hop attribute for external networks that will be advertised to Branch router: ISP1(config-router)#neighbor 10.0.1.2 next-hop-self And again will verify on Branch: Branch#show ip bgp BGP table version is 6, local router ID is 10.0.1.2 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>i10.0.1.0/30 10.0.1.1 0 100 0 i *>i192.168.0.0 10.0.1.1 0 100 0 65100 i Have you seen? Next hop attribute has changed from 10.0.0.2 to 10.0.1.1. Let’s check routing table: Branch#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 10.0.0.0/30 is subnetted, 1 subnets C 10.0.1.0 is directly connected, FastEthernet0/0 B 192.168.0.0/24 [200/0] via 10.0.1.1, 00:02:02 Branch# Awesome, and now a ping from Branch router to 192.168.0.1 loopback address of ISP2: 3/4 Branch#ping 192.168.0.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 28/47/76 ms Branch# That’s all, I hope you enjoyed this lab! BGP next-hop-self 3.44 KB Download 105008 views 4/4