Course contents

Module 2: Configuring BGPLesson 2.1 (1 of 6 in this module)4 of 43 in the BGP course

Configuring eBGP

The provider link is up, so why does your router still have no route to the provider's networks? Let's build the BGP conversation and then choose exactly what it may announce.

Advanced · 14 min read

You'll learn to configure a directly connected eBGP peer, originate an exact IPv4 prefix, apply explicit prefix filters and distinguish session success from route installation.

What are we trying to connect?

R1 is the company border router in AS 64500. ISP A is the provider router in AS 64501. An autonomous system (AS) is a routing domain with an AS number. Because the numbers differ, the routers use external BGP (eBGP). We want R1 to announce the company prefix 198.51.100.0/24 and accept only the provider's example prefix 203.0.113.0/24.

The prefix is a block of addresses, not a URL. Its /24 means a 255.255.255.0 subnet mask. R1 Gi0/2 connects to the company LAN at 198.51.100.2/24. The provider represents its example destination network using Loopback10 at 203.0.113.1/24. A loopback is a software interface. It creates a connected lab network without requiring a second physical LAN.

Device and roleInterfaceIPv4 address
R1, company AS 64500Gi0/0, provider link192.0.2.2/30
ISP A, provider AS 64501Gi0/0, customer link192.0.2.1/30
R1, company LANGi0/2198.51.100.2/24
ISP A, example destinationLoopback10203.0.113.1/24

Gi0/0 means GigabitEthernet0/0, the interface name used by this lab. Adapt names to your image. We assume two isolated Cisco IOS XE 17.x lab routers, with no existing BGP process. We use explicit IPv4-unicast activation so the route family is visible in the configuration.

Gi0/0 .2.1 Gi0/0192.0.2.0/30R1 · AS 64500Company: 198.51.100.0/24ISP A · AS 64501Provider: 203.0.113.0/24

Device key: R1 · AS 64500, ISP A · AS 64501 (router)

Lines show the example’s network connections. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type.

Reading the addresses

IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.

An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.

  • R1 · AS 64500: Company: 198.51.100.0/24
  • ISP A · AS 64501: Provider: 203.0.113.0/24
  1. 1. Build the session The configured neighbours exchange BGP messages over the provider link.
  2. 2. Announce the company network R1 exports only the company prefix permitted by its outbound filter.
  3. 3. Learn the provider example ISP A announces its lab network. R1 accepts only this expected prefix.
The arrows show BGP control information. Interface addresses identify the session; advertised /24 prefixes identify destination networks.

First prove that the neighbouring IP responds

Start in global configuration mode on each router. Configure R1's interfaces and ISP A's matching interface before adding BGP. On a virtual image, confirm the interfaces are actually connected to each other.

Prove the link before BGP
Prove the link before BGPAn unreachable neighbour address keeps the session in Active.Interface upand addressedPing neighbour192.0.2.1Neighbour commandonly now

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Connected route, then ping, then the neighbour command.
interface GigabitEthernet0/0 ip address 192.0.2.2 255.255.255.252 no shutdown interface GigabitEthernet0/2 ip address 198.51.100.2 255.255.255.0 no shutdown

R1: the /30 link reaches ISP A; the company /24 must be an installed connected route before BGP can originate it.

interface GigabitEthernet0/0 ip address 192.0.2.1 255.255.255.252 no shutdown interface Loopback10 ip address 203.0.113.1 255.255.255.0

ISP A: create the other end of the /30 and a connected example destination prefix.

From privileged EXEC mode on R1, run show ip interface brief and ping 192.0.2.1. The provider interface should be up/up. A successful ping checks basic IP reachability, not whether TCP port 179 is allowed. If Gi0/2 is down because nothing is attached, its connected /24 will not exist; attach a live lab LAN before expecting that advertisement.

A first eBGP session between R1 and the provider
A first eBGP session between R1 and the providerR1 in AS 64500 and the provider router in AS 64501 share the link 192.0.2.0/30. R1 uses 192.0.2.2 and the provider uses 192.0.2.1. R1 is configured with the provider's address and AS number, the provider is configured with the same in return, and a TCP session on port 179 opens between the two addresses. Once the session is Established, each side sends its routes.AS 64500 (you)AS 64501 (provider)R1198.51.100.0/24ISP-Rprovider router192.0.2.2192.0.2.1TCP 1791. Peer by addressneighbor 192.0.2.1 remote-as 645012. Session EstablishedOPEN, KEEPALIVE exchanged3. Routes exchangednetwork 198.51.100.0/24

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Both ends must name each other's address and AS number. If either side is wrong the session stays in Idle, Active or Connect and no routes move.

Create a neighbour and activate the route family

router bgp 64500 sets R1's local AS. remote-as 64501 tells R1 which AS the provider must report. The router ID is a stable BGP identifier, not the peering address. An address family selects the kind of routes exchanged; here it is ordinary IPv4 unicast.

Three pieces of one neighbour
Three pieces of one neighbourThe session, the family and the prefix each need their own line.router bgp 64500local ASneighbor remote-asstarts the sessionaddress-familyactivates IPv4networkoriginates a prefix

On small screens, swipe sideways or focus the diagram and use the arrow keys.

A session in Established with no routes usually means the family or the network statement is missing.
ip prefix-list COMPANY-ONLY seq 10 permit 198.51.100.0/24 ip prefix-list ISPA-ONLY seq 10 permit 203.0.113.0/24 router bgp 64500 bgp router-id 1.1.1.1 no bgp default ipv4-unicast neighbor 192.0.2.1 remote-as 64501 address-family ipv4 unicast neighbor 192.0.2.1 activate neighbor 192.0.2.1 prefix-list ISPA-ONLY in neighbor 192.0.2.1 prefix-list COMPANY-ONLY out network 198.51.100.0 mask 255.255.255.0 exit-address-family

R1, global configuration mode. Define exact permitted prefixes, create the external peer, activate IPv4 and originate the company network.

A prefix list matches route prefixes. Without ge or le, these entries match exactly the written prefix and length. Other prefixes meet the list's implicit deny. in checks announcements received from ISP A; out checks announcements sent to it. These are route filters, not user-packet access rules.

ip prefix-list COMPANY-ONLY seq 10 permit 198.51.100.0/24 ip prefix-list ISPA-ONLY seq 10 permit 203.0.113.0/24 router bgp 64501 bgp router-id 2.2.2.2 no bgp default ipv4-unicast neighbor 192.0.2.2 remote-as 64500 address-family ipv4 unicast neighbor 192.0.2.2 activate neighbor 192.0.2.2 prefix-list COMPANY-ONLY in neighbor 192.0.2.2 prefix-list ISPA-ONLY out network 203.0.113.0 mask 255.255.255.0 exit-address-family

ISP A: mirror the peer relationship, reverse the filter directions and originate only the provider lab prefix.

A BGP network statement needs the exact prefix and mask already present in the IP routing table. A default route or a different-length covering route is not an exact match. This command does not assign an interface address and does not create reachability by itself.

Read the session, BGP path and installed route

Illustrative Cisco IOS XE output written for this lesson, not a router capture
R1#show ip bgp summary | begin Neighbor
Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.0.2.1       4        64501      12      13        3    0    0 00:04:12        1
The final numeric 1 means Established with one accepted IPv4 prefix. It is not a BGP state named 1. If this field says Active, investigate the TCP session before investigating the network statement.
Illustrative Cisco IOS XE output written for this lesson, not a router capture
R1#show ip bgp
     Network          Next Hop            Metric LocPrf Weight Path
 *>  198.51.100.0      0.0.0.0                  0         32768 i
 *>  203.0.113.0       192.0.2.1                0             0 64501 i
The company network is locally originated; 0.0.0.0 in this next-hop field is not a default route. The provider route has next hop 192.0.2.1 and AS path 64501. The * marks a valid path and > marks BGP's best path. The final i is an origin code, not an iBGP session marker.

Run show ip route 203.0.113.1 on R1. With no competing source for this /24, expect a BGP route via 192.0.2.1, normally with Cisco eBGP distance 20. Then test ping 203.0.113.1 source 198.51.100.2. This checks the provider loopback and a return route to the company LAN. It does not test an unconfigured web server.

Three tables, three questions
Three tables, three questionsshow ip bgp summary, show ip bgp and show ip route answer different questions.show ip bgp summaryIs the session Established? How many prefixes?show ip bgpWhich paths exist and which is best (>)?show ip route bgpWhat was installed for forwarding?

On small screens, swipe sideways or focus the diagram and use the arrow keys.

A route can be in one table and missing from the next.

A small failure-and-recovery lab

  1. Record the one-prefix count and the provider route on R1. Check the reverse company route on ISP A with show ip route 198.51.100.2.
  2. On R1's lab Gi0/2, apply shutdown. The connected company /24 disappears. Its BGP network statement now lacks its exact route, so the originated advertisement is withdrawn after BGP processes the change.
  3. Check ISP A's company route again, then restore R1 Gi0/2 using no shutdown. When the connected route returns, verify the advertisement returns too.

The trade-off is control versus configuration: explicit filters take more work than accepting everything, but their effect is easy to inspect. Keep them narrow as the lab grows. Check failures with show ip route, show ip bgp and the relevant prefix list before resetting a healthy session.

Technical references: Cisco IOS XE 17.x basic BGP configuration and external BGP provider connections. Outputs are illustrative; this lesson does not claim validation on a physical router or a specific image.

Changing AS numbers with local-as

When two networks merge, or a customer moves to a new AS number, you cannot change every peer on the same day. The local-as neighbour option lets a router use a different AS number towards one neighbour, so the neighbour does not need to change its configuration while you migrate.

router bgp 64510 neighbor 192.0.2.1 remote-as 64501 neighbor 192.0.2.1 local-as 64500

R1. The router is now AS 64510, but this neighbour still sees AS 64500. The AS numbers are documentation examples.

By default the router also prepends the old AS number to routes it sends to that neighbour, so the AS path shows both numbers. Adding no-prepend hides the local-as number on routes received from the neighbour, and replace-as sends only the local-as number outbound. Treat the option as temporary: it adds an AS to the path, only works for eBGP neighbours, and should be removed when the neighbour is updated.

Technical reference: Cisco, BGP local-as feature. Commands above are illustrative.

Check your first eBGP configuration

Predict · scenario 1

The session is Established, but R1 does not advertise 198.51.100.0/24. Its LAN interface is down and only a default route exists. What should you check first?

Predict · scenario 2

What does the outbound COMPANY-ONLY prefix list filter?

Predict · scenario 3

State/PfxRcd is 1. What does that show?

FAQ

Does the BGP network command enable BGP on an interface?
No. In this configuration it requests origination of a prefix that already has an exact matching route in the IP routing table. The neighbour commands create the session. The address-family commands activate IPv4 route exchange.
Why use a filter when this lab has only one prefix?
An explicit permitted-prefix list makes the intended advertisement clear and prevents other prefixes from being exported through this peer. A later configuration change should not silently turn the customer router into transit for unrelated networks.
Can I paste this into a production router?
This is an isolated Cisco IOS XE 17.x-style learning example. The addresses and AS numbers are documentation values, not your provider's assigned values. Existing routing, peer policies and platform-specific behaviour must be reviewed separately.