Introduction

Hello and welcome to module 3 of the NetBox ‘Zero-to-Hero’ course. In Module 2: Setting up the Organization you learned how to model an organization within NetBox, and how to use the Web Interface to both manually create individual objects, and bulk import objects using CSV-formatted data.

In this module we will continue to populate NetBox with data for our fictional organization. Our intrepid Network Engineer Eric will be adding the network devices that are going to be installed at the planned new Brisbane branch office, making use of the NetBox REST API (he’s heard about these API things on the ‘Router Nerds’ podcast and is keen to learn how to use one).

By the end of this module you will be able to:

  • Describe how NetBox models devices
  • Use Postman to make REST API calls to NetBox
  • Save time by making use of the community library of pre-defined device types

 

Why Use The REST API?

You can obviously add all this data manually via the Web Interface, but by getting hands on with the REST API, you will start to take your skills with NetBox to the next level! A lot of Network Engineers have never used an API (they have surely heard of them by now though) and they might be unsure of how to work with one, or why they should even bother.

The goal of this module is to demystify REST API’s and show you how powerful and simple to use the NetBox REST API is. You will quickly start to see how you can interact programmatically with NetBox and how NetBox can drive your Network Automation efforts going forward.

 

Get Hands On

If you’d like to follow along with the examples used in this course, it’s super easy to do, and you have a few options:

  1. Run NetBox as a container with NetBox Docker – This is the quickest way to get your own dedicated NetBox instance going and it only takes a few minutes to spin up on your laptop!
  2. Follow the official documentation and do a full installation of all the NetBox components. These instructions have been tested on Ubuntu and CentOS Linux.
  3. Use the public demo instance of NetBox
  4. Sign up for a free trial of NetBox Cloud (hosted, managed NetBox with enterprise grade capabilities).

The NetBox version used in the video for this module is v3.3.2, and the following course materials used in the demo are available:

 

Devices

Devices are a key part of NetBox – after all NetBox is a tool for modeling network infrastructure. A device can be any piece of physical hardware installed within your network, such as a server, router, or switch, and may optionally be mounted within a rack. Within each device, resources such as network interfaces and console ports are modeled as discrete components, which may optionally be grouped into modules.

Device objects in NetBox have some dependencies that must already exist in NetBox before you can add the device. They are Manufacturer (the organization that produces the hardware) and Device Type. A device can be installed at a particular position within an equipment rack, or simply associated with a site (and optionally with a location within that site).

 

Device Types

A device type is a combination of manufacturer and hardware model that maps to actual devices that exist in the real world. Device types typically have a number of components modelled on them too for things like interfaces, console ports, and power ports etc.

An example of a device type is a Cisco ISR4321 Router (part_number: ISR4321/K9), and this might have the following component templates defined:

  • 3 x GigabitEthernet interfaces
  • 1 x Console Port
  • 1 x Power Port

Once a device type has been created, then each new device instance of that particular device type you add will have all of the components defined in the device type.

 

Device Roles

These are the functional roles of devices, and are fully customizable by the user. For example, you might create roles for core switches, distribution switches, and access switches within your network.

 

Platforms

A platform defines the type of software running on a device or virtual machine, for example Cisco IOS version 15. NetBox can optionally connect to network devices (to retrieve device information such as LLDP Neighbors) using NAPALM and you can also (optionally) define the driver to be used (eg. ios) as part of the Platform definition.

 

The Project – New Branch Site Devices

Our fictional organization has standardized on the following network devices for their Branch office network deployments:

ManufacturerDevice TypeDevice RolePlatformNAPALM Driver
CiscoISR4321WAN RouterCisco IOSios
JuniperEX4300-48PAccess SwitchJuniper JunOSjunos
Cisco MerakiMR56Wireless APn/an/a
AvocentACS16Console Servern/an/a
PanduitMini-Com High Density Patch Panel (48 Port, 1RU)Patch Paneln/an/a

 

Video – Adding Devices Into NetBox

The video demo will now show you how to add all of the device data into NetBox mainly using the REST API (the device types will be uploaded manually as YAML files). As always the best way to understand the power of NetBox is to dive right in, so let’s get started!

If you are following along, don’t forget to use the Postman Collection for making the API calls and the YAML files used for adding device types.

Adding devices into Netbox

 

Summary

In this module you learned how to add devices into NetBox, making use of the NetBox REST API and a Postman collection.

In Module 4: IP Addressing and VLANs, Susan will use the Ansible Galaxy Collection for NetBox to populate NetBox with the IP addressing and VLAN data for the new Brisbane branch office.