BGP Next Hop eBGP vs iBGP


When a BGP router advertises a prefix, it includes a next-hop address.

You can find this in the UPDATE message:

  • Network Layer Reachability Information (NLRI) field: this contains the prefix and prefix length.
  • Path attributes: this contains the NEXT_HOP field.

This next hop differs depending on whether you use external BGP (eBGP) or internal BGP (iBGP):

  • An eBGP router typically advertises its own IP address as the next hop when it sends a prefix to another eBGP router.
  • An iBGP router typically keeps the next hop address unchanged.

In this lesson, we’ll take a look at this default behavior on some routers.

Configuration

Here is the topology we’ll use:

Bgp Ebgp Ibgp Six Routers Four Ases

We have six routers in different autonomous systems (AS). The routers in AS 456 run iBGP and use their loopback interfaces for the BGP neighbor adjacency. With these routers, we have plenty of next-hop addresses to look at.

I use IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.9(3)M on all routers.

Configurations

Want to take a look for yourself? Here, you will find the startup configuration of each device.

R1

hostname R1
!
ip cef
!
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!
interface GigabitEthernet0/0
 ip address 192.168.12.1 255.255.255.0
!
interface GigabitEthernet0/1
 ip address 192.168.14.1 255.255.255.0
!
router bgp 1
 network 1.1.1.1 mask 255.255.255.255
 neighbor 192.168.12.2 remote-as 2
 neighbor 192.168.14.4 remote-as 456
!
end

R2

hostname R2
!
ip cef
!
interface Loopback0
 ip address 2.2.2.2 255.255.255.255
!
interface GigabitEthernet0/0
 ip address 192.168.12.2 255.255.255.0
!
interface GigabitEthernet0/1
 ip address 192.168.23.2 255.255.255.0

!
router bgp 2
 network 2.2.2.2 mask 255.255.255.255
 neighbor 192.168.12.1 remote-as 1
 neighbor 192.168.23.3 remote-as 3
!
end

R3

hostname R3
!
ip cef
!
interface Loopback0
 ip address 3.3.3.3 255.255.255.255
!
interface GigabitEthernet0/0
 ip address 192.168.23.3 255.255.255.0
!
router bgp 3
 network 3.3.3.3 mask 255.255.255.255
 neighbor 192.168.23.2 remote-as 2
!
end

R4

hostname R4
!
ip cef
!
interface Loopback0
 ip address 4.4.4.4 255.255.255.255
!
interface GigabitEthernet0/0
 ip address 192.168.45.4 255.255.255.0
!
interface GigabitEthernet0/1
 ip address 192.168.14.4 255.255.255.0
!
router ospf 1
 network 4.4.4.4 0.0.0.0 area 0
 network 192.168.45.0 0.0.0.255 area 0
!
router bgp 456
 network 4.4.4.4 mask 255.255.255.255
 neighbor 5.5.5.5 remote-as 456
 neighbor 5.5.5.5 update-source Loopback0
 neighbor 6.6.6.6 remote-as 456
 neighbor 6.6.6.6 update-source Loopback0
 neighbor 192.168.14.1 remote-as 1
!
end

R5

hostname R5
!
ip cef
!
interface Loopback0
 ip address 5.5.5.5 255.255.255.255
!
interface GigabitEthernet0/0
 ip address 192.168.45.5 255.255.255.0
!
interface GigabitEthernet0/1
 ip address 192.168.56.5 255.255.255.0
!
router ospf 1
 network 5.5.5.5 0.0.0.0 area 0
 network 192.168.45.0 0.0.0.255 area 0
 network 192.168.56.0 0.0.0.255 area 0
!
router bgp 456
 network 5.5.5.5 mask 255.255.255.255
 neighbor 4.4.4.4 remote-as 456
 neighbor 4.4.4.4 update-source Loopback0
 neighbor 6.6.6.6 remote-as 456
 neighbor 6.6.6.6 update-source Loopback0
!
end

R6

hostname R6
!
ip cef
!
interface Loopback0
 ip address 6.6.6.6 255.255.255.255
!
interface GigabitEthernet0/0
 ip address 192.168.56.6 255.255.255.0
!
router ospf 1
 network 6.6.6.6 0.0.0.0 area 0
 network 192.168.56.0 0.0.0.255 area 0
!
router bgp 456
 network 6.6.6.6 mask 255.255.255.255
 neighbor 4.4.4.4 remote-as 456
 neighbor 4.4.4.4 update-source Loopback0
 neighbor 5.5.5.5 remote-as 456
 neighbor 5.5.5.5 update-source Loopback0
!
end

Verification

Let’s look at some next-hop addresses.

eBGP to eBGP

We’ll start with prefixes that are advertised from eBGP to eBGP. This is what R2 sees when we look at the loopback interface of R1:

