Peer Groups
Replace repeated neighbor settings with a shared peer group while preserving each remote AS.
Four routers and a common policy
R1 has three external neighbors in different ASes. Start with direct sessions, then migrate the lab to loopback-sourced sessions with multihop and a common outbound MED. The complete baseline below is the direct-session starting point.
| Link | First endpoint | Second endpoint |
|---|---|---|
| R1–R2 | GigabitEthernet1 192.0.2.1/30 | GigabitEthernet1 192.0.2.2/30 |
| R1–R3 | GigabitEthernet2 192.0.2.5/30 | GigabitEthernet1 192.0.2.6/30 |
| R1–R4 | GigabitEthernet3 192.0.2.9/30 | GigabitEthernet1 192.0.2.10/30 |
Complete baseline configurations
R1
hostname R1
ip cef
interface Loopback0
ip address 10.255.0.1 255.255.255.255
exit
interface Loopback10
ip address 198.51.100.1 255.255.255.255
exit
interface GigabitEthernet1
ip address 192.0.2.1 255.255.255.252
no shutdown
exit
interface GigabitEthernet2
ip address 192.0.2.5 255.255.255.252
no shutdown
exit
interface GigabitEthernet3
ip address 192.0.2.9 255.255.255.252
no shutdown
exit
router bgp 65001
bgp router-id 10.255.0.1
no bgp default ipv4-unicast
neighbor 192.0.2.2 remote-as 65002
neighbor 192.0.2.6 remote-as 65003
neighbor 192.0.2.10 remote-as 65004
address-family ipv4 unicast
no auto-summary
neighbor 192.0.2.2 activate
neighbor 192.0.2.6 activate
neighbor 192.0.2.10 activate
network 198.51.100.1 mask 255.255.255.255
exit-address-family
endR2
hostname R2
ip cef
interface Loopback0
ip address 10.255.0.2 255.255.255.255
exit
interface GigabitEthernet1
ip address 192.0.2.2 255.255.255.252
no shutdown
exit
router bgp 65002
bgp router-id 10.255.0.2
no bgp default ipv4-unicast
neighbor 192.0.2.1 remote-as 65001
address-family ipv4 unicast
no auto-summary
neighbor 192.0.2.1 activate
exit-address-family
endR3
hostname R3
ip cef
interface Loopback0
ip address 10.255.0.3 255.255.255.255
exit
interface GigabitEthernet1
ip address 192.0.2.6 255.255.255.252
no shutdown
exit
router bgp 65003
bgp router-id 10.255.0.3
no bgp default ipv4-unicast
neighbor 192.0.2.5 remote-as 65001
address-family ipv4 unicast
no auto-summary
neighbor 192.0.2.5 activate
exit-address-family
endR4
hostname R4
ip cef
interface Loopback0
ip address 10.255.0.4 255.255.255.255
exit
interface GigabitEthernet1
ip address 192.0.2.10 255.255.255.252
no shutdown
exit
router bgp 65004
bgp router-id 10.255.0.4
no bgp default ipv4-unicast
neighbor 192.0.2.9 remote-as 65001
address-family ipv4 unicast
no auto-summary
neighbor 192.0.2.9 activate
exit-address-family
endPrepare loopback reachability
R1 needs the three remote loopback routes; each remote router needs a return route to R1’s loopback. Configure these before changing the BGP transport.
ip route 10.255.0.2 255.255.255.255 192.0.2.2
ip route 10.255.0.3 255.255.255.255 192.0.2.6
ip route 10.255.0.4 255.255.255.255 192.0.2.10R2
ip route 10.255.0.1 255.255.255.255 192.0.2.1R3
ip route 10.255.0.1 255.255.255.255 192.0.2.5R4
ip route 10.255.0.1 255.255.255.255 192.0.2.9R1# show ip route 10.255.0.2
Routing entry for 10.255.0.2/32
Known via "static", distance 1
* 192.0.2.2Inspect the repeated configuration
On R1, remove the direct-neighbor definitions and add the three loopback neighbors. Apply the same MED policy to each. The remote examples below complete the migration.
route-map SET-MED permit 10
set metric 2323
exit
router bgp 65001
no neighbor 192.0.2.2
no neighbor 192.0.2.6
no neighbor 192.0.2.10
neighbor 10.255.0.2 remote-as 65002
neighbor 10.255.0.2 update-source Loopback0
neighbor 10.255.0.2 ebgp-multihop 2
neighbor 10.255.0.3 remote-as 65003
neighbor 10.255.0.3 update-source Loopback0
neighbor 10.255.0.3 ebgp-multihop 2
neighbor 10.255.0.4 remote-as 65004
neighbor 10.255.0.4 update-source Loopback0
neighbor 10.255.0.4 ebgp-multihop 2
address-family ipv4 unicast
neighbor 10.255.0.2 activate
neighbor 10.255.0.2 route-map SET-MED out
neighbor 10.255.0.3 activate
neighbor 10.255.0.3 route-map SET-MED out
neighbor 10.255.0.4 activate
neighbor 10.255.0.4 route-map SET-MED out
exit-address-familyR2
router bgp 65002
no neighbor 192.0.2.1
neighbor 10.255.0.1 remote-as 65001
neighbor 10.255.0.1 update-source Loopback0
neighbor 10.255.0.1 ebgp-multihop 2
address-family ipv4 unicast
neighbor 10.255.0.1 activate
exit-address-familyR3
router bgp 65003
no neighbor 192.0.2.5
neighbor 10.255.0.1 remote-as 65001
neighbor 10.255.0.1 update-source Loopback0
neighbor 10.255.0.1 ebgp-multihop 2
address-family ipv4 unicast
neighbor 10.255.0.1 activate
exit-address-familyR4
router bgp 65004
no neighbor 192.0.2.9
neighbor 10.255.0.1 remote-as 65001
neighbor 10.255.0.1 update-source Loopback0
neighbor 10.255.0.1 ebgp-multihop 2
address-family ipv4 unicast
neighbor 10.255.0.1 activate
exit-address-familyReplace repetition with a group
On R1, remove the three temporary loopback definitions, create EXTERNAL, and bind each address to it. Remote AS numbers remain per neighbor because these ASes differ.
router bgp 65001
no neighbor 10.255.0.2
no neighbor 10.255.0.3
no neighbor 10.255.0.4
neighbor EXTERNAL peer-group
neighbor EXTERNAL update-source Loopback0
neighbor EXTERNAL ebgp-multihop 2
neighbor 10.255.0.2 remote-as 65002
neighbor 10.255.0.2 peer-group EXTERNAL
neighbor 10.255.0.3 remote-as 65003
neighbor 10.255.0.3 peer-group EXTERNAL
neighbor 10.255.0.4 remote-as 65004
neighbor 10.255.0.4 peer-group EXTERNAL
address-family ipv4 unicast
neighbor EXTERNAL activate
neighbor EXTERNAL route-map SET-MED out
exit-address-familyVerify inheritance and cleanup
R1# show ip bgp peer-group EXTERNAL
BGP peer-group is EXTERNAL
Members: 10.255.0.2 10.255.0.3 10.255.0.4R2# show ip bgp 198.51.100.1/32
BGP routing table entry for 198.51.100.1/32
65001
10.255.0.1 from 10.255.0.1
Origin IGP, metric 2323, localpref 100, valid, external, bestPeer groups simplify policy administration. Modern implementations also use dynamic update groups, so one peer group does not universally imply a particular CPU saving. Inbound overrides and outbound compatibility depend on platform rules. Restore the saved baseline configurations to return to direct sessions.
Key Takeaways
- A peer group shares compatible neighbor settings.
- Different external AS numbers can remain per member.
- Loopback peering requires routes in both directions.
- Group membership does not replace address-family activation.
- Verify effective attributes after changing the configuration.
Protocol and command references
Peer-group command reference · BGP specification · Router-symbol attribution.