How to Redirect BGP Routes into a File with Quagga

bgplinux

We've deployed the caching server in local ISP and peered it with the ISP router via BGP protocol in order to get all advertised ip prefixes of ISP. We need to redirect all of these ip prefixes into a file and sync it to the DNS server. So, we'll add all of these prefixes into bind view directive in order to direct all requests coming from our local ISP clients towards the local caching server.

can i use the combination of bash with quagga and redirect all bgp routes into the file ? show ip bgp command displays all the advertised routes but i am unable to redirect these routes into the file. Linux route command also shows these prefixes but i need cidr notation i.e 1.2.3.4/24 but route command doesn't support it.

Please suggest me if you have better approach.

Best Answer

Let's assume that you are in a bash shell on the quagga router... use the script command to capture output from quagga (or any other interactive CLI session)... a contrived example which saves the quagga bgp routes to a file named bgp_routes.txt

$ script bgp_routes.txt
Script started, file is bgp_routes.txt
$ telnet localhost 2605
... authenticate as required
Router# terminal length 0
... run show ip bgp command
Router# exit
$ exit