Bgp – Junos: Policy-Statment and AS-Prepends

bgpjuniper-junos

I am trying to create a policy-statement to prepend the local AS number 5 times (assuming it is AS1234) before advertising local routes up to a new upstream transit provider (no inbound traffic is desired via this upstream). MED and communities are not available here (and out of the scope of this question). The policy I originally wrote looked like this;

  policy-statement PS-AS-Prepend-x5 {
     from {
         route-filter 0.0.0.0/0 orlonger;
     }
     to protocol bgp;
      then {
          as-path-prepend "1234 1234 1234 1234 1234";
          accept;
      }
  }

  protocols {
      bgp {
        group new-upstream {
        type external;
        export [ PS-AS-Prepend-x5 ];
      }
  }

The upstream has a looking glass on which I can see that when performing something akin to "show ip bgp prefix/mask" they are only seeing one AS in the path to this route (and all routes advertised). I changed the policy-statement as follows;

  policy-statement PS-AS-Prepend-x5 {
     to protocol bgp;
      then {
          as-path-prepend "1234 1234 1234 1234 1234";
          accept;
      }
  }

After resetting the BGP session the same behaviour as before was still occuring, no prepends. My question is two fold;

  1. Do you need a "from" clause in a policy-statement? I used 0/0 in the original statement as only local prefixes are being advertised so rather than writing them all out I used 0/0 to match them all. I have been search on-line documentation but haven't found anything definitive. This is why removed the "from" clause to try and match all prefixes that way. I also tried to protocol bgp but this too failed.

  2. I now suspect the syntax of the policy-statment is not the problem so my second question is Can you pre-pend your own AS on advertisements in JUNOS to eBGP peers?

UPDATE

me@r1# run show route advertising-protocol bgp 11.22.33.44 detail 

inet.0: 471821 destinations, 512598 routes (471815 active, 0 holddown, 12 hidden)
* 123.0.0.0/8 (3 entries, 1 announced)
 BGP group new-upstream type Externa
     Nexthop: Self
     AS path: [1234] I
     Communities: 1234:1234

Best Answer

  1. Do you need a "from" clause in a policy-statement?

No. You don't. Without a "from" class everything will match.

  1. Can you pre-pend your own AS on advertisements in JUNOS to eBGP peers?

Yes, of course you can, that's the typical way in which AS prepending is being done.

So the real question is: why doesn't this work? One thing which I'm not sure about is the to protocol bgp statement, I've never used that in policies for prepending. The best thing to do is verify if you're actually prepending by checking what you're advertising: show route advertising-protocol bgp aaa.bbb.ccc.ddd detail, where aaa.bbb.ccc.ddd is the peer IP.