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
In a nutshell
  • 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.

PolicySets attribute or tagUPDATENeighborReads attributeselection or policyPath chosenTraffic follows

How it works

Attribute categories

CategoryAttributesBehavior
Well-known mandatoryORIGIN, AS_PATH, NEXT_HOPMust be in every UPDATE and be recognized
Well-known discretionaryLOCAL_PREF, ATOMIC_AGGREGATERecognized; included as needed
Optional transitiveCOMMUNITY, AGGREGATORPassed on even if not understood
Optional non-transitiveMED, ORIGINATOR_ID, CLUSTER_LISTNot passed beyond the receiving AS or the reflection cluster

The attributes that steer traffic

AttributeScopeDirection it influencesPolicy action
Local preferenceInside the ASOutbound traffic, which exit to usethen local-preference 200
AS path lengthBetween ASsInbound traffic, by making a path look longerthen as-path-prepend "65001 65001"
MEDOne neighboring ASInbound traffic, a hint to the neighborthen metric 50
OriginAnywhereWeak tie-breakerthen 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
Watch out

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
ActionResult
community add NAMEAdds the tag and keeps the existing ones
community set NAMEReplaces all existing communities
community delete NAMERemoves 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:

CommunityMeaning
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.

CustomerSets 65001:200tag on routeProviderMatches communitythenLocal preference 50Backup path
Exam tip

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, set and delete actions; Junos propagates them by default.
  • Well-known: no-export, no-advertise, no-export-subconfed.
  • AS path regex is configured under policy-options as-path and matched with from 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 add and community set?

    add keeps the existing communities, set replaces 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.