BGP basics: autonomous systems, peers, and routes
Learn what BGP does, how autonomous systems and peers exchange routes, and then explore interactive route selection, configuration, and practice.
Routing / Field note
Configure a small two-router eBGP lab, advertise one route from each side, and check the session safely.
This guide builds a small eBGP session between two routers. R1 belongs to AS 65010. R2 belongs to AS 65020. They have a direct link and exchange one practice network each.
The addresses use ranges reserved for examples. Do this in a simulator or isolated lab. The commands are not a ready-made production change.
| Device | AS | Link address | Network to advertise | Router ID |
|---|---|---|---|---|
| R1 | 65010 | 198.51.100.1/30 | 192.0.2.0/24 | 192.0.2.1 |
| R2 | 65020 | 198.51.100.2/30 | 203.0.113.0/24 | 203.0.113.1 |
Before starting, configure the link addresses and create the networks to advertise. On IOS-XE, the example uses loopback interfaces. On FRRouting, the network routes must already be present in the Linux routing table. The BGP network command advertises a matching route; it does not create that route.
The commands below configure the interfaces, peer, and two lab prefixes. Check your router's interface names and release before using them.
! R1
interface GigabitEthernet0/0/0
ip address 198.51.100.1 255.255.255.252
no shutdown
!
interface Loopback0
ip address 192.0.2.1 255.255.255.0
!
router bgp 65010
bgp router-id 192.0.2.1
neighbor 198.51.100.2 remote-as 65020
network 192.0.2.0 mask 255.255.255.0
!
! R2
interface GigabitEthernet0/0/0
ip address 198.51.100.2 255.255.255.252
no shutdown
!
interface Loopback0
ip address 203.0.113.1 255.255.255.0
!
router bgp 65020
bgp router-id 203.0.113.1
neighbor 198.51.100.1 remote-as 65010
network 203.0.113.0 mask 255.255.255.0FRR requires an inbound and outbound policy for eBGP by default in many standard configurations. This example allows only the two lab prefixes. Configure the link and loopback routes in Linux before starting BGP.
! R1 — /etc/frr/frr.conf
ip prefix-list R1-IN seq 5 permit 203.0.113.0/24
ip prefix-list R1-OUT seq 5 permit 192.0.2.0/24
route-map R1-IN permit 10
match ip address prefix-list R1-IN
route-map R1-OUT permit 10
match ip address prefix-list R1-OUT
router bgp 65010
bgp router-id 192.0.2.1
neighbor 198.51.100.2 remote-as 65020
address-family ipv4 unicast
network 192.0.2.0/24
neighbor 198.51.100.2 route-map R1-IN in
neighbor 198.51.100.2 route-map R1-OUT out
exit-address-family
!
! R2 — reverse the prefixes and neighbor direction
ip prefix-list R2-IN seq 5 permit 192.0.2.0/24
ip prefix-list R2-OUT seq 5 permit 203.0.113.0/24
route-map R2-IN permit 10
match ip address prefix-list R2-IN
route-map R2-OUT permit 10
match ip address prefix-list R2-OUT
router bgp 65020
bgp router-id 203.0.113.1
neighbor 198.51.100.1 remote-as 65010
address-family ipv4 unicast
network 203.0.113.0/24
neighbor 198.51.100.1 route-map R2-IN in
neighbor 198.51.100.1 route-map R2-OUT out
exit-address-familyThe two prefixes and policies are an example for the named lab only. FRR's eBGP policy defaults and syntax can change between profiles and releases. Confirm them in the documentation for the FRR version you run.
First confirm that the link works. Then check the BGP session and route table. A neighbor showing Established means the BGP session is up; it does not by itself prove that the expected routes are accepted or installed for forwarding.
! Cisco IOS-XE
show ip bgp summary
show ip bgp
show ip route bgp
!
! FRRouting
show bgp summary
show bgp ipv4 unicast
show ip routeYou should see the neighbor session established and the other router's permitted lab prefix in the BGP table. If not, check the remote AS, link reachability, address-family activation, route-map, and whether the route to advertise exists.
The BGP learning experience includes copyable examples for eBGP setup, Local Preference, and iBGP route sharing. For session failures, use the layered BGP neighbor checklist.
Continue reading
Learn what BGP does, how autonomous systems and peers exchange routes, and then explore interactive route selection, configuration, and practice.
Separate BGP transport, session, policy, and route-advertisement problems with a repeatable peer checklist.
Use Local Preference, AS_PATH, and MED to guide BGP traffic while understanding what each network controls.
Reader signal
Your feedback helps shape the next field note and lab.
Views count when this page opens. You can change or remove your vote during this tab session.