Add communities on direct routes in Juniper

Dear all,

Is there a way to add BGP communities on direct (interface) routes in Junipers? The task looks to be simple but the solution eludes me.
In Cisco/Arista, for example, I could use "network route-map <SOME_MAP_THAT_ADDS_COMMUNITIES>".

In Juniper it seems to be impossible. I even tried putting interface-routes into rib-group with an import policy.
But it seems the import policy only works on importing routes into Secondary routing tables (e.g. inet.50), and not into the Primary one (inet.0).

I know it's possible to add communities on later stage while announcing networks to peers, in [protocols bgp group <name> export]. But I'd better slap the community on the routes right when they're imported into RIB, not when they announced to peers.

Thanks in advance.

Unfortunately not yet, as far as I know. Long time ago I gave this to
my account team

Title: Direct routes must support tag and or community
Platform: Trio, priority MX80, MPC2
JunOS: 12.4Rx
Command: 'set interfaxe ge-4/2.0 family inet address
tag>community X'
JTAC: n/a
  - Router must be able to add tags communities to direct routes directly, like
    it does for static routes

Usage Case:
  Trivial way to signal route information to BGP. Often tag/community is used
  by service providers to singal 'this is PI/PA prefix, leak it to internet' or
  'this is backup route, reduce its MED'. However for some reason it is only
  supported for static routes, while usage scenario and benefits are exactly the
  same for direct routes.

Hi Stanislav,
I believe this is what you are looking for:

jcluser@Lothlorien-MX1# show | compare
[edit interfaces lo0 unit 0 family inet]
        address { ... }
+ address;
[edit protocols bgp]
- export IPV4-STATIC;
+ export [ IPV4-STATIC TAG-DIRECT ];
[edit policy-options]
+ policy-statement TAG-DIRECT {
+ from {
+ protocol direct;
+ route-filter exact;
+ }
+ then {
+ community set MYCOMMUNITY;
+ accept;
+ }
+ }
[edit policy-options]
+ community MYCOMMUNITY members 5:5;

jcluser@Lothlorien-MX1# commit
commit complete

jcluser@Lothlorien-MX1# run show route advertising-protocol bgp detail | find
* (1 entry, 1 announced)
BGP group RR-LOADBALANCER type External
     Nexthop: Self
     AS path: [65000] I
     Communities: 5:5

Jason R. Rokeach

I believe you need to add the communities either on the import policy which pulls in the direct route or the export policy to the neighbor(s) you want to feed the communities to.


Junos doesn't maintain an intermediate BGP table / RIB as you would see on
other Cisco-like platforms. Therefore you need to build comm-string actions
into your neighborship policies.