A BGP policy attach point is a specific location in BGP configuration where you can attach a routing policy that
-
applies the policy to routes processed at that BGP processing stage, and
-
controls how BGP evaluates or modifies routes by using BGP attributes and operators relevant to that attach point.
BGP policy attach points by function
Use these BGP policy attach points to control how BGP selects, advertises, imports, and manages routes:
-
Path selection and advertisement
-
additional-path
-
default originate
-
neighbor export
-
neighbor import
-
Route injection
-
Display, accounting, and operations
-
show bgp
-
table policy
-
clear-policy
-
debug
-
VPN route movement and retention
-
import
-
export
-
retain route-target
-
Label and ORF controls
-
allocate-label
-
label-mode
-
neighbor-orf
-
Next-hop event control: next-hop
-
Stability control: dampening
additional-path
The additional-path attach point controls whether BGP selects additional paths so a BGP speaker can send multiple paths for the same prefix.
Example:
router bgp 100
address-family ipv4 unicast
additional-paths selection route-policy add-path-policy
This table summarizes the BGP attributes and operators available for the additional-path attach point.
Table 1.
Attributes and operators for additional-path
| Attach Point |
Attribute |
Match |
Set |
| aggregation |
as-path |
in is-local length neighbor-is originates-from passes-through unique-length |
— |
| as-path-length |
is, ge, le, eq |
— |
| as-path-unique-length |
is, ge, le, eq |
— |
| community |
is-empty matches-any matches-every |
set set additive delete in delete not in delete all |
| destination |
in |
— |
| extcommunity cost |
— |
set set additive |
| local-preference |
is, ge, le, eq |
set |
| med |
is, eg, ge, le |
setset +set - |
| next-hop |
in |
set |
| origin |
is |
set |
| source |
in |
— |
| suppress-route |
— |
suppress-route |
| weight |
— |
set |
dampening
The dampening attach point controls BGP route-dampening behavior by using a policy to set dampening attributes for routes.
Policy behavior:
-
The last set dampening statement encountered takes effect.
-
If the policy executes drop , the route does not contribute to dampening.
-
If the policy executes pass or done without set dampening , the default dampening parameters apply.
-
If an applied policy executes pass , execution returns to the calling policy.
-
If an applied policy executes done , policy execution stops and accepts the route.
Example:
route-policy sample_damp
if destination in (0.0.0.0/0 ge 25) then
set dampening halflife 30 others default
else
set dampening halflife 20 others default
endif
end-policy
router bgp 2
address-family ipv4 unicast
bgp dampening route-policy sample_damp
...
This table summarizes the BGP attributes and operators available for the dampening attach point.
Table 2.
Attributes and operators for dampening
| Attach Point |
Attribute |
Match |
Set |
| dampening |
as-path |
in is-local length neighbor-is originates-from passes-through unique-length |
— |
| as-path-length |
is, ge, le, eq |
— |
| as-path-unique-length |
is, ge, le, eq |
— |
| community |
is-empty matches-any matches-every |
— |
| dampening |
— |
set dampening |
| destination |
in |
— |
| local-preference |
is, ge, le, eq |
— |
| med |
is, eg, ge, le |
— |
| next-hop |
in |
— |
| origin |
is |
— |
| source |
in |
— |
default originate
The default originate attach point conditionally generates and advertises the default route 0.0.0.0/0 to a peer based on whether routes in the RIB pass the attached policy.
Example:
route-policy sample-originate
if rib-has-route in (10.0.0.0/8 ge 8 le 32) then
pass
endif
end-policy
router bgp 2
neighbor 10.0.0.1
remote-as 3
address-family ipv4 unicast
default-originate policy sample-originate
...
This table summarizes the BGP attributes and operators available for the default originate attach point.
Table 3.
Attributes and operators for default originate
| Attach Point |
Attribute |
Match |
Set |
| default originate |
med |
— |
set set + set - |
| rib-has-route |
in |
— |
neighbor export
The neighbor export attach point selects which BGP routes BGP sends to a peer or peer group by running candidate routes through the attached policy. Routes that pass are sent, and the policy can modify route attributes before BGP sends the update.
Example:
route-policy sample-export
if community matches-any (2:[100-200]) then
set med 100
set community (2:666)
else
set med 200
set community (2:200)
endif
end-policy
router bgp 2
neighbor 10.0.0.5
remote-as 3
address-family ipv4 unicast
route-policy sample-export out
...
This table summarizes the BGP attributes and operators available for the neighbor export attach point.
Table 4.
Attributes and operators for neighbor export
| Attach Point |
Attribute |
Match |
Set |
| neighbor-out |
as-path |
in is-local length — neighbor-is originates-from passes-through unique-length |
prepend prepend most-recent remove as-path private-as replace |
| as-path-length |
is, ge, le, eq |
— |
| as-path-unique-length |
is, ge, le, eq |
— |
| communitycommunity with ‘peeras’ |
is-empty matches-any matches-every |
set set additive delete-in delete-not-in delete-all |
| destination |
in |
— |
| extcommunity cost |
— |
set set additive |
| extcommunity rt |
is-empty matches-any matches-every matches-within |
set additive delete-in delete-not-in delete-all |
| extcommunity soo |
is-empty matches-any matches-every matches-within |
— |
| local-preference |
is, ge, le, eq |
set |
| med |
is, eg, ge, le |
set set + set - set max-unreachable set igp-cost |
| next-hop |
in |
set set self |
| origin |
is |
set |
| path-type |
is |
— |
| rd |
in |
— |
| route-aggregated |
route-aggregated |
— |
| source |
in |
— |
| unsuppress-route |
— |
unsuppress-route |
| vpn-distinguisher |
— |
set |
neighbor import
The neighbor import attach point controls which routes BGP accepts from a peer by running received routes through the attached policy. Routes that pass become candidates in the BGP RIB.
When you change an import policy, BGP must re-evaluate routes from that peer against the new policy. The bgp auto-policy-soft-reset option can automate this when soft reconfiguration is enabled or route refresh is negotiated.
Example:
route-policy sample_import
if community matches-any (3:100) then
set local-preference 100
set community (2:666)
else
set local-preference 200
set community (2:200)
endif
end-policy
router bgp 2
neighbor 10.0.0.1
remote-as 3
address-family ipv4 unicast
route-policy sample_import in
This table summarizes the BGP attributes and operators available for the neighbor import attach point.
Table 5.
Attributes and operators for neighbor import
| Attach Point |
Attribute |
Match |
Set |
| neighbor-in |
as-path |
in is-local length NA neighbor-is originates-from passes-through unique-length |
prepend prepend most-recent remove as-path private-as replace |
| as-path-length |
is, ge, le, eq |
— |
| as-path-unique-length |
is, ge, le, eq |
— |
| communitycommunity with ‘peeras’ |
is-empty matches-any matches-every |
set set additive delete-in delete-not-in delete-all |
| destination |
in |
— |
| extcommunity cost |
— |
set set additive |
| extcommunity rt |
is-empty matches-any matches-every matches-within |
set additive delete-in delete-not-in delete-all |
| extcommunity soo |
is-empty matches-any matches-every matches-within |
— |
| local-preference |
is, ge, le, eq |
set |
| med |
is, eg, ge, le |
set set + set - |
| next-hop |
in |
set set peer address |
| origin |
is |
set |
| route-aggregated |
route-aggregated |
NA |
| source |
in |
— |
| weight |
— |
set |
network
The network attach point controls how BGP injects routes from the RIB into BGP. A policy at this attach point can set valid BGP attributes on injected routes.
Example:
route-policy NetworkControl
if destination in (0.0.0.0/0 ge 25) then
set community (no-export) additive
endif
end-policy
router bgp 2
address-family ipv4 unicast
network 172.16.0.5/27 route-policy NetworkControl
This table summarizes the BGP attributes and operators available for the network attach point.
Table 6.
Attributes and operators for network
| Attach Point |
Attribute |
Match |
Set |
| network |
as-path |
— |
prepend |
| community |
— |
set set additive delete-in delete-not-in delete-all |
| destination |
in |
— |
| extcommunity cost |
— |
set set additive |
| mpls-label |
route-has-label |
— |
| local-preference |
— |
set |
| med |
— |
set set+ set- |
| next-hop |
in |
set |
| origin |
— |
set |
| route-type |
is |
— |
| tag |
is, ge, le, eq |
— |
| weight |
— |
set |
redistribute
The redistribute attach point injects routes from other routing protocols into OSPF by selecting routes and setting OSPF parameters such as cost and metric type.
Example:
route-policy OSPF-redist
set metric-type type-2
if tag eq 10 then
set ospf cost 100
elseif tag eq 20 then
set ospf cost 200
else
drop
endif
end-policy
router ospf 1
redistribute isis instance_10 policy OSPF-redist
This table summarizes the BGP attributes and operators available for the redistribute attach point.
Table 7.
Attributes and operators for redistribute
| Attach Point |
Attribute |
Match |
Set |
| redistribute |
as-path |
— |
prepend |
| community |
— |
set set additive delete in delete not in delete all |
| destination |
in |
— |
| extcommunity cost |
— |
setset additive |
| local-preference |
— |
set |
| med |
— |
set set+ set- |
| next-hop |
in |
set |
| origin |
— |
set |
| mpls-label |
route-has-label |
— |
| route-type |
is |
— |
| tag |
is, eq, ge, le |
— |
| weight |
— |
set |
show bgp
The show bgp attach point displays BGP routes that are not dropped by the attached policy.
Example:
route-policy sample-display
if med eq 5 then
pass
endif
end-policy
show bgp route-policy sample-display
This table summarizes the BGP attributes and operators available for the show bgp attach point.
Table 8.
Attributes and operators for show bgp
| Attach Point |
Attribute |
Match |
Set |
| show bgp |
as-path |
in is-local length neighbor-is originates-from passes-through unique-length |
— |
| as-path-length |
is, ge, le, eq |
— |
| as-path-unique-length |
is, ge, le, eq |
— |
| community |
is-empty matches-any matches-every |
— |
| destination |
in |
— |
| extcommunity rt |
is-empty matches-any matches-every matches-within |
— |
| extcommunity soo |
is-empty matches-any matches-every matches-within |
— |
| med |
is, eg, ge, le |
— |
| next-hop |
in |
— |
| origin |
is |
— |
| source |
in |
— |
table policy
The table policy attach point sets traffic-index values on routes as the system installs routes into the global routing table. This supports BGP policy accounting by classifying routes and tracking traffic counters per class.
Example:
route-policy sample-table
if as-path originates-from '10.33' then
set traffic-index 10
elseif as-path originates-from '11.60' then
set traffic-index 11
endif
end-policy
router bgp 2
address-family ipv4 unicast
table-policy sample-table
import
The import attach point controls import of routes from the global VPN IPv4 table into a VRF.
Example:
route-policy bgpvrf_import
if extcommunity rt matches-any (10:91) then
set next-hop 172.16.0.1
elseif extcommunity rt matches-every (11:92) then
set next-hop 172.16.0.2
elseif extcommunity soo matches-any (10:111111, 10:111222) then
pass
endif
end-policy
vrf vrf_import
address-family ipv4 unicast
import route-policy bgpvrf_import
export
The export attach point controls export of routes from a VRF to the global VPN IPv4 table, including conditional route-target handling.
Example:
route-policy bgpvrf_export
if destination in (172.16.1.0/24) then
set extcommunity rt (10:101)
set weight 211
elseif origin is egp then
set local-preference 212
set extcommunity rt (10:101)
endif
set extcommunity rt (10:111222) additive
end-policy
vrf vrf-export
address-family ipv4 unicast
export route-policy bgpvrf-export
retain route-target
The retain route-target attach point retains VPN routes based only on route target extended communities. This can reduce the route scale at a route reflector or support IPv4 VPN route retention at an autonomous system boundary router (ASBR).
Example:
extcommunity-set rt rtset1
0:615,
10:6150,
192.0.2.15:15
end-set
route-policy retainer
if extcommunity rt matches-any rtset1 then
pass
endif
end-policy
router bgp 2
address-family vpnv4 unicast
retain route-target route-policy retainer
This table summarizes the BGP attributes and operators available for the retain route-target attach point.
Table 9.
Attributes and operators for retain route-target
| Attach Point |
Attribute |
Match |
Set |
| retain-rt |
extcommunity rt |
is-empty matches-any matches-every matches-within |
— |
allocate-label
The allocate-label attach point decides whether BGP allocates a label when it sends updates for the IPv4 labeled-unicast address family. This attach point typically uses AS path match criteria and supports pass and drop.
This table summarizes the BGP attributes and operators available for the allocate-label attach point.
Table 10.
Attributes and operators for allocate-label
| Attribute |
Match |
Set |
| as-path |
in is-local length neighbor-is originates-from passes-through unique-length |
— |
| as-path-length |
is, ge, le, eq |
— |
| as-path-unique-length |
is, ge, le, eq |
— |
| community |
is-empty matches-any matches-every |
— |
| destination |
in |
— |
| label |
— |
set |
| local-preference |
is, ge, le, eq |
— |
| med |
is, eg, ge, le |
— |
| next-hop |
in |
— |
| origin |
is |
— |
| source |
in |
— |
label-mode
The label-mode attach point selects a label mode based on match criteria such as prefix or community. This attach point is commonly used to choose per-CE, per-VRF, or per-prefix label modes and supports pass and drop.
neighbor-orf
The neighbor-orf attach point filters inbound BGP route updates by using prefix-based matching and sends the same prefix filters to upstream neighbors as outbound route filter (ORF) entries.
Example:
prefix-set orf-preset
172.16.1.0/24,
172.16.5.0/24,
172.16.11.0/24
end-set
route-policy policy-orf
if orf prefix in orf-preset then
drop
endif
if orf prefix in (172.16.3.0/24, 172.16.7.0/24, 172.16.13.0/24) then
pass
endif
router bgp 2
neighbor 1.1.1.1
remote-as 3
address-family ipv4 unicast
orf route-policy policy-orf
This table summarizes the BGP attributes and operators available for the neighbor-orf attach point.
Table 11.
Attributes and operators for neighbor-orf
| Attach Point |
Attribute |
Match |
Set |
| neighbor-orf |
orf-prefix |
in |
Not applicable |
next-hop
The next-hop attach point controls which RIB next-hop up or down notifications BGP processes by matching prefixes and protocols. This attach point is commonly used with next-hop tracking to monitor non-BGP routes.
Example:
route-policy nxthp_policy_A
if destination in (10.0.0.0/8) and protocol in (static, connected) then
pass
endif
end-policy
router bgp 2
address-family ipv4 unicast
nexthop route-policy nxthp_policy_A
This table summarizes the BGP attributes and operators available for the next-hop attach point.
Table 12.
Attributes and operators for next-hop
| Attach Point |
Attribute |
Match |
Set |
| next-hop |
destination |
in |
— |
| protocol |
is,in |
— |
| source |
in |
— |
clear-policy
The clear-policy attach point controls whether clear bgp operations clear flap statistics based on AS path match criteria.
Example:
as-path-set my-as-set
ios-regex '_12$',
ios-regex '_13$'
end-set
route-policy policy_a
if as-path in my-as-set then
pass
else
drop
endif
end-policy
clear bgp ipv4 unicast flap-statistics route-policy policy_a
This table summarizes the BGP attributes and operators available for the clear-policy attach point.
Table 13.
Attributes and operators for clear-policy
| Attach Point |
Attribute |
Match |
Set |
| clear-policy |
as-path |
in is-local length neighbor-is originates-from passes-through unique-length |
— |
| as-path-length |
is, ge, le, eq |
— |
| as-path-unique-length |
is, ge, le, eq |
— |
debug
The debug attach point filters BGP debug output by matching route prefixes.
Example:
route-policy policy_b
if destination in (10.0.0.0/8) then
pass
else
drop
endif
end-policy
debug bgp update policy_b
This table summarizes the BGP attributes and operators available for the debug attach point.
Table 14.
Attributes and operators for debug
| Attach Point |
Attribute |
Match |
Set |
| debug |
destination |
in |
— |