Simplifying Router Configurations with BGP Peer Groups

« 2022 June 14 »

What is BGP Peer Groups?

A BGP Peer Group is designed to optimize system resources when processing BGP updates while also simplifying BGP configuration tasks. BGP neighbors can be assigned to the same Peer Group if they have identical outbound policies.

In other words, if multiple BGP neighbors receive the exact same set of route updates (including BGP attributes), then they can become members of a Peer Group. The following output from R1 shows the two members included in the Peer Group.

R1#show ip bgp peer-group | begin For
 For address family: IPv4 Unicast
  BGP neighbor is AS65002, peer-group external, members:
  10.1.0.2 10.2.0.2 
  Index 0, Advertise bit 0
  Community attribute sent to this neighbor
  Outbound path policy configured
  Route map for outgoing advertisements is RM-COMMUNITY
  Update messages formatted 0, replicated 0
  Number of NLRIs in the update sent: max 0, min 0

The following table compares the BGP configuration with and without a BGP Peer Group.

BGP Peer Group configuration comparison
With Peer Group Without Peer Group
R1#show run | sec router
router bgp 65001
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 network 192.168.1.0
 network 192.168.2.0
 neighbor AS65002 peer-group
 neighbor AS65002 remote-as 65002
 neighbor AS65002 password p4ssw0rd.123
 neighbor AS65002 fall-over bfd
 neighbor AS65002 send-community
 neighbor AS65002 route-map RM-COMMUNITY out
 neighbor 10.1.0.2 peer-group AS65002
 neighbor 10.2.0.2 peer-group AS65002
R1#show run | sec router   
router bgp 65001
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 network 192.168.1.0
 network 192.168.2.0
 neighbor 10.1.0.2 remote-as 65002
 neighbor 10.1.0.2 password p4ssw0rd.123
 neighbor 10.1.0.2 fall-over bfd
 neighbor 10.1.0.2 send-community
 neighbor 10.1.0.2 route-map RM-COMMUNITY out
 neighbor 10.2.0.2 remote-as 65002
 neighbor 10.2.0.2 password p4ssw0rd.123
 neighbor 10.2.0.2 fall-over bfd
 neighbor 10.2.0.2 send-community
 neighbor 10.2.0.2 route-map RM-COMMUNITY out

What is the difference between a BGP Peer Group and a Peer Template?

BGP Peer Templates are focused on hierarchically assigning BGP configuration templates through inheritance. This provides flexibility in grouping and assigning templates to different BGP neighbors. A BGP Peer Template is thus a framework for managing the BGP configuration by grouping similar elements, and linking them to each other. BGP Peer Groups do not have such flexibility.

BGP Peer Group configuration explained

In this example scnenario, two BGP Autonomous Systems (AS) are connected with two separate links. The AS 65002 has two routers, and AS 65001 has only one router R1. Thus, R1 is dual homed with the AS 65002. To simplify the configuration tasks involved in setting up the BGP connection to R2 and R3, a BGP Peer Group is applied on R1.

This means, a Peer Group is configured on R1 with the command neighbor AS65002 peer-group. The Peer Group is created first, because otherwise the following message is received:

R1(config-router)#neighbor AS65002 remote-as 65002
% Create the peer-group first

A Peer Group can have a single outbound policy applied to all neighbors. An individual neighbor cannot have a separate outbound policy compared to the one defined in the Peer Group, otherwise the following message is received.

R1(config-router)#neighbor AS65002 route-map RM-COMMUNITY out
R1(config-router)#neighbor 10.1.0.2 peer-group AS65002
R1(config-router)#neighbor 10.1.0.2 route-map RM-ASPREPEND out
% Invalid command for a peer-group member

This does not apply to inbound policies, which may be different for each neighbor within the same Peer Group. An example of such a configuration is shown below.

R1#show run | sec router
router bgp 65001
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 neighbor AS65002 peer-group
 neighbor AS65002 remote-as 65002
 neighbor AS65002 route-map RM-COMMUNITY out
 neighbor 10.1.0.2 peer-group AS65002
 neighbor 10.1.0.2 route-map RM-LOCPREF1 in
 neighbor 10.2.0.2 peer-group AS65002
 neighbor 10.2.0.2 route-map RM-LOCPREF2 in

Once the Peer Group is created, further attributes can be added to the BGP Peer Group configuration. In the following example, R1 advertises routes with the standard community 65002:100 using an outbound route-map.

BGP Peer Group configuration with an outbound route-map policy

Configuration:

R1
    R1#show run | sec router
    router bgp 65001
     bgp router-id 1.1.1.1
     bgp log-neighbor-changes
     network 192.168.1.0
     network 192.168.2.0
     neighbor AS65002 peer-group
     neighbor AS65002 remote-as 65002
     neighbor AS65002 password p4ssw0rd.123
     neighbor AS65002 fall-over bfd
     neighbor AS65002 send-community
     neighbor AS65002 route-map RM-COMMUNITY out
     neighbor 10.1.0.2 peer-group AS65002
     neighbor 10.2.0.2 peer-group AS65002
    
    R1#show run | sec ^route-map
    route-map RM-COMMUNITY permit 10
     set community 65002:100
    
    R1#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R2 **
     ip address 10.1.0.1 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
     bfd interval 100 min_rx 100 multiplier 3
    
    R1#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R3 **
     ip address 10.2.0.1 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
     bfd interval 100 min_rx 100 multiplier 3
    
    R1#show run int Lo10 | sec int
    interface Loopback10
     ip address 192.168.1.1 255.255.255.0
    
    R1#show run int Lo20 | sec int
    interface Loopback20
     ip address 192.168.2.1 255.255.255.0
    
    R1#show run | sec ^ip bgp
    ip bgp-community new-format
    
R2
    R2#show run | sec router
    router bgp 65002
     bgp router-id 2.2.2.2
     bgp log-neighbor-changes
     neighbor 10.1.0.1 remote-as 65001
     neighbor 10.1.0.1 password p4ssw0rd.123
     neighbor 10.1.0.1 fall-over bfd
    
    R2#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R1 **
     ip address 10.1.0.2 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
     bfd interval 100 min_rx 100 multiplier 3
     
    R2#show run | sec ^ip bgp
    ip bgp-community new-format
    
R3
    R3#show run | sec router
    router bgp 65002
     bgp router-id 3.3.3.3
     bgp log-neighbor-changes
     neighbor 10.2.0.1 remote-as 65001
     neighbor 10.2.0.1 password p4ssw0rd.123
     neighbor 10.2.0.1 fall-over bfd
    
    R3#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R1 **
     ip address 10.2.0.2 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
     bfd interval 100 min_rx 100 multiplier 3
    
    R3#show run | sec ^ip bgp
    ip bgp-community new-format
    
R1#show ip bgp peer-group 
BGP peer-group is AS65002,  remote AS 65002
 Fall over configured for session
 BFD is configured.
  BGP version 4
  Neighbor sessions:
    0 active, is not multisession capable (disabled)
  Do log neighbor state changes (via global configuration)
  Default minimum time between advertisement runs is 30 seconds

 For address family: IPv4 Unicast
  BGP neighbor is AS65002, peer-group external, members:
  10.1.0.2 10.2.0.2                                              « R1 and R2 are members of this BGP Peer Group 
  Index 0, Advertise bit 0
  Community attribute sent to this neighbor
  Outbound path policy configured
  Route map for outgoing advertisements is RM-COMMUNITY          « This route-map is being used
  Update messages formatted 0, replicated 0
  Number of NLRIs in the update sent: max 0, min 0




R2#show ip bgp 192.168.1.0
BGP routing table entry for 192.168.1.0/24, version 26
Paths: (1 available, best #1, table default)
  Not advertised to any peer
  Refresh Epoch 1
  65001
    10.1.0.1 from 10.1.0.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, external, best
      Community: 65002:100                                       « R2 receives the BGP route from R1 with the community value
      rx pathid: 0, tx pathid: 0x0
	  



R2#show ip bgp community 65002:100 | beg Network
     Network          Next Hop            Metric LocPrf Weight Path
 *>   192.168.1.0      10.1.0.1                 0             0 65001 i
 *>   192.168.2.0      10.1.0.1                 0             0 65001 i