Skip to main content
Calico Open Source 3.32 (latest) documentation

BGP Filter

A BGP filter resource (BGPFilter) represents a way to control routes imported by and exported to BGP peers specified using a BGP peer resource (BGPPeer).

The BGPFilter rules are applied sequentially: the action for the first rule that matches is executed immediately. If an address does not match any explicit BGP filter rule, the default action is Accept.

In order for a BGPFilter to be used in a BGP peering, its name must be added to filters of the corresponding BGPPeer resource.

For kubectl commands, the following case-sensitive aliases may be used to specify the resource type on the CLI: bgpfilters.projectcalico.org

Sample YAML

apiVersion: projectcalico.org/v3
kind: BGPFilter
metadata:
name: my-filter
spec:
exportV4:
- action: Accept
matchOperator: In
cidr: 77.0.0.0/16
source: RemotePeers
- action: Reject
interface: '*.calico'
importV4:
- action: Accept
matchOperator: In
cidr: 55.0.0.0/16
prefixLength:
min: 30
- action: Reject
matchOperator: NotIn
cidr: 44.0.0.0/16
exportV6:
- action: Reject
source: RemotePeers
- action: Reject
interface: '*.calico'
importV6:
- action: Accept
matchOperator: Equal
cidr: 5000::0/64
- action: Reject

BGP filter definition

Metadata

FieldDescriptionAccepted ValuesSchema
nameUnique name to describe this resource instance. Must be specified.Alphanumeric string with optional ., _, or -.string

Spec

FieldDescriptionAccepted ValuesSchemaDefault
exportV4List of v4 CIDRs and export actionBGP Filter Rule v4
importV4List of v4 CIDRs and import actionBGP Filter Rule v4
exportV6List of v6 CIDRs and export actionBGP Filter Rule v6
importV6List of v6 CIDRs and import actionBGP Filter Rule v6

BGP Filter Rule v4

FieldDescriptionAccepted ValuesSchemaDefault
cidrIPv4 rangeA valid IPv4 CIDRstring
prefixLengthPrefixLengthValid integers between 0 and ipv4/6 max (32, 128)
matchOperatorMethod by which to match candidate routesIn, NotIn, Equal, NotEqualstring
sourceIndicator of the source of routeRemotePeers means any route learned from other BGP peersstring
interfaceString to match interface namesA valid pattern to match interfaces. "*" can be used as a wildcard.string
peerTypeOnly apply this rule to routes from/to the specified BGP peer type. If empty, the rule applies to all peers.eBGP, iBGPstring
priorityOnly apply this rule to routes with the given priority (metric). Uses the same units as the ...RoutePriority fields in FelixConfiguration.1-2147483646integer
communitiesOnly apply this rule to routes carrying the specified BGP community.See BGP Filter Community Match.object
actionAction to be taken for this ruleAccept or Rejectstring
operationsOrdered list of route modifications to apply when the rule matches. Only valid when action is Accept. Maximum 10 operations.See BGP Filter Operation.list

BGP Filter Rule v6

FieldDescriptionAccepted ValuesSchemaDefault
cidrIPv6 rangeA valid IPv6 CIDRstring
prefixLengthPrefixLengthValid integers between 0 and ipv4/6 max (32, 128)
matchOperatorMethod by which to match candidate routesIn, NotIn, Equal, NotEqualstring
sourceIndicator of the source of routeRemotePeers means any route learned from other BGP peersstring
interfaceString to match interface namesA valid pattern to match interfaces. "*" can be used as a wildcard.string
peerTypeOnly apply this rule to routes from/to the specified BGP peer type. If empty, the rule applies to all peers.eBGP, iBGPstring
priorityOnly apply this rule to routes with the given priority (metric). Uses the same units as the ...RoutePriority fields in FelixConfiguration.1-2147483646integer
communitiesOnly apply this rule to routes carrying the specified BGP community.See BGP Filter Community Match.object
actionAction to be taken for this ruleAccept or Rejectstring
operationsOrdered list of route modifications to apply when the rule matches. Only valid when action is Accept. Maximum 10 operations.See BGP Filter Operation.list

BGP Filter Prefix Length

FieldDescriptionAccepted ValuesSchemaDefault
minSmallest matched mask size (0 by default)Valid integers between 0 and ipv4/6 max (32, 128)int
maxLargest matched mask size (32/128 by default)Valid integers between 1 and ipv4/6 max (32, 128)int

BGP Filter Community Match

FieldDescriptionAccepted ValuesSchema
valuesList of BGP community values to match against. The route must carry at least one of these communities.Standard (aa:nn) or large (aa:nn:mm) community values.list of string

BGP Filter Operation

Each operation is an object with exactly one of the following fields set:

FieldDescriptionSchema
addCommunityAdds a BGP community to the route.AddCommunity
prependASPathPrepends AS numbers to the route's AS path.PrependASPath
setPrioritySets the route's priority (metric).SetPriority

BGP Filter Add Community

FieldDescriptionAccepted ValuesSchema
valueBGP community value to add.Standard (aa:nn) or large (aa:nn:mm) community value.string

BGP Filter Prepend AS Path

FieldDescriptionAccepted ValuesSchema
prefixSequence of AS numbers to prepend to the route's AS path. The resulting path starts with these AS numbers in the order listed (e.g., [65000, 65001] produces 65000 65001 <original>).A list of 1-10 valid AS numbers.list of integer

BGP Filter Set Priority

FieldDescriptionAccepted ValuesSchema
valueThe priority (metric) value to set on the route. Uses the same units as FelixConfiguration RoutePriority fields.1-2147483646integer