BGP · Topic 3 of 5
BGP Attributes and Communities
JN0-650 study page on BGP path attributes and communities on Junos: local preference, MED, AS path prepend, well-known communities and community policy.
- 5 min
- ORIGIN, AS_PATH, NEXT_HOP are well-known mandatory; LOCAL_PREF is well-known discretionary; COMMUNITY is optional transitive; MED is optional non-transitive.
- Local preference: inside the AS, higher wins, default 100, influences outbound traffic.
- AS path prepend and MED influence inbound traffic from neighbors.
What it is
Path attributes are the properties attached to every BGP route. They tell the receiver where a route came from and how it should be treated. You change traffic patterns by changing attributes in routing policy.
A community is a tag attached to a route. It carries no meaning of its own: you and your neighbors agree on what each tag means, and policy acts on it.
How it works
Attribute categories
| Category | Attributes | Behavior |
|---|---|---|
| Well-known mandatory | ORIGIN, AS_PATH, NEXT_HOP | Must be in every UPDATE and be recognized |
| Well-known discretionary | LOCAL_PREF, ATOMIC_AGGREGATE | Recognized; included as needed |
| Optional transitive | COMMUNITY, AGGREGATOR | Passed on even if not understood |
| Optional non-transitive | MED, ORIGINATOR_ID, CLUSTER_LIST | Not passed beyond the receiving AS or the reflection cluster |
The attributes that steer traffic
| Attribute | Scope | Direction it influences | Policy action |
|---|---|---|---|
| Local preference | Inside the AS | Outbound traffic, which exit to use | then local-preference 200 |
| AS path length | Between ASs | Inbound traffic, by making a path look longer | then as-path-prepend "65001 65001" |
| MED | One neighboring AS | Inbound traffic, a hint to the neighbor | then metric 50 |
| Origin | Anywhere | Weak tie-breaker | then origin igp |
set policy-options policy-statement PREFER-ISP-A term 1 from neighbor 192.0.2.2
set policy-options policy-statement PREFER-ISP-A term 1 then local-preference 200
set policy-options policy-statement PREFER-ISP-A term 1 then accept
set protocols bgp group ISP-A import PREFER-ISP-A
Local preference is sent only to IBGP peers and never to EBGP peers. MED is received from a neighbor, carried to your own IBGP peers, but not passed on to another AS. To influence inbound traffic from a neighbor you prepend the AS path or set a MED, because you do not control their local preference.
Prepending adds your own AS number extra times so that the path looks longer:
set policy-options policy-statement PREPEND term 1 then as-path-prepend "65001 65001"
set policy-options policy-statement PREPEND term 1 then accept
set protocols bgp group ISP-B export PREPEND
Prepending only has an effect when AS path length is the deciding step. A higher local preference on the other side overrides it.
AS path matching
Policy can match the AS path with a regular expression. Each AS number is an element, so ^65002 .* means the path begins with AS 65002.
set policy-options as-path FROM-65002 "^65002 .*"
set policy-options policy-statement ASFILTER term 1 from as-path FROM-65002
Communities
A standard community is written AS:value, such as 65001:100. A route can carry several. You define a community by name in policy-options and then use it in policy to match, add or remove.
set policy-options community CUST-BACKUP members 65001:200
set policy-options community NOEXP members no-export
set policy-options policy-statement TAG term 1 then community add CUST-BACKUP
set policy-options policy-statement ACT term 1 from community CUST-BACKUP
set policy-options policy-statement ACT term 1 then local-preference 50
| Action | Result |
|---|---|
community add NAME | Adds the tag and keeps the existing ones |
community set NAME | Replaces all existing communities |
community delete NAME | Removes the matching tags |
Junos sends communities to peers by default, so no extra statement is needed to propagate them. The well-known communities have fixed meaning:
| Community | Meaning |
|---|---|
no-export (65535:65281) | Do not advertise outside the AS or confederation |
no-advertise (65535:65282) | Do not advertise to any peer |
no-export-subconfed (65535:65283) | Do not advertise outside the local sub-AS |
A name can also use a wildcard pattern in the member string, for example "65001:1.*", to match a range of values in one definition. Extended communities such as target:65001:100 are used for VPNs and EVPN route targets.
Use communities to turn policy into a menu. Customers tag a route and your policy reads the tag, so you never edit prefix lists for them.
Common mistakes
Setting local preference toward an EBGP neighbor. It is not sent outside the AS.
Using MED to steer traffic through a third AS. MED is only compared between paths from the same neighbor AS by default.
Replacing instead of adding a community. set wipes the existing tags, add keeps them.
Expecting no-export to stop IBGP. It stops advertisement to EBGP peers outside the AS, not inside.
Prepending the wrong number. Prepend the local AS, not the neighbor's.
What to remember for the exam
- ORIGIN, AS_PATH, NEXT_HOP are well-known mandatory; LOCAL_PREF is well-known discretionary; COMMUNITY is optional transitive; MED is optional non-transitive.
- Local preference: inside the AS, higher wins, default 100, influences outbound traffic.
- AS path prepend and MED influence inbound traffic from neighbors.
- Communities are tags;
add,setanddeleteactions; Junos propagates them by default. - Well-known:
no-export,no-advertise,no-export-subconfed. - AS path regex is configured under
policy-options as-pathand matched withfrom as-path.
Check yourself
Which attribute do you change to choose the outbound exit inside your AS?
Local preference; the higher value is preferred.
How do you make a path look less attractive to a neighbor AS without changing their policy?
Prepend your AS number to the AS path or set a higher MED.
What is the difference between
community addandcommunity set?addkeeps the existing communities,setreplaces them all.
Topic 3 of 5 in BGP
Test yourself on BGP
The full Juniper JNCIP-ENT JN0-650 question bank has 858 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.