BGP Configuration Example
In the last tutorial “BGP configuration example : EBGP Peering“, we configured an EBGP peering between two routers using their physical interface IP addresses. In this BGP configuration example, we’ll use loopback interfaces for BGP peering. We prefer loopback interfaces when there are multiple paths between peers because they provide more stability Using multiple paths ensures that even if one path disconnects, we can maintain the BGP peering through an alternate path.
Table of Contents
BGP Configuration Example 2: EBGP Using Loopback Interfaces
In this example, your objective is to configure EBGP between the routers using loopback interfaces and ensure that peering remains stable, even if one of the physical paths disconnects.
Topology:
Note that each router has two loopback interfaces: one forms the peering, and the other is advertised using BGP to check if BGP is working.
In the last BGP configuration example, we used physical interfaces to form the peering, which was straightforward. However, when using loopback interfaces, we need to consider the following three things:
1. Route to Peer’s Loopback Interface:
First, our router won’t have a path or route to reach the peer’s loopback interface network address, so we need to add a route using another protocol like OSPF or a static route.
2. TTL Value Adjustment:
Second, EBGP peering uses a TTL value of 1 by default, but a TTL of 1 can’t reach the peer’s loopback interface because the router decrements it when forwarding a packet. Therefore, we need to configure a TTL of 2 or more using the “ebgp-multihop” command.
3. Source IP Address Update:
Finally, we need to change the source IP address of BGP packets.By default, the IP address of the interface used to send the packet to the neighbor is the source IP address of all BGP packets. However, in this case, the peer expects packets with the source IP set to the peer’s loopback interface.
Configuration Process:
Procedure Steps
- Connect the routers as given in the topology with two physical interfaces.
- Create two loopback interfaces on both routers.
(Check the connectivity of both physical interfaces using ping.) - Configure OSPF and advertise both the physical networks and one of the loopback networks.
- Wait for OSPF adjacency and ensure two paths are shown to the neighbor’s loopback network.
- On R1, configure BGP with AS 100.
- Use the neighbor command with R2’s loopback interface IP and set the remote AS as 200.
- Use the neighbor command with the update-source option and provide R1’s loopback interface number.
- Use the neighbor command with the ebgp-multihop option to set the TTL to 2.
- Use the network command to advertise the second loopback interface.
- (Perform a similar configuration on R2.)
- Check the BGP peering state using show ip bgp summary.
- Shut down one of the physical interfaces.
- Check whether BGP maintains the peering through the available path to the peer.
Router Configuration Commands :
R1 : Setting up physical and loopback interfaces.
R1#
R1# configure terminal
R1(config)# interface fastEthernet 0/0
R1(config-if)# ip address 1.1.1.1 255.0.0.0
R1(config-if)# no shutdown
R1(config-if)# interface fastEthernet 0/1
R1(config-if)# ip address 2.1.1.1 255.0.0.0
R1(config-if)# int loopback 1
R1(config-if)# ip address 10.1.1.1 255.0.0.0
R1(config-if)# int loopback 2
R1(config-if)# ip address 11.1.1.1 255.0.0.0
R1(config-if)# exit
R1 : OSPF Configuration Commands
R1(config)# router ospf 1
R1(config-router)# network 1.0.0.0 0.255.255.255 area 1
R1(config-router)# network 2.0.0.0 0.255.255.255 area 1
R1(config-router)# network 10.0.0.0 0.255.255.255 area 1
R1(config-router)# exit
R1 : BGP Configuration Commands
R1(config)# router bgp 100
R1(config-router)# neighbor 20.1.1.1 remote-as 200
R1(config-router)# neighbor 20.1.1.1 update-source loopback 1
R1(config-router)# neighbor 20.1.1.1 ebgp-multihop 2
R1(config-router)# network 11.0.0.0 mask 255.0.0.0
R1(config-router)# exit
R2 : Setting up physical and loopback interfaces.
R2#
R2# configure terminal
R2(config)# interface fastEthernet 0/0
R2(config-if)# ip address 1.1.1.2 255.0.0.0
R2(config-if)# no shutdown
R2(config-if)# interface fastEthernet 0/1
R2(config-if)# ip address 2.1.1.2 255.0.0.0
R2(config-if)# int loopback 1
R2(config-if)# ip address 20.1.1.1 255.0.0.0
R2(config-if)# int loopback 2
R2(config-if)# ip address 11.1.1.2 255.0.0.0
R2(config-if)# exit
R2 : OSPF Configuration Commands
R2(config)# router ospf 1
R2(config-router)# network 1.0.0.0 0.255.255.255 area 1
R2(config-router)# network 2.0.0.0 0.255.255.255 area 1
R2(config-router)# network 20.0.0.0 0.255.255.255 area 1
R2(config-router)# exit
R2 : BGP Configuration Commands
R2(config)# router bgp 200
R2(config-router)# neighbor 10.1.1.1 remote-as 100
R2(config-router)# neighbor 10.1.1.1 update-source loopback 1
R2(config-router)# neighbor 10.1.1.1 ebgp-multihop 2
R2(config-router)# network 21.0.0.0 mask 255.0.0.0
R2(config-router)# exit
By using two physical interfaces and configuring OSPF to advertise the loopback network through both, the routers will have two routes to reach the neighbor’s loopback. Use the command “show ip route 20.0.0.0” on R1 to see these two paths. This setup means BGP has two paths to reach its peer at 20.1.1.1. So, even if one physical path is disconnected, BGP can maintain the peering using the other path.
With this, we have completed the first five steps. Now, let’s verify the configuration
Verification of Peering Stability
Step 6 : Check the peering status using “show ip bgp summary” on R1
The above output shows that R1 has successfully established peering with 20.1.1.1 and has learned one network from that peer.
Step 7 and 8: Now that you have confirmed the peering has been formed, you can shut down one of the physical interfaces, “FE 0/0” or “FE 0/1”. Repeat the “show ip bgp summary” command, and you will see that BGP maintains the peering with R2.
You can also check the peering using the debug command to show the keepalive packets. Use “debug ip bgp keepalives” and verify whether the routers are exchanging keepalives.
Previous >>> BGP Configuration Example 1: EBGP Peering
Further reading : cisco
We’d love to hear your feedback and suggestions about this article. Feel free to reach out to us using the WhatsApp number below.
About The Author:
Sajith Achipra has been a trainer and testing consultant at Zframez Technologies since 2009. With 15+ years of experience, he specializes in networking, Python, development, and testing. He conducts online courses to help students and professionals enhance their skills. You can reach him on WhatsApp at +91 8884 884 844 for your training and testing requirements.