Skip to content

Instantly share code, notes, and snippets.

@markstgodard
Created December 2, 2016 19:35
Show Gist options
  • Select an option

  • Save markstgodard/db0d703a29643f24d0502fa27b320dd2 to your computer and use it in GitHub Desktop.

Select an option

Save markstgodard/db0d703a29643f24d0502fa27b320dd2 to your computer and use it in GitHub Desktop.
How to get route info from a gorouter in-memory routing table

Get Route

The example below is an example using bosh-lite

  • Go on to a gorouter VM
$ bosh ssh router_z1
  • Get the user, password info for the gorouter status endpoint
$ head /var/vcap/jobs/gorouter/config/gorouter.yml
---

status:
  port: 8080
  user: router
  pass: "router"
  • Fetch the routes info and dump to temp file
$ curl -s http://router:[email protected]:8080/routes | json_pp > routes-temp.json

Note: in the above "router:router" is the username / password in previous step. The ip address is the address that the gorouter is listening on, typically the well known IP address (not localhost or 127.0.0.1).

  • View route info in file Open the file and search for the route your are looking for.
$ less routes-temp.json

For example: "proxy.bosh-lite.com"

   . . . 
  "blobstore.bosh-lite.com" : [
      {
         "ttl" : 0,
         "address" : "10.244.0.130:8080"
      }
   ],
   "proxy.bosh-lite.com" : [
      {
         "ttl" : 0,
         "address" : "10.244.16.14:60002"
      },
      {
         "ttl" : 0,
         "address" : "10.244.16.14:60004"
      }
   ],
   "api.bosh-lite.com/networking" : [
      {
       . . .
@gcoon151
Copy link
Copy Markdown

gcoon151 commented Dec 2, 2016

I can't get it to run the command, but I did take the time to do this...

echo curl -s http://`head /var/vcap/jobs/gorouter/config/gorouter.yml| awk '/user: /{print $2}'`:`head /var/vcap/jobs/gorouter/config/gorouter.yml| awk '/pass: /{print $2}'`@`netstat -an|grep LISTEN |awk '/8080/ {print $4}'`/routes

@gcoon151
Copy link
Copy Markdown

gcoon151 commented Dec 2, 2016

Oh and I was going to awk out the port and pass that to the last netstat search for where it's listening on. Meh. You get the idea.

@tcdowney
Copy link
Copy Markdown

tcdowney commented Jun 10, 2024

I was trying to dump a Gorouter's routing table and stumbled on this gist in 2024. 😅 Turns out it is available on port 8082 now, so here are the modern docs for doing this in case anyone else ends up here:
https://github.com/cloudfoundry/gorouter?tab=readme-ov-file#the-routing-table

There is now a /var/vcap/jobs/gorouter/bin/retrieve-local-routes script on the router VM that can call the endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment