BIRD – BGP AS Path Manipulation

25 Apr
BGP Path Manipulation

BGP Path Manipulation

I use BIRD as a BGP router it’s reliable, and use small resources. Talking about network upstreams, I already have 2 network upstream and I’ll replace one of them because it’s to expensive and not worth for business. Finally I have new upstream but I had an issue when connecting my network to new upstream, they have 2 different AS number for their local internet exchange (AS-1) and global internet exchange (AS-2). The problem is my upstream sent/advertise their local internet exchange (AS-1) prefixes though international (AS-2), by doing this, I loss best path to their local internet exchange compared to my other upstreams.

I need to delete AS-2 from prefixes which advertised by AS-1, and here is my BGP filter rule to delete AS path on BIRD:

filter bgp_in_upstream1 {
if (bgp_path ~ [= 12345 67890 * =]) && (bgp_path.last != 12345) then bgp_path.delete(12345);
bgp_local_pref=250;
accept; }

Explaination:
bgp_path ~ [= 12345 67890 * =] this rule is to filter prefix which has first as path 12345 and second as path 12345 and * are indicate all as number allowed.
bgp_path.last != 12345 excluding as 12345 from this filter to avoid prefix that have as origin 12345 deleted.
then bgp_path.delete(12345) this is a decision rule to delete as 12345.

Here is the results:

Before:

119.81.0.0/18 via 1.1.1.1 on em3 [peer_upstream1 19:10:17] (100) [AS36351i]
Type: BGP unicast univ
BGP.origin: IGP
BGP.as_path: 12345 67890 36351
BGP.next_hop: 1.1.1.1
BGP.local_pref: 250

After:

119.81.0.0/18 via 1.1.1.1 on em3 [peer_upstream1 20:37:30] * (100) [AS36351i]
Type: BGP unicast univ
BGP.origin: IGP
BGP.as_path: 67890 36351
BGP.next_hop: 1.1.1.1
BGP.local_pref: 250

Hope this help

Reference: http://bird.network.cz/?get_doc&f=bird-5.html

Leave a Reply

Your email address will not be published. Required fields are marked *

*