snar / bgpq3

bgpq3
BSD 2-Clause "Simplified" License
363 stars 53 forks source link

Feature Request: Add ASN to recognized format characters in USER-DEFINED FORMAT #51

Closed netravnen closed 4 years ago

netravnen commented 5 years ago

USER-DEFINED FORMAT If you want to generate configuration not for routers, but for some other programs/systems, you may use user-defined formatting, like in example below:

user@host:~>bgpq3 -F "ipfw add pass all from %n/%l to any\n" as3254 ipfw add pass all from 62.244.0.0/18 to any ipfw add pass all from 91.219.29.0/24 to any ipfw add pass all from 91.219.30.0/24 to any ipfw add pass all from 193.193.192.0/19 to any Recognized format characters: '%n' - network, '%l' - mask length, '%N' - object name, '%m' - object mask and '%i' - inversed mask. Recognized escape characters: '\n' - new line, '\t' - tabulation. Please note that no new lines inserted automatically after each sentence, you have to add them into format string manually, elsewhere output will be in one line (sometimes it makes sense):

Was looking at generating custom output, where I include the AS number for custom roa table with bird. bgpq3 -63 -F "roa %n/%l max %l as %a;\n" AS-CHOOPA This is at the moment not possible. Where I use an AS-SET as the data-input. And at the same time wanting to include the ASN in the custom-output.

snar commented 5 years ago

On Sat, Aug 17, 2019 at 07:03:30AM -0700, Chriztoffer Hansen wrote:

USER-DEFINED FORMAT
If you want to generate configuration not for routers, but for some other
programs/systems, you may use user-defined formatting, like in example
below:

user@host:~>bgpq3 -F "ipfw add pass all from %n/%l to any\n" as3254
ipfw add pass all from 62.244.0.0/18 to any
ipfw add pass all from 91.219.29.0/24 to any
ipfw add pass all from 91.219.30.0/24 to any
ipfw add pass all from 193.193.192.0/19 to any
Recognized format characters: '%n' - network, '%l' - mask length, '%N' -
object name, '%m' - object mask and '%i' - inversed mask. Recognized escape
characters: '\n' - new line, '\t' - tabulation. Please note that no new
lines inserted automatically after each sentence, you have to add them into
format string manually, elsewhere output will be in one line (sometimes it
makes sense):

Was looking at generating custom output, where I include the AS number for custom roa table with bird. bgpq3 -63 -F "roa %n/%l max %l as %a;\n" AS-CHOOPA This is at the moment not possible. Where I use an AS-SET as the data-input. And at the same time wanting to include the ASN in the custom-output.

What is the actual goal of this RPKI-faking ? Not every route with registered route-object is valid from RPKI point of view :( Example:

route: 62.113.120.0/21 origin: AS6903 mnt-by: AS6903-MNT mnt-by: ZENON-NOC created: 2019-08-05T06:40:00Z last-modified: 2019-08-05T06:40:00Z source: RIPE

snar@fri:~>whois -h whois.bgpmon.net 62.113.120.0/21 [....]

Prefix: 62.113.120.0/21 Prefix description: Country code: RU Origin AS: 6903 Origin AS Name: ZENON-AS Moscow, Russia, RU RPKI status: ROA validation failed: Invalid Prefix-Length First seen: 2014-08-14 Last seen: 2019-08-17 Seen by #peers: 64

PS: another good question is how shall bgpq3 handle routes with multiple route-objects registered. Example of such route: 188.235.248.0/22 in RIPE, which has 36 (thirty-six) route-objects with different origins registered:

snar@fri:~>whois3 -h whois.ripe.net 188.235.248.0/22 | egrep '^(route|origin):' | sort | uniq -c | sort -rn 36 route: 188.235.248.0/22 1 origin: AS9049 1 origin: AS59713 1 origin: AS57378 1 origin: AS57044 1 origin: AS57026 1 origin: AS56981 1 origin: AS56420 1 origin: AS56377 1 origin: AS56330 [... skipped for brevity ...]

Shall '%a' expand to single ASN or to all possible ASN's in this case ?

snar commented 4 years ago

Closed for inactivity