Back to Blog
Tutorial6 min

BGP Basics Lab: Configure eBGP Between Routers

Hands-on BGP lab: configure eBGP peering between two autonomous systems, advertise prefixes, and verify routes. Step-by-step with configs.

S
Sarah Chen
Network Engineer

BGP (Border Gateway Protocol) is the protocol that holds the internet together. It's how ISPs exchange routes and how enterprises connect to their upstream providers. BGP is covered in CCNA at a basic level and tested heavily on the CCNP ENCOR exam.

This lab walks through configuring eBGP (external BGP) between two autonomous systems — the most common real-world BGP scenario.

To generate this lab instantly:

Build a BGP lab with 2 autonomous systems.
AS 65001 has 2 routers (R1, R2) running OSPF internally.
AS 65002 has 2 routers (R3, R4) running OSPF internally.
R2 and R3 are the eBGP peers connecting the two ASes.
Each AS has a LAN network to advertise.

The Lab Topology

  • AS 65001: R1 and R2, connected via OSPF area 0
    • R1 LAN: 10.1.1.0/24
    • R2-R3 link: 172.16.0.0/30
  • AS 65002: R3 and R4, connected via OSPF area 0
    • R4 LAN: 10.2.1.0/24
    • R2-R3 link: 172.16.0.0/30

R2 and R3 form the eBGP peering — the connection point between the two autonomous systems.

Step 1: Configure the Internal Routing (OSPF)

Before configuring BGP, each AS needs internal routing so all routers can reach the eBGP peer addresses.

AS 65001 (R1 and R2):

! R1
hostname R1
interface GigabitEthernet0/0
 ip address 10.0.1.1 255.255.255.252
 no shutdown
interface GigabitEthernet0/1
 ip address 10.1.1.1 255.255.255.0
 no shutdown
router ospf 1
 network 10.0.1.0 0.0.0.3 area 0
 network 10.1.1.0 0.0.0.255 area 0
! R2
hostname R2
interface GigabitEthernet0/0
 ip address 10.0.1.2 255.255.255.252
 no shutdown
interface GigabitEthernet0/1
 ip address 172.16.0.1 255.255.255.252
 no shutdown
router ospf 1
 network 10.0.1.0 0.0.0.3 area 0

AS 65002 (R3 and R4): similar configuration with their own addresses.

! R3
hostname R3
interface GigabitEthernet0/0
 ip address 172.16.0.2 255.255.255.252
 no shutdown
interface GigabitEthernet0/1
 ip address 10.0.2.1 255.255.255.252
 no shutdown
router ospf 1
 network 10.0.2.0 0.0.0.3 area 0
! R4
hostname R4
interface GigabitEthernet0/0
 ip address 10.0.2.2 255.255.255.252
 no shutdown
interface GigabitEthernet0/1
 ip address 10.2.1.1 255.255.255.0
 no shutdown
router ospf 1
 network 10.0.2.0 0.0.0.3 area 0
 network 10.2.1.0 0.0.0.255 area 0

Step 2: Configure eBGP Peering

Now configure the BGP session between R2 and R3:

R2 (AS 65001):

router bgp 65001
 neighbor 172.16.0.2 remote-as 65002
 network 10.1.1.0 mask 255.255.255.0

R3 (AS 65002):

router bgp 65002
 neighbor 172.16.0.1 remote-as 65001
 network 10.2.1.0 mask 255.255.255.0

Breaking it down:

  • router bgp 65001 — starts BGP process with your AS number
  • neighbor ... remote-as 65002 — defines the eBGP peer and its AS number. Because the remote AS (65002) differs from the local AS (65001), this is eBGP.
  • network ... mask ... — advertises a prefix into BGP. The route must exist in the routing table for BGP to advertise it.

Step 3: Verify the BGP Session

R2# show ip bgp summary
 
BGP router identifier 172.16.0.1, local AS number 65001
BGP table version is 3, main routing table version 3
2 network entries using 288 bytes of memory
 
Neighbor        V    AS  MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.16.0.2      4 65002      10      12        3    0    0 00:05:23        1

What to check:

  • State/PfxRcd: 1 — the peer is established and you received 1 prefix from them. If this shows a state like Active or Idle, the session hasn't come up.
  • Up/Down — how long the session has been established
  • MsgRcvd/MsgSent — BGP keepalive and update messages exchanged

Step 4: Check the BGP Table

R2# show ip bgp
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.1.0/24      0.0.0.0                  0         32768 i
*> 10.2.1.0/24      172.16.0.2               0             0 65002 i

Reading this:

  • *> — best path, installed in the routing table
  • 10.1.1.0/24 — locally originated (next hop 0.0.0.0, weight 32768)
  • 10.2.1.0/24 — learned from the peer (next hop 172.16.0.2, AS path: 65002)
  • AS Path65002 i means this route came through AS 65002. The i means it was originated via the network command (IGP origin).

Step 5: Verify End-to-End Connectivity

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

If R1 can reach R4's LAN (10.2.1.0/24), BGP is working. The route was:

  1. R1 → R2 (via OSPF within AS 65001)
  2. R2 → R3 (via eBGP across the AS boundary)
  3. R3 → R4 (via OSPF within AS 65002)

Check R1's routing table:

R1# show ip route bgp
 
B    10.2.1.0/24 [20/0] via 172.16.0.2, 00:03:45

The B means this route was learned via BGP. The [20/0] shows BGP's administrative distance (20 for eBGP).

BGP vs OSPF: Key Differences

OSPFBGP
TypeInterior Gateway Protocol (IGP)Exterior Gateway Protocol (EGP)
Use caseWithin an organizationBetween organizations/ISPs
AlgorithmSPF (shortest path)Path vector (AS path)
Admin distance11020 (eBGP), 200 (iBGP)
ConvergenceFast (seconds)Slower (designed for stability)
TransportIP protocol 89TCP port 179

OSPF finds the shortest path within your network. BGP finds the best path across the internet.

Common BGP Mistakes

1. Peer IP not reachable

BGP runs over TCP. If R2 can't ping 172.16.0.2, the BGP session won't establish. Always verify basic connectivity first.

2. Wrong remote-as number

If R2 has neighbor 172.16.0.2 remote-as 65001 (same AS), that's iBGP — a completely different behavior. For eBGP, the remote-as must be different from your local AS.

3. Network statement doesn't match the routing table

network 10.1.1.0 mask 255.255.255.0 only advertises the route if 10.1.1.0/24 exists exactly in the routing table. If the route is 10.1.0.0/16 instead, BGP won't advertise it.

4. Missing redistribution

BGP routes learned on R2 won't automatically appear on R1 unless you either:

  • Redistribute BGP into OSPF (not recommended in most cases)
  • Use iBGP between R1 and R2
  • Use a default route on R1 pointing to R2

What's Next

Once you're comfortable with eBGP basics, the CCNP path includes:

  • iBGP — BGP between routers in the same AS (requires full mesh or route reflectors)
  • BGP path selection — understanding how BGP chooses the best path among multiple options
  • Route filtering — prefix lists and route maps to control which routes are advertised

For CCNA-level practice, see the OSPF configuration lab for comparison, or explore CCNP labs for advanced BGP scenarios.


Ready to practice? Get started with NetPilot — describe your BGP topology and get a working lab in under 2 minutes.

Try NetPilot Free

Build enterprise-grade network labs in seconds with AI assistance

Get Started Free