使用 quagga 将 BGP 路由重定向到文件中

网络工程 bgp linux
2021-07-05 18:44:18

我们在本地 ISP 中部署了缓存服务器,并通过 BGP 协议将其与 ISP 路由器对等,以获取 ISP 的所有广告 ip 前缀。我们需要将所有这些 ip 前缀重定向到一个文件中,并将其同步到 DNS 服务器。因此,我们将所有这些前缀添加到绑定视图指令中,以便将来自本地 ISP 客户端的所有请求定向到本地缓存服务器。

我可以使用 bash 与 quagga 的组合并将所有 bgp 路由重定向到文件中吗?show ip bgp 命令显示所有通告的路由,但我无法将这些路由重定向到文件中。Linux route 命令也显示这些前缀,但我需要 cidr 符号,即 1.2.3.4/24 但 route 命令不支持它。

如果您有更好的方法,请建议我。

2个回答

假设您在 quagga 路由器上的 bash shell 中...使用该script命令捕获 quagga(或任何其他交互式 CLI 会话)的输出...一个人为的示例,它将 quagga bgp 路由保存到名为 bgp_routes 的文件中。文本文件

$ 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

这应该对你有用。

vtysh -c "show ip bgp neighbors X.X.X.X routes" | sed '1,6d' | awk '{print $2}' | head -n -2 > routes.txt

这将只将路由输出到文件 routes.txt