When you configure BGP on a router it’s possible that some of the BGP neighbors share the exact same configuration. This can be annoying since you have to type in the exact same commands for each of these neighbors. Also, when BGP prepares updates it does this separately for each neighbor. This means that it has to use CPU resources to prepare the update for each neighbor.
To simplify the configuration of BGP and to reduce the number of updates BGP has to create, we can use peer groups. We can add neighbors to a peer group and then apply all our configurations to the peer group. BGP will prepare the updates for the peer group which requires less CPU resources than preparing them for each neighbor separately.
Configuration
Let’s take a look at two examples so you can see the difference between using peer groups or not. I’ll use the following topology to demonstrate this:
Above we have 4 routers in different autonomous systems. R1 is connected to R2, R3 and R4. Let’s say that we have the following requirements for these eBGP neighbors:
- Use eBGP multihop and source updates from the loopback interface.
- Set the default metric (MED) to 2323.
Let’s start with the example without the peer group…
I am using loopback interfaces for the neighbor adjacency so don’t forget to add some static routes:
R1(config)#ip route 2.2.2.2 255.255.255.255 192.168.12.2
R1(config)#ip route 3.3.3.3 255.255.255.255 192.168.13.3
R1(config)#ip route 4.4.4.4 255.255.255.255 192.168.14.4
R2(config)#ip route 1.1.1.1 255.255.255.255 192.168.12.1
R3(config)#ip route 1.1.1.1 255.255.255.255 192.168.13.1
R4(config)#ip route 1.1.1.1 255.255.255.255 192.168.14.1
And here s the route-map to set the MED:
R1(config)#route-map SET_MED permit 10
R1(config-route-map)#set metric 2323
Without BGP Peer Group
Here’s what our BGP configuration on R1 would look like:
R1(config)#router bgp 1
R1(config-router)#neighbor 2.2.2.2 remote-as 2
R1(config-router)#neighbor 3.3.3.3 remote-as 3
R1(config-router)#neighbor 4.4.4.4 remote-as 4
R1(config-router)#neighbor 2.2.2.2 update-source loopback 0
R1(config-router)#neighbor 3.3.3.3 update-source loopback 0
R1(config-router)#neighbor 4.4.4.4 update-source loopback 0
R1(config-router)#neighbor 2.2.2.2 ebgp-multihop 2
R1(config-router)#neighbor 3.3.3.3 ebgp-multihop 2
R1(config-router)#neighbor 4.4.4.4 ebgp-multihop 2
R1(config-router)#neighbor 2.2.2.2 route-map SET_MED out
R1(config-router)#neighbor 3.3.3.3 route-map SET_MED out
R1(config-router)#neighbor 4.4.4.4 route-map SET_MED out
In the configuration of R1 above the only difference is the AS number for each neighbor. The update-source, ebgp-multihop and route-map are the same. This works but we have to repeat the same commands over and over again.
With BGP Peer Group
Let’s simplify the configuration of R1 with our peer group. I will start with a fresh BGP configuration on R1.
First we have to configure the AS number for each eBGP neighbor separately:
R1(config)#router bgp 1
R1(config-router)#neighbor 2.2.2.2 remote-as 2
R1(config-router)#neighbor 3.3.3.3 remote-as 3
R1(config-router)#neighbor 4.4.4.4 remote-as 4
Now we can create the peer group. If you look at the neighbor command you will see some options:
R1(config-router)#neighbor ?
A.B.C.D Neighbor address
WORD Neighbor tag
X:X:X:X::X Neighbor IPv6 address
We can specify an IPv4 or IPv6 address for the neighbor or we can use a tag. That’s what we need to use for the peer group, let’s try that:
R1(config-router)#neighbor R2_R3_R4 peer-group
I’ll call my peer group R2_R3_R4. The next step is to add my neighbors to this peer group:
R1(config-router)#neighbor 2.2.2.2 peer-group R2_R3_R4
R1(config-router)#neighbor 3.3.3.3 peer-group R2_R3_R4
R1(config-router)#neighbor 4.4.4.4 peer-group R2_R3_R4
That’s all you have to configure. Everything else you want to configure can be applied to the peer group instead of applying it to the neighbor directly:
R1(config-router)#neighbor R2_R3_R4 update-source loopback 0
R1(config-router)#neighbor R2_R3_R4 ebgp-multihop 2
R1(config-router)#neighbor R2_R3_R4 route-map SET_MED out
That’s all there is to it. These three commands are now applied to R2, R3 and R4 thanks to our peer group. This saves us some typing and copy/pasting and the router will require less CPU cycles for its BGP updates.
hostname R1
!
interface Loopback 0
ip address 1.1.1.1 255.255.255.255
!
interface fastEthernet0/0
ip address 192.168.12.1 255.255.255.0
!
interface fastEthernet0/1
ip address 192.168.13.1 255.255.255.0
!
interface fastEthernet1/0
ip address 192.168.14.1 255.255.255.0
!
router bgp 1
neighbor 2.2.2.2 remote-as 2
neighbor 3.3.3.3 remote-as 3
neighbor 4.4.4.4 remote-as 4
neighbor R2_R3_R4 peer-group
neighbor 2.2.2.2 peer-group R2_R3_R4
neighbor 3.3.3.3 peer-group R2_R3_R4
neighbor 4.4.4.4 peer-group R2_R3_R4
neighbor R2_R3_R4 update-source loopback 0
neighbor R2_R3_R4 ebgp-multihop 2
neighbor R2_R3_R4 route-map SET_MED out
!
route-map SET_MED permit 10
set metric 2323
end
hostname R2
!
interface Loopback 0
ip address 2.2.2.2 255.255.255.255
!
interface fastEthernet0/0
ip address 192.168.12.2 255.255.255.0
!
router bgp 2
neighbor 1.1.1.1 remote-as 1
neighbor 1.1.1.1 update-source loopback 0
neighbor 1.1.1.1 ebgp-multihop 2
!
end
hostname R3
!
interface Loopback 0
ip address 3.3.3.3 255.255.255.255
!
interface fastEthernet0/0
ip address 192.168.13.3 255.255.255.0
!
router bgp 3
neighbor 1.1.1.1 remote-as 1
neighbor 1.1.1.1 update-source loopback 0
neighbor 1.1.1.1 ebgp-multihop 2
!
end
hostname R4
!
interface Loopback 0
ip address 4.4.4.4 255.255.255.255
!
interface fastEthernet0/0
ip address 192.168.14.4 255.255.255.0
!
router bgp 4
neighbor 1.1.1.1 remote-as 1
neighbor 1.1.1.1 update-source loopback 0
neighbor 1.1.1.1 ebgp-multihop 2
!
end
If you have any questions, feel free to leave a comment!
No comments:
Post a Comment