GoBGP grpc code examples

18 April 2017    bgp automation networking 

For those that haven’t heard about it yet, GoBGP is, as they say “an open source BGP implementation designed from scratch for modern environment and implemented in a modern programming language, the Go Programming Language”.

To me, the most interesting part of GoBGP is that it uses a grpc interface to interact with the daemon and anything that can be done via its configuration file and/or CLI can be done via this interface. As a matter of fact, the CLI actually uses this interface to retrieve data and configure things.

What this means is that you can easily write tooling to automatically deploy GoBGP instances, peers, policies or even to manipulate the RIB. The latter is particularly interesting as I haven’t seen any other BGP daemon that let’s you manipulate the RIB programmatically.

Last weekend I wanted to see how much of what I just said was true (spoiler alert, it is) so I put together a docker environment and wrote some code to:

  • Deploy peers
  • Deploy BGP policies
  • Manipulate the RIB

Well, I don’t want to waste more of your time so I will just link the Github repo where you can find the code, the environment and instructions to replicate everything: