Cisco eBGP Configuration

M. Ichsanul Fadhil•November 21, 2026•12 min read

Learn External Border Gateway Protocol (eBGP) fundamentals. Explore how Autonomous Systems exchange IPv4 prefixes and configure Cisco eBGP peering.

bgp.simneta
Topology Preview

In our previous routing lessons, we discussed Interior Gateway Protocols (IGPs) like OSPF and RIP. We learned how routers inside a single company discover neighbors, exchange link states, and automatically calculate the shortest path to every subnet.

In this lesson, we take the next step. We look at what happens when your packets need to leave your building and cross into completely independent networks. We examine the differences between interior and exterior routing, explore how Border Gateway Protocol (BGP) operates, and then practice configuring and verifying External BGP (eBGP) across three Autonomous Systems from scratch.

Why do we need BGP?

To understand why we need BGP, let's look at the limitations of interior routing protocols.

An IGP works under a fundamental assumption: complete administrative trust. Every router running OSPF in an area belongs to the same organization. When an interface flaps or a link changes speed, every router in the area recalculates its Shortest Path First (SPF) tree.

Now imagine you want to connect your corporate network to an Internet Service Provider (ISP) or an external partner. What happens if you try to run OSPF with the ISP?

Well, you immediately hit the wall. You cannot run an interior routing protocol across organizational boundaries for three simple reasons:

  • Scalability: The global internet has over 950,000 active IPv4 routes. An interior protocol like OSPF would completely collapse under the memory and CPU burden of calculating SPF trees for that many prefixes.
  • Stability: If you shared link-state advertisements with external providers, a single flapping cable in Tokyo or Frankfurt would force your core routers in London to rerun the Dijkstra algorithm.
  • Policy Control: OSPF only cares about finding the fastest path based on interface bandwidth. In real-world enterprise networking, path selection is driven by business policy and cost—for example, sending bulk data through a cheap transit provider while reserving a low-latency link for voice traffic.

At some point, the networking industry realized we need a completely different type of routing protocol—one designed specifically for policy-based reachability between independent organizations. That protocol is Border Gateway Protocol (BGP).

Figure 1. eBGP Inter-Domain Traffic Flow

Figure 1. eBGP Inter-Domain Traffic Flow

As shown in Figure 1 above, BGP groups routers into Autonomous Systems (AS). An Autonomous System is simply a collection of routers and subnets under a single technical administration. BGP routers do not care about the physical link details inside another AS; they only exchange reachability information—lists of IP prefixes and the sequence of Autonomous Systems needed to reach them.

What is an Autonomous System?

An Autonomous System is identified by a unique Autonomous System Number (ASN) assigned by regional registries (like ARIN, RIPE, or APNIC). ASNs come in two ranges:

  • Public ASNs (1 to 64495): Used on the global internet to identify ISPs, cloud providers, and large enterprises. These must be globally unique.
  • Private ASNs (64512 to 65534): Just like RFC 1918 private IP addresses, private ASNs can be used internally by any organization without registration.

In our lab topology today, we use three private Autonomous Systems: R1 sits in AS 65001 (Branch Office), R2 sits in AS 65000 (ISP Transit), and R3 sits in AS 65002 (Data Center).

The difference between eBGP and iBGP

BGP operates in two distinct modes depending on where the peering routers sit:

  • External BGP (eBGP): Established between routers in different Autonomous Systems (such as R1 in AS 65001 and R2 in AS 65000). Because these routers sit on opposite sides of a WAN link, Cisco IOS sets the default packet Time-to-Live (TTL) to 1. Furthermore, eBGP routes are assigned an Administrative Distance of 20, making them highly preferred over interior protocols.
  • Internal BGP (iBGP): Established between routers inside the same Autonomous System. Because internal peers may be separated by multiple internal routers, iBGP packets use a default TTL of 255. Cisco IOS gives iBGP routes an Administrative Distance of 200, ensuring the router always prefers local IGP paths whenever available.

In this lab, all our sessions are eBGP because every peering connection crosses an Autonomous System boundary.

How does BGP establish peering?

Before BGP can exchange a single route, two routers must establish a peering session. Unlike OSPF, which sends multicast Hello packets to find neighbors automatically, BGP will never discover neighbors on its own.

You must explicitly configure the neighbor's IP address and remote AS number on both routers. Once configured, BGP does not invent its own transport mechanism—it relies entirely on TCP port 179.

Figure 2. BGP TCP Port 179 Handshake

Figure 2. BGP TCP Port 179 Handshake

As illustrated in Figure 2, the peering negotiation follows a strict sequence of states:

  • Idle: The router has detected the configured neighbor and is allocating memory resources.
  • Connect: The router actively sends a TCP SYN packet to the neighbor's IP address on port 179.
  • Active: A very common source of confusion for beginners! In BGP, 'Active' does not mean working. It means the initial TCP connection failed or timed out, and the router is actively retrying to establish the TCP connection. If a router stays in Active, check your IP connectivity or firewall rules.
  • OpenSent: The TCP three-way handshake succeeded. Both routers exchange BGP OPEN messages containing their BGP version, ASN, and Hold Time timers.
  • OpenConfirm: The router received a valid OPEN message from the neighbor and sent a KEEPALIVE to confirm.
  • Established: The session is fully up. Only in this state do routers begin exchanging routing updates (NLRI). In the CLI output of show ip bgp summary, seeing a number under the State/PfxRcd column confirms you have reached this state.

Route Advertisement & AS-Path Propagation

Once the peering session is Established, how do routes actually travel across the network?

When a router originates a local prefix into BGP, it attaches path attributes to it. The most famous and essential attribute is the AS-Path.

Figure 3. BGP Route Advertisement and AS-Path Prepend

Figure 3. BGP Route Advertisement and AS-Path Prepend

Think of the AS-Path as a sequence of passport stamps:

  • Router R3 originates the Data Center subnet 192.168.3.0/24 with an initial path: [AS-Path: 65002].
  • When Transit Router R2 receives the update and forwards it over to R1, it prepends its own AS number to the front of the list: [AS-Path: 65000 65002].
  • When Router R1 receives the update, it inspects the AS-Path. The path tells R1: 'To reach 192.168.3.0/24, you must traverse AS 65000 first, then AS 65002.'

How BGP Prevents Routing Loops

Interior protocols like OSPF prevent loops by having every router hold a full map of the area. But BGP routers know nothing about the topology inside remote Autonomous Systems. How does BGP prevent routing loops on the global internet?

It uses the AS-Path attribute as a built-in loop detection mechanism.

Figure 4. BGP AS-Path Loop Prevention

Figure 4. BGP AS-Path Loop Prevention

The rule is remarkably simple and foolproof:

  • When an eBGP router receives an update, it scans the entire AS-Path list.
  • If the router sees its own Autonomous System number anywhere in the path, it knows the packet has looped back to where it originated.
  • The router immediately drops the update and refuses to install it into its routing table.

This simple check prevents infinite inter-domain routing loops without requiring routers to compute complex shortest-path trees.

The Strict Exact-Match Rule for Network Statements

Before we jump into the CLI, there is one critical rule you must understand about the BGP network command in Cisco IOS.

In OSPF or EIGRP, typing network 192.168.1.0 0.0.0.255 simply tells the router which physical interfaces should send Hello packets. In BGP, the command does something completely different:

It tells the BGP process: 'Search the local routing table (RIB). If you find a route that matches this exact prefix and subnet mask with 100% precision, inject it into the BGP table and advertise it to neighbors.'

If interface GigabitEthernet0/1 has IP 192.168.1.254/24, its routing table contains 192.168.1.0/24. You must type:

R1(config-router)# network 192.168.1.0 mask 255.255.255.0

If you forget the mask keyword or type the wrong subnet mask, BGP will find no matching entry in the routing table and will silently refuse to advertise the route. No error will appear on your console, but your remote peers will never receive the prefix!

Network Addressing Plan

Now let's look at the lab topology. Before configuring each router, refer to the following point-to-point WAN links and LAN IP allocations:

DeviceInterfaceIP AddressRole
R1GigabitEthernet0/1192.168.1.254/24Branch LAN Gateway (AS 65001)
R1GigabitEthernet0/0192.168.12.1/24WAN link to R2
R2GigabitEthernet0/0192.168.12.2/24ISP Transit link to R1 (AS 65000)
R2GigabitEthernet0/1192.168.13.2/24ISP Transit link to R3 (AS 65000)
R3GigabitEthernet0/0192.168.13.3/24WAN link to R2
R3GigabitEthernet0/1192.168.3.254/24Data Center LAN Gateway (AS 65002)
PC1FastEthernet0192.168.1.1/24Branch Client Workstation
PC2FastEthernet0192.168.3.1/24Data Center Server

Configuring eBGP: Step-by-Step

Now let's configure our network. We follow six sequential steps to bring up peering, advertise routes, and verify end-to-end connectivity.

Step 1. Verify Layer 3 Reachability Before Touching BGP

Remember: BGP runs on top of TCP port 179. If the underlying IP link is down or ping fails, BGP will never start. Let's verify our point-to-point links first:

R1# ping 192.168.12.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.12.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5)

R2# ping 192.168.13.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.13.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5)

All pings return 100% success. Our Layer 3 point-to-point links are verified.

Step 2. Configure eBGP Peering on R1 (AS 65001)

On Router R1, we enable BGP process 65001, configure R2 as our eBGP neighbor, and advertise our local branch LAN:

R1# configure terminal
R1(config)# router bgp 65001
R1(config-router)# neighbor 192.168.12.2 remote-as 65000
R1(config-router)# network 192.168.1.0 mask 255.255.255.0
R1(config-router)# exit

Notice what happens here:

  • router bgp 65001 defines our local Autonomous System.
  • neighbor 192.168.12.2 remote-as 65000 tells R1 that the neighbor is in a different AS, automatically making this an eBGP session.
  • network 192.168.1.0 mask 255.255.255.0 advertises our local LAN into BGP with an exact subnet match.

Step 3. Configure Dual Peering on Transit Router R2 (AS 65000)

Router R2 acts as the service provider backbone. It needs two separate neighbor statements to connect both customer sites:

R2# configure terminal
R2(config)# router bgp 65000
R2(config-router)# neighbor 192.168.12.1 remote-as 65001
R2(config-router)# neighbor 192.168.13.3 remote-as 65002
R2(config-router)# exit

Within a few seconds, the console on R2 will display neighbor adjacency notifications:

%BGP-5-ADJCHANGE: neighbor 192.168.12.1 Up

The session between R1 and R2 is now Established. Notice that R2 does not configure any network commands because it acts purely as a transit provider.

Step 4. Configure eBGP Peering on R3 (AS 65002)

Next, we configure our Data Center edge router R3 to peer with R2 and advertise the server LAN:

R3# configure terminal
R3(config)# router bgp 65002
R3(config-router)# neighbor 192.168.13.2 remote-as 65000
R3(config-router)# network 192.168.3.0 mask 255.255.255.0
R3(config-router)# exit

Both peering sessions across the entire backbone are now configured.

Step 5. Verify BGP Neighbor Adjacency & Routing Tables

Now comes the most important part of working with BGP: knowing how to read the verification commands. Let's run show ip bgp summary on R1:

R1# show ip bgp summary
BGP router identifier 192.168.12.1, local AS number 65001
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.168.12.2    4 65000      14      15        3    0    0 00:08:42        1

Look at the very last column: State/PfxRcd. In Cisco IOS, when a BGP session is not established, this column displays words like Idle or Active. But once the session is Established, the word disappears and is replaced by a number indicating how many prefixes have been received from that neighbor!

Seeing the number 1 proves that R1 has successfully learned the Data Center subnet from R2. Now let's check R1's IP routing table:

R1# show ip route bgp
      192.168.3.0/24 [20/0] via 192.168.12.2, 00:09:15

The route 192.168.3.0/24 is installed via next-hop 192.168.12.2 with an Administrative Distance of [20/0] (the bracket indicates AD 20 and metric 0).

Step 6. Verify End-to-End Traffic from PC1 to PC2

Finally, we test complete end-to-end data transmission. Open the Command Prompt on PC1 and ping the server PC2:

PC1> ping 192.168.3.1
Pinging 192.168.3.1 with 32 bytes of data:
Reply from 192.168.3.1: bytes=32 time=14ms TTL=125
Reply from 192.168.3.1: bytes=32 time=12ms TTL=125
Reply from 192.168.3.1: bytes=32 time=13ms TTL=125
Reply from 192.168.3.1: bytes=32 time=12ms TTL=125

Ping statistics for 192.168.3.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss)

The ping succeeds with zero packet loss. Branch Office PC1 has successfully communicated with Data Center Server PC2 across three distinct Autonomous Systems!

Key Takeaways

  • BGP Purpose: Interior protocols (OSPF) route based on interface metrics within a single organization. BGP routes based on business policy between independent Autonomous Systems (AS).
  • Transport: BGP relies on TCP port 179. It does not discover neighbors automatically; peering must be configured explicitly with neighbor [ip] remote-as [asn].
  • Administrative Distance: eBGP routes have an Administrative Distance of 20 with a default packet TTL of 1. iBGP routes have an AD of 200 with a default TTL of 255.
  • Exact-Match Rule: The network command only advertises routes that exist in the local routing table with an exact prefix and subnet mask match.
  • Loop Prevention: BGP uses the AS-Path attribute to prevent loops. If a router detects its own ASN anywhere in the path, it immediately discards the update.
  • Verification: A session is Established only when the State/PfxRcd column in show ip bgp summary displays a number of received prefixes instead of words like Active or Idle.

Discussion & Community Notes

Ask questions, share configuration solutions, or discuss this practice lab.

0 Comments
Posting as Guest • 1-level replies supported