Netlab Examples in GitHub Codespaces

A few days ago, someone asked me about the IPv4 next-hop details of running interface EBGP sessions. I pointed him to a blog post explaining them, adding, “And of course, you can test that in netlab.” A few minutes later, it hit me: instead of asking him to set up netlab locally, I could enable him to do that in a minute with GitHub codespaces.

Setting that up was easy: copy the .devcontainer directory from the BGP labs repository into the netlab examples repository and commit the change. After a short yak-shaving exercise (writing README files and rearranging a few folders), I successfully started the codespace and was ready for this blog post. There was just one gotcha…

I couldn’t find a way to pass a different working directory to GitHub codespaces; when a new codespace opens in a browser window, it always starts in the top directory. Here’s what you have to do afterward:

  • Get the URL of the netlab example you want to run (for example,
  • Get the example directory name from the URL (BGP/Unnumbered)
  • Change into that directory (cd BGP/Unnumbered)
  • Execute netlab up
  • Wait for the container images to download and the lab to start (assuming the lab uses images from vendors that understand the benefits of hassle-free downloads)
  • Have fun ;)

Finally, when you’re done, don’t forget to shut down the lab (with netlab down) and stop the GitHub codespace.

Add comment