Bgpq3

bgpq3 is a command-line tool to produce access-lists, prefix lists, and ASN-lists from routing registries.

Examples
Examples assume you are 32-bit ASN safe, which you should be if you're on the internet and it's 2016 or later. Therefore the -3 option is always specified.

bird
bird is a routing engine that runs on UNIX, so we will specify the -b flag to create BIRD-compatible output. I use this on the MBIX route servers.

Example 1 - AS list
Generate AS list allas from AS macro AS-LESNET, using the ARIN route registry data:

bgpq3 -3b -S ARIN -f 18451 -l allas AS-LESNET allas = [16395, 18451, 20144, 20291, 20940, 23523, 31914, 32773, 36493, 62752, 62758, 393445, 394352, 394466, 395089];

Example 2 - IPv4 prefix list
Generate IPv4 prefix list allnet from AS macro AS-LESNET, accepting any prefixes up to 24 bits long, using the ARIN route registry data:

./bgpq3 -34b -S ARIN -l allnet -R 24 AS-LESNET allnet = [ 23.12.41.0/24,   44.135.120.0/24,    66.160.164.0/23{23,24},    72.246.19.0/24,    72.247.146.0/24,    72.247.147.0/24,    74.120.4.0/22{22,24},    104.244.244.0/22{22,24},    142.147.52.0/23{23,24},    162.249.40.0/23{23,24},    162.249.42.0/23{23,24},    192.146.230.0/23{23,24},    192.160.102.0/24,    192.195.203.0/24,    192.219.0.0/24,    198.51.75.0/24,    198.62.164.0/24,    198.181.199.0/24,    199.87.152.0/21{21,24},    208.81.0.0/21{21,24} ];

Example 3 - IPv6 prefix list
Generate IPv6 prefix list allnet from data source ARIN allowing 56-bit long prefixes, for as-set object AS-LESNET

./bgpq3 -36b -S ARIN -l allnet -R 56 AS-LESNET allnet = [ 2600:1417:4::/48{48,56},   2600:1417:23::/48{48,56},    2602:ff6d::/36{36,56}, 2605:e200::/32{32,56}, 2620:19:4000::/48{48,56},   2620:42:c000::/48{48,56} ];

Cisco IOS
Cisco IOS is the default, so no special flags are needed.

Example 1: IPv4 Prefix list
Generate IPv4 prefix list 3T-in from data source ARIN for object AS-3TSYSTEMS (as-set).

./bgpq3 -34 -S ARIN -l 3T-in -R 24 AS-3TSYSTEMS no ip prefix-list 3T-in ip prefix-list 3T-in permit 104.244.244.0/22 le 24 ip prefix-list 3T-in permit 142.147.52.0/23 le 24

Example 2: IPv4 Access list
Generate IPv4 access-list 3T-ipv4-in from data source ARIN for object AS-3TSYSTEMS (as-set).

WARNING: seems broken, the wildcard masks appear invalid. ./bgpq3 -34E -S ARIN -l 3T-ipv4-in -R 24 AS-3TSYSTEMS no ip access-list extended 3T-ipv4-in ip access-list extended 3T-ipv4-in permit ip 104.244.244.0 0.0.3.0 255.255.252.0 0.0.3.0 permit ip 142.147.52.0 0.0.1.0 255.255.254.0 0.0.1.0