BGP Maximum Prefix
BGP Maximum Prefix
Contents
Introduction
Prerequisites
Requirements
Components Used
Conventions
Background Information
Configure
Network Diagram
Configurations
Maximum-Prefix Configured for Warning-Only Message When Threshold Exceeds Threshold Set
Maximum-Prefix Configured to Bring Down Neighbor Relationship When Threshold Exceeds Threshold
Set
Maximum-Prefix Configured to Bring Down the Session When Threshold Exceeds Threshold Set
Related Information
Introduction
This document describes configuration and troubleshooting information on the Border Gateway Protocol
(BGP) Maximum-Prefix feature.
Prerequisites
Requirements
Components Used
The information in this document is not restricted to specific software and hardware versions, but the
outputs were taken from these software versions:
The information in this document was created from the devices in a specific lab environment. All of the
devices used in this document started with a cleared (default) configuration. If your network is live, ensure
that you understand the potential impact of any command.
Conventions
Refer to Cisco Technical Tips Conventions for more information on document conventions.
Background Information
This document provides configuration and troubleshooting information on the Border Gateway Protocol
(BGP) Maximum-Prefix feature.
The BGP Maximum-Prefix feature allows you to control how many prefixes can be received from a
neighbor. By default, this feature allows a router to bring down a peer when the number of received prefixes
from that peer exceeds the configured Maximum-Prefix limit. This feature is commonly used for external
BGP peers, but can be applied to internal BGP peers also.
The Maximum-Prefix feature is useful when, at a change of outbound policy at the remote peering site, a
router starts to receive more routes than the router memory can take. If this same router is peering with BGP
and also performs critical routing functions within a network, this overhead could turn out bad. A BGP
problem could disrupt internal network connectivity. With the neighbor maximum-prefix command, it is
possible to protect a router against this situation.
When you plan to use this feature, consider these key points:
• Know how many routes the remote BGP peering router normally sends.
• Set a threshold a little higher than the number of BGP prefixes expected to be received during normal
operations.
• Know the action to take in case the remote BGP peer sends more prefixes than those expected.
Available actions could either be to bring down the session and to keep the BGP neighbor relationship
down until you use the clear ip bgp x.x.x.x command or, alternatively, to only log a warning
message.
Note: An enhancement to this feature is introduced in Cisco IOS Software Release 12.0(22)S and
12.2(15)T. The enhancement allows the user to automatically reestablish a peering session that has
been brought down because the configured Maximum-Prefix limit is exceeded. No intervention
from the network operator is required when this feature is enabled. For further information, refer to
BGP Restart Session After Maximum-Prefix Limit.
Configure
In this section, you are presented with the information to configure the features described in this document.
The command syntax used in order to configure the BGP Maximum-Prefix feature is:
<#root>
neighbor {ip-address | peer-group-name} maximum-prefix <maximum> [threshold] [restart restart-inte
Where:
• maximum—Represents the maximum number of prefixes allowed from the neighbor.
For example, if the maximum-value configured is 20 and the threshold 60, the router generates
warning messages when the number of BGP learned routes from the neighbor exceeds 60 percent of
20 (12) routes.
restart-interval—An optional Time interval (in minutes) that a peering session is reestablished. The
range is from 1 to 65535 minutes.
warning-only—(optional) Allows the router to generate a log message when the Maximum-Prefix
limit is exceeded, instead of terminating the peering session.
<#root>
neighbor 10.1.1.1 maximum-prefix 3000
Network Diagram
• Maximum-Prefix Configured for Warning-Only Message When Threshold Exceeds Threshold Set
In the Maximum-Prefix warning-only configuration, Router_B is configured to log only a warning message
when the number of prefixes received from Router_A exceeds the threshold set. Configuration of both
routers is as shown in this table. Notice the presence of the warning-only keyword configured with the
neighbor command.
Router_A Router_B
<#root>
hostname Router_B
!
hostname Router_A interface Loopback0
! ip address 10.0.0.2 255.255.255.252
interface Loopback0 !
ip address 10.0.0.1 255.255.255.255 interface Ethernet0
! ip address 10.0.1.1 255.255.255.0
interface Serial0 !
ip address 192.168.1.1 255.255.255.252 interface Serial0
! ip unnumbered Loopback0
interface Serial1 !
ip unnumbered Loopback0 router bgp 300
! no synchronization
router bgp 200 bgp router-id 10.0.0.2
no synchronization bgp log-neighbor-changes
bgp router-id 10.0.0.1 neighbor 10.0.0.1 remote-as 200
bgp log-neighbor-changes neighbor 10.0.0.1 ebgp-multihop 2
neighbor 192.168.1.2 local-as 100 neighbor 10.0.0.1 update-source Loopback0
neighbor 10.0.0.2 remote-as 300 neighbor 10.0.0.1 version 4
neighbor 10.0.0.2 ebgp-multihop 2
neighbor 10.0.0.2 update-source Loopback0
neighbor 10.0.0.1 maximum-prefix 10 80 warning-only
neighbor 10.0.0.2 version 4
no auto-summary
!
!--- Enables warning message logging when the number
ip route 10.0.0.2 255.255.255.252 Serial1
!--- of BGP routes learned from neighbor
!--- 10.0.0.1 exceeds eight.
no auto-summary
!
ip route 10.0.0.1 255.255.255.252 Serial0
The show and debug command outputs in the Verify and Troubleshoot section of this document report what
really happens on Router_B whenever the number of prefixes received from Router_A exceeds the threshold
set.
In the Maximum-Prefix configured to bring down the neighbor relationship configuration, Router_B is
configured to generate warning messages when the number of prefixes received from Router_A exceeds the
threshold set. Router_B is also configured to bring down the BGP neighbor when the maximum prefix limit
is exceeded. Configuration of both routers is as shown in the table. Notice the absence of the warning-only
keyword set with the neighbor command.
Router_A Router_B
<#root>
hostname Router_B
!
interface Loopback0
hostname Router_A ip address 10.0.0.2 255.255.255.252
! !
interface Loopback0 interface Ethernet0
ip address 10.0.0.1 255.255.255.255 ip address 10.0.1.1 255.255.255.0
! !
interface Serial0 interface Serial0
ip address 192.168.1.1 255.255.255.252 ip unnumbered Loopback0
! !
interface Serial1 router bgp 300
ip unnumbered Loopback0 no synchronization
! bgp router-id 10.0.0.2
router bgp 200 bgp log-neighbor-changes
no synchronization neighbor 10.0.0.1 remote-as 200
bgp router-id 10.0.0.1 neighbor 10.0.0.1 ebgp-multihop 2
bgp log-neighbor-changes neighbor 10.0.0.1 update-source Loopback0
neighbor 192.168.1.2 local-as 100 neighbor 10.0.0.1 version 4
neighbor 10.0.0.2 remote-as 300
neighbor 10.0.0.2 ebgp-multihop 2
neighbor 10.0.0.1 maximum-prefix 10 80
neighbor 10.0.0.2 update-source Loopback0
neighbor 10.0.0.2 version 4
no auto-summary !--- This forces the neighbor session to tear down
! !--- when the BGP learned routes from
ip route 10.0.0.2 255.255.255.252 Serial1 !--- the neighbor exceeds 10.
no auto-summary
!
ip route 10.0.0.1 255.255.255.252 Serial0
The show and debug command outputs in the Verify and Troubleshoot section report what really happens
on Router_B whenever the number of prefixes it receives from Router_A exceeds the threshold set.
Verify and Troubleshoot
This section provides information you can use to confirm your configuration is working properly.
The command syntax and defaults of the feature used in this document are available at the BGP Command
page.
Note: Refer to Understand Important Information on Debug Commands before you use debug
commands.
Maximum-Prefix Warning-Only
As long as the number of received prefixes does not get higher than the threshold set, eight, no messages are
logged. As soon as the number of BGP routes learned from neighbor 10.0.0.1 exceeds the threshold limit of
eight, Router_B logs this message. This situation is simulated when nine prefixes are sent:
If the situation gets worse, and exceeds the Maximum-Prefix number set of 10, then the router logs this
message. This situation is simulated when 12 prefixes are sent:
%BGP-3-MAXPFXEXCEED: No. of prefix received from 10.0.0.1 (afi 0): 11 exceed limit 10
When you activate debug ip bgp updates in , you are able to get a closer look at what happens. However,
do not use this command in a live environment with several thousands of prefixes. The situation depicted is
that Router_B already has an established peering. Six prefixes have been advertised to Router B by
Router_A. Now three additional prefixes are advertised by the peer Router_A.
<#root>
Router_B#
*Mar 12 07:31:18.944: BGP(0): 10.0.0.1 rcvd UPDATE w/ attr: nexthop 10.0.0.1, origin i, metric 0,
*Mar 12 07:31:18.948: BGP(0): 10.0.0.1 rcvd 10.0.1.0/24...duplicate ignored
*Mar 12 07:31:18.952: BGP(0): 10.0.0.1 rcvd 10.0.2.0/24...duplicate ignored
*Mar 12 07:31:18.960: BGP(0): 10.0.0.1 rcvd 10.0.3.0/24...duplicate ignored
*Mar 12 07:32:20.224: BGP(0): 10.0.0.1 rcvd 10.0.4.0/24...duplicate ignored
*Mar 12 07:32:20.228: BGP(0): 10.0.0.1 rcvd 10.0.5.0/24...duplicate ignored
*Mar 12 07:32:20.232: BGP(0): 10.0.0.1 rcvd 10.0.6.0/24...duplicate ignored
*Mar 12 07:34:19.768: BGP(0): 10.0.0.1 rcvd 10.0.7.0/24
*Mar 12 07:34:19.772: BGP(0): 10.0.0.1 rcvd 10.0.8.0/24
*Mar 12 07:34:19.780: BGP(0): 10.0.0.1 rcvd 10.0.9.0/24
*Mar 12 07:34:19.780:
*Mar 12 07:34:19.792: BGP(0): Revise route installing 1 of 1 route for 10.0.7.0/24 -> 10.0.0.1 to
*Mar 12 07:34:19.796: BGP(0): Revise route installing 1 of 1 route for 10.0.8.0/24 -> 10.0.0.1 to
*Mar 12 07:34:19.804: BGP(0): Revise route installing 1 of 1 route for 10.0.9.0/24 -> 10.0.0.1 to
<#root>
Router_B#
9 accepted prefixes
SRTT: 279 ms, RTTO: 500 ms, RTV: 221 ms, KRTT: 0 ms
minRTT: 24 ms, maxRTT: 384 ms, ACK hold: 200 ms
Flags: higher precedence, nagle
Datagrams (max data segment is 536 bytes):
Rcvd: 33 (out of order: 0), with data: 22, total data bytes: 751
Sent: 29 (retransmit: 0, fastretransmit: 0), with data: 17, total data bytes: 349
<#root>
Router_B#
Suppose that the situation gets worse and that Router_A sends three additional prefixes, which increases the
total number up to 12.
<#root>
Router_B#
*Mar 12 07:39:21.192: BGP(0): 10.0.0.1 rcvd UPDATE w/ attr: nexthop 10.0.0.1, origin i, metric 0,
*Mar 12 07:39:21.196: BGP(0): 10.0.0.1 rcvd 10.0.10.0/24
*Mar 12 07:39:21.200: %BGP-4-MAXPFX: No. of prefix received from 10.0.0.1 (afi 0) reaches 10, max
*Mar 12 07:39:21.208: BGP(0): 10.0.0.1 rcvd 10.0.11.0/24
*Mar 12 07:39:21.212:
%BGP-3-MAXPFXEXCEED: No. of prefix received from 10.0.0.1 (afi 0): 11 exceed limit 10
<#root>
Router_B#
12 accepted prefixes
12
As you can see from the example shown, the BGP neighbor relationship is maintained even if the
neighboring router sends more prefixes than the policy allows. The result is that only a warning message
gets logged by Router_B. No other actions are taken by Router_B.
Initial conditions required for this case are to have the BGP neighbor up and running and with six prefixes
sent by Router_A to Router_B. As seen in the example, when Router_A advertises more prefixes (for
example, 9), the output of the commands reflects exactly what was already seen for the case where
Router_B is configured to just log a warning message. If you push up the number of prefixes sent and make
Router_A advertise 12, Router_B closes the neighbor relationship with Router_A.
<#root>
Router_B#
*Mar 12 08:03:27.864: BGP(0): 10.0.0.1 rcvd UPDATE w/ attr: nexthop 10.0.0.1, origin i, metric 0,
*Mar 12 08:03:27.868: BGP(0): 10.0.0.1 rcvd 10.0.1.0/24...duplicate ignored
*Mar 12 08:03:27.876: BGP(0): 10.0.0.1 rcvd 10.0.2.0/24...duplicate ignored
*Mar 12 08:03:27.880: BGP(0): 10.0.0.1 rcvd 10.0.3.0/24...duplicate ignored
*Mar 12 08:03:27.884: BGP(0): 10.0.0.1 rcvd 10.0.4.0/24...duplicate ignored
*Mar 12 08:03:27.892: BGP(0): 10.0.0.1 rcvd 10.0.5.0/24...duplicate ignored
*Mar 12 08:03:27.896: BGP(0): 10.0.0.1 rcvd 10.0.6.0/24...duplicate ignored
*Mar 12 08:03:27.900: BGP(0): 10.0.0.1 rcvd 10.0.7.0/24
*Mar 12 08:03:27.908: BGP(0): 10.0.0.1 rcvd 10.0.8.0/24
*Mar 12 08:03:27.912: BGP(0): 10.0.0.1 rcvd 10.0.9.0/24
*Mar 12 08:03:27.916:
%BGP-3-MAXPFXEXCEED: No. of prefix received from 10.0.0.1 (afi 0): 11 exceed limit 10
*Mar 12 08:03:27.940:
*Mar 12 08:03:27.940:
%BGP-3-NOTIFICATION:
update
malformed
) 0 bytes FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 0060 0200 0000 1940
0101 0040 0204 0201 00C8 4003 040A 0000 0180 0404 0000 0000 180A 0001 180A 0002
180A 0003 180A 0004 180A 0005 180A 0006 180A 0007 180A 0008 180A 0009 180A 000A
180A 000B 180A 000C
*Mar 12 08:03:28.024: BGP(0): Revise route installing 1 of 1 route for 10.0.7.0/24 -> 10.0.0.1 to
*Mar 12 08:03:28.032: BGP(0): Revise route installing 1 of 1 route for 10.0.8.0/24 -> 10.0.0.1 to
*Mar 12 08:03:28.036: BGP(0): Revise route installing 1 of 1 route for 10.0.9.0/24 -> 10.0.0.1 to
*Mar 12 08:03:28.044: BGP(0): Revise route installing 1 of 1 route for 10.0.10.0/24 -> 10.0.0.1 to
*Mar 12 08:03:28.148: BGP(0): no valid path for 10.0.1.0/24
*Mar 12 08:03:28.152: BGP(0): no valid path for 10.0.2.0/24
*Mar 12 08:03:28.156: BGP(0): no valid path for 10.0.3.0/24
*Mar 12 08:03:28.156: BGP(0): no valid path for 10.0.4.0/24
*Mar 12 08:03:28.160: BGP(0): no valid path for 10.0.5.0/24
*Mar 12 08:03:28.164: BGP(0): no valid path for 10.0.6.0/24
*Mar 12 08:03:28.168: BGP(0): no valid path for 10.0.7.0/24
*Mar 12 08:03:28.168: BGP(0): no valid path for 10.0.8.0/24
*Mar 12 08:03:28.172: BGP(0): no valid path for 10.0.9.0/24
*Mar 12 08:03:28.176: BGP(0): no valid path for 10.0.10.0/24
*Mar 12 08:03:28.184: BGP(0): nettable_walker 10.0.1.0/24 no best path
*Mar 12 08:03:28.188: BGP(0): nettable_walker 10.0.2.0/24 no best path
*Mar 12 08:03:28.192: BGP(0): nettable_walker 10.0.3.0/24 no best path
*Mar 12 08:03:28.196: BGP(0): nettable_walker 10.0.4.0/24 no best path
*Mar 12 08:03:28.200: BGP(0): nettable_walker 10.0.5.0/24 no best path
*Mar 12 08:03:28.204: BGP(0): nettable_walker 10.0.6.0/24 no best path
*Mar 12 08:03:28.208: BGP(0): nettable_walker 10.0.7.0/24 no best path
*Mar 12 08:03:28.212: BGP(0): nettable_walker 10.0.8.0/24 no best path
*Mar 12 08:03:28.212: BGP(0): nettable_walker 10.0.9.0/24 no best path
*Mar 12 08:03:28.216: BGP(0): nettable_walker 10.0.10.0/24 no best path
<#root>
Router_B#
Idle (PfxCt)
<#root>
Router_B#
Idle
Connections established 2;
dropped 2
Last reset 00:02:43, due to BGP Notification sent, update malformed
<#root>
Router_B#
Related Information
• BGP Restart Session After Maximum-Prefix Limit
• Troubleshooting BGP
• BGP Case Studies
• Cisco Technical Support & Downloads