Create a community named dunedin and apply it in a routing policy statement:
- [edit]
- policy-options {
- community dunedin members [ 56:2379 23:46944 ];
-
- policy-statement from-dunedin {
- from community dunedin;
-
- then {
- metric 2;
- preference 100;
- next policy;
- }
- }
- }
The preceding example modifies the metric and preference for routes that contain members of community dunedin only.
![]() |
Note: You cannot set or add a community in a policy whose members use regular expressions or a wildcard. |
Delete a particular community from a route, leaving remaining communities untouched:
- [edit]
- policy-options {
- community dunedin members 701:555;
-
- policy-statement delete-dunedin {
-
- then {
- community delete dunedin;
- }
- }
- }
Remove any community from a route with the AS number of 65534 or 65535:
- [edit]
- policy-options {
- community my-as1-transit members [ 65535:10 65535:11 ];
- community my-as2-transit members [ 65534:10 65534:11 ];
- community my-wild members [ 65534:* 65535:* ];
-
- policy-statement delete-communities {
-
- from {
- community [ my-as1-transit my-as2-transit ];
- }
-
- then {
- community delete my-wild;
- }
- }
- }
Match the set of community members 5000, 5010, 5020, 5030, and so on up to 5090:
- [edit]
- policy-options {
- community customers members "^1111:50.0$";
-
- policy-statement advertise-customers {
- from community customers;
- then accept;
- }
- }
Reject routes that are longer than /19 in Class A space, /16 in Class B space, and /24 in Class C space:
- [edit policy-options]
- community auckland-accept members 555:1;
- policy-statement drop-specific-routes {
-
- from {
-
- route-filter 0.0.0.0/1 upto /19 {
- community add auckland-accept;
- next policy;
- }
-
- route-filter 172.16.0.0/2 upto /16 {
- community add auckland-accept;
- next policy;
- }
-
- route-filter 192.168.0.0/3 upto /24 {
- community add auckland-accept;
- next policy;
- }
- }
- then reject;
- }
In the preceding example, for routes that are not rejected, the tag auckland-accept is added.
Create routing policies to handle peer and customer communities. This example does the following:
- [edit]
- policy-options {
- community internal201 members 201:112;
- community internal202 members 202:112;
- community internal203 members 203:112;
- community internal204 members 204:112;
- community internal205 members 205:112;
- community peer201 members 201:555;
- community peer202 members 202:555;
- community peer203 members 203:555;
- community peer204 members 204:555;
- community peer205 members 205:555;
- community custpeer201 members 201:20;
- community custpeer202 members 202:20;
- community custpeer203 members 203:20;
- community custpeer204 members 204:20;
- community custpeer205 members 205:20;
- community prepend201-1 members 201:1;
- community prepend202-1 members 202:1;
- community prepend203-1 members 203:1;
- community prepend204-1 members 204:1;
- community prepend205-1 members 205:1;
- community prepend201-2 members 201:2;
- community prepend202-2 members 202:2;
- community prepend203-2 members 203:2;
- community prepend204-2 members 204:2;
- community prepend205-2 members 205:2;
- community prepend201-3 members 201:3;
- community prepend202-3 members 202:3;
- community prepend203-3 members 203:3;
- community prepend204-3 members 204:3;
- community prepend205-3 members 205:3;
- community lcl201-low members 201:80;
- community lcl202-low members 202:80;
- community lcl203-low members 203:80;
- community lcl204-low members 204:80;
- community lcl205-low members 205:80;
- community lcl 20x-high members "^20 [ 1-5 ] : 120$";
-
- policy-statement in-customer {
-
- term term1 {
-
- from {
- protocol bgp;
- community lcl 20x-high;
- }
-
- then {
- local-preference 80;
- accept;
- }
- }
-
- term term2 {
-
- from {
- protocol bgp;
- community [ lcl201-high lcl202-high lcl203-high lcl204-high
lcl205-high ];
- }
- then local-preference 120;
- }
- then next policy;
- }
-
- policy-statement out-customer {
-
- term term1 {
-
- from {
- protocol bgp;
- community [internal201 internal202 internal203 internal204
internal205];
- }
- then reject;
- }
- then next policy;
- }
-
- policy-statement in-peer {
- from protocol bgp;
-
- then {
- metric 10;
- community set peer201;
- }
- }
-
- policy-statement out-peer {
-
- term term1 {
-
- from {
- protocol bgp;
- community [ prepend201-1 prepend202-1 prepend203-1 prepend204-1
prepend205-1 ];
- }
- then as-path-prepend 201;
- }
-
- term term2 {
-
- from {
- protocol bgp;
- community [ prepend201-2 prepend202-2 prepend203-2 prepend204-2
prepend205-2 ];
- }
- then as-path-prepend "201 201";
- }
-
- term term3 {
-
- from {
- protocol bgp;
- community [ prepend201-3 prepend202-3 prepend203-3 prepend204-3
prepend205-3 ];
- }
- then as-path-prepend "201 201 201";
- }
-
- term term4 {
-
- from {
- protocol bgp;
- community [ peer201 peer202 peer203 peer204 peer205 custpeer201
custpeer202 custpeer203 custpeer204 custpeer205 internal201 internal202
internal203 internal204 internal205 ];
- }
- then reject;
- }
- then next policy;
- }
- }