Juniper as-path-expand with bgp communities

With working in an ISP enviroment I always find myself trying to automate or create process for others to follow so I don’t have to do the work 😉

I recently started to look at BGP communities and to see how I can apply them in day to day life.  One of the applications that would make my life easier the bigger we grow is putting the onus onto the bgp transit customer to affect how we advertise/announce them to our upstreams, peers and customers.

I found a relatively easy way to do this with help from some of the guys on the Juniper forums.

Below is some config that allows our bgp transit customer to send us a bgp community that, once received, will stop announcing them to transit A.

policy-statement prepend_test {
term prepend-1 {
from community prepend-1;
then {
as-path-expand last-as;
accept;
}
}
term prepend-2 {
from community prepend-2;
then {
as-path-expand last-as count 2;
accept;
}
}
}

community prepend-1 65000:1;
community prepend-2 65000:2;

If you then add the policy prepend_test to your bgp export filter away you go.  The customer can then quickly tag an announcement to you and you automatically prepend the customers AS for them.

Just remember to give your customers a list of your BGP communities you allow them to use 🙂

Nick

Leave a comment