R2#show ip bgp | include 1.1.1.1
 *>   1.1.1.1/32       192.168.12.1             0             0 1 i

This address is the IP address that R1 uses for the neighbor adjacency. When R2 advertises it to R3, it uses the IP address of its neighbor adjacency with R3 as the next hop:

R3#show ip bgp | include 1.1.1.1
 *>   1.1.1.1/32       192.168.23.2                           0 2 1 i

iBGP to iBGP

Let’s check iBGP to iBGP prefixes.

Keep in mind that because of BGP split horizon, an iBGP router only advertises a prefix to its neighbor. R4 advertises a prefix to R5, but R5 won’t advertise that prefix to R6. That’s why you need a full mesh of iBGP neighbor adjacencies. There are options to deal with this, such as a BGP route reflector.

Let’s see how R4 advertises its 4.4.4.4/32 prefix on the loopback interface to R5:

R5#show ip bgp | include 4.4.4.4
 r>i  4.4.4.4/32       4.4.4.4                  0    100      0 i

The next hop is 4.4.4.4. This is the IP address we use for the BGP neighbor adjacency. We can ignore the r. This route is not installed because the router installs the route from OSPF because it has a better administrative distance.

We see the same information on R6:

R6#show ip bgp | include 4.4.4.4
 r>i  4.4.4.4/32       4.4.4.4                  0    100      0 i

eBGP to iBGP

What about prefixes that are advertised from eBGP to iBGP? Let’s find out.

R4 learns about 1.1.1.1/32 from R1:

R4#show ip bgp | include 1.1.1.1
 *>   1.1.1.1/32       192.168.14.1             0             0 1 i

Which uses IP address 192.168.14.1 on R4’s GigabitEthernet0/1 interface as the next hop.

We see the same next-hop IP address for the prefix 2.2.2.2/32 from R2 and 3.3.3.3/32 from R3:

R4#show ip bgp | include 2.2.2.2
 *>   2.2.2.2/32       192.168.14.1                           0 1 2 i
R4#show ip bgp | include 3.3.3.3
 *>   3.3.3.3/32       192.168.14.1                           0 1 2 3 i

iBGP won’t change the next hop of eBGP learned routes. We can see this by checking R5 or R6:

R5#show ip bgp | include 1.1.1.1
 * i  1.1.1.1/32       192.168.14.1             0    100      0 1 i
R5#show ip bgp | include 2.2.2.2
 * i  2.2.2.2/32       192.168.14.1             0    100      0 1 2 i
R5#show ip bgp | include 3.3.3.3
 * i  3.3.3.3/32       192.168.14.1             0    100      0 1 2 3 i

This can be an issue because your iBGP routers might not know how to reach 192.168.14.1. You could advertise network 192.168.14.0/24 on R4 or use BGP next hop self to solve this.

iBGP to eBGP

What about iBGP routes that are advertised to eBGP? Let’s look at some.

R4 has 5.5.5.5/32 in its BGP table:

R4#show ip bgp | include 5.5.5.5
 r>i  5.5.5.5/32       5.5.5.5                  0    100      0 i

Which is advertised to R1:

R1#show ip bgp | include 5.5.5.5
 *>   5.5.5.5/32       192.168.14.4                           0 456 i

We use eBGP between R1 and R4, so R4 changes the next hop to its IP address. This also happens when a route is advertised to other eBGP routers. Here you can see R2:

R2#show ip bgp | include 5.5.5.5
 *>   5.5.5.5/32       192.168.12.1                           0 1 456 i

R2 receives the prefix with next hop IP address 192.168.12.1 (R1). Here is R3:

R3#show ip bgp | include 5.5.5.5
 *>   5.5.5.5/32       192.168.23.2                           0 2 1 456 i

R3 sees next hop IP address 192.168.23.2 (R2).

Conclusion

You have now learned what the BGP next hop looks like when you advertise routes between iBGP, eBGP, and from iBGP to eBGP or vice versa.

  • eBGP advertises its own IP address as the next hop when it sends a prefix to another eBGP router.
  • iBGP keeps the next hop address unchanged.

These are different options to change this behavior. For example, it’s possible to keep the eBGP next-hop the same with the next-hop unchanged feature. For iBGP, you can use BGP next hop self to change the next hop address to the router advertising the prefix.

I hope you enjoyed this lesson. If you have any questions, feel free to leave a comment!



Source link

case studies

See More Case Studies

Contact us

Partner with Us for Comprehensive IT

We’re happy to answer any questions you may have and help you determine which of our services best fit your needs.

Your benefits:
What happens next?
1

We Schedule a call at your convenience 

2

We do a discovery and consulting meting 

3

We prepare a proposal 

Schedule a Free Consultation