You can set a global limit on the number of dynamic BGP4 neighbors, create a BGP4 peer group, and associate a subnet range with the peer group.
device# configure terminal
device(config)# router bgp
device(config-bgp-router)# local-as 65520
device(config-bgp-router)# neighbor mypeergroup1 peer-group
device(config-bgp-router)# neighbor mypeergroup1 remote-as 80
device(config-bgp-router)# listen-range 150.1.0.0/16 peer-group mypeergroup1 limit 20
device(config-bgp-router)# neighbor mypeergroup1 alternate-as add 101
The following example summarizes the commands in this procedure.
device# configure terminal device(config)# router bgp device(config-bgp-router)# local-as 65520 device(config-bgp-router)# neighbor mypeergroup1 peer-group device(config-bgp-router)# neighbor mypeergroup1 remote-as 80 device(config-bgp-router)# listen-range 150.1.0.0/16 peer-group mypeergroup1 limit 20 device(config-bgp-router)# neighbor mypeergroup1 alternate-as add 101