BGP peer templates are used to summarise configuration options for re-use on multiple BGP peers. This enables the setup of a BGP peer to be made simple, and any changes to the templates will affect all peers using it.
Peer templates are divided into session and policy templates. It is possible to use one of each on a neighbouring peer. The difference between the templates is the ability to create inheritance only with policy templates. This means you can create a very general policy template which can be used as a basis for more specific templates.
An example can illustrate the advantage of using peer templates:
Without peer templates:
Assuming we have created one session template and one policy template:
The peer templates we make will look like this:
And with the ability to inherit within the policy templates it is possible to create some really clever setups, making the creation of new peers very simple. One example where using policy templates can be beneficial is if you purposely want to move traffic from one node to another. By setting up a route-map for adjusting route selection it is possible completely drain a device for traffic by simply adjusting a value and forcing a BGP refresh.
It is also possible to override values in the templates by adding them as a separate option on the neighborship. One example is using prefix-lists in the peer policy. If you use the general prefix list as standard, suddenly a customer arrives where it is necessary to use a custom prefix-list.
In this case the
Customer-A-in prefix-list will override the prefix-list in the peer-policy BGP.
The peer-policy template is able to inherit seven levels of templates. This makes it possible to build a powerful and very flexible template configuration. In the peer configuration it will still only be one inherit statement for the peer-policy, and then the peer-policy template will be the one inheriting the next templates. Session templates are not able to inherit any other templates.
BGP peer templates are the preferred option for grouping BGP configuration for peers. Previously BGP peer groups has been used for this functionality, but the flexibility of templates has made it the top choice. It is not possible to use both peer groups and peer templates in the same neighbor configuration.
BGP peer templates is an advanced feature for grouping policies and applying them to BGP peers. In a small environment the gains of using this feature may be small, but in an evironment with many BGP sessions this feature can save plenty of configuration as well as provide a consistent policy implementation.
Cisco documentation on BGP peer templates
PacketLife on BGP peer templates