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 role | Interface | IPv4 address |
|---|---|---|
| R1, company AS 64500 | Gi0/0, provider link | 192.0.2.2/30 |
| ISP A, provider AS 64501 | Gi0/0, customer link | 192.0.2.1/30 |
| R1, company LAN | Gi0/2 | 198.51.100.2/24 |
| ISP A, example destination | Loopback10 | 203.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.
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. Build the session The configured neighbours exchange BGP messages over the provider link.
- 2. Announce the company network R1 exports only the company prefix permitted by its outbound filter.
- 3. Learn the provider example ISP A announces its lab network. R1 accepts only this expected prefix.
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.
On small screens, swipe sideways or focus the diagram and use the arrow keys.
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 shutdownR1: 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.0ISP 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.
On small screens, swipe sideways or focus the diagram and use the arrow keys.
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.
On small screens, swipe sideways or focus the diagram and use the arrow keys.
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-familyR1, 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-familyISP 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
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
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
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.
On small screens, swipe sideways or focus the diagram and use the arrow keys.
A small failure-and-recovery lab
- 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. - 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. - 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 64500R1. 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
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?
What does the outbound COMPANY-ONLY prefix list filter?
State/PfxRcd is 1. What does that show?