YANG – Yet Another Next Generation. Network engineers are used to hearing Next Generation. For example, Next Generation Firewalls and Next Generation Wireless.
But in this case, I’m talking about a data modeling language. It’s used with something like NETCONF and RESTCONF. YANG is used to describe networking data models and defines a structure.
YANG was developed by the IETF. Read RFC 6020 to get all the details of how it works. API requests use NETCONF or RESTCONF to make configuration changes and review the configuration.
Building blocks of YANG
- module – top of the hierarchy of nodes
- containers – related nodes
- lists – identifies nodes
- leaf – individual attributes of a node
- type – every leaf has an associated type
Here’s an example:
- Employee
- Employee ID
- SSN
- Gender
- Address
- Birthday
A data model could be about a network device or service. A network device will have containers and leafs about its interfaces, statistics, VLANs, etc. A YANG model on a service may be ACLS, VRFs, BGP, etc.
To explore the YANG models pyang
can be used. Pyang will validate and convert YANG modules to different formats.
I’m going to be using using my DevNet lab files to look into pyang
further.
We’ll explore a file on my desktop, ietf-interfaces.yang
. If you’re going through the DevNet classes then you will also learn about YANG. Some of the examples are taken from DevNet.

To view the the YANG model, I’m going to issue a command in iTerm2, pyang
, to display the tree.
I was able to get a copy of the YANG model from the DevNet labs. In one lab I used git
to download a whole folder of YANG models. On my computer I use pyang
to view details of those YANG models.
Taking a look at ietf-interfaces.yang
, there are two containers, created called interfaces
and interfaces-state
.
ietf-interfaces
is a module of the container. Inside a container is a list. Within the list is the leaf, which are attributes of the individual node items.
You may notice there are rw
and ro
in front of the name.
rw
= read/writero
= read-only
In the example below, ietf-interfaces
is the module. interfaces
will be the container, consisting of interface
leaf with attributes such as the interface name, description, and type.
To the right of the leaf describes what type of attribute it is.
$ pyang -f tree ietf-interfaces.yang
module: ietf-interfaces
+--rw interfaces
| +--rw interface* [name]
| +--rw name string
| +--rw description? string
| +--rw type identityref
| +--rw enabled? boolean
| +--rw link-up-down-trap-enable? enumeration {if-mib}?
| +--ro admin-status enumeration {if-mib}?
| +--ro oper-status enumeration
| +--ro last-change? yang:date-and-time
| +--ro if-index int32 {if-mib}?
| +--ro phys-address? yang:phys-address
| +--ro higher-layer-if* interface-ref
| +--ro lower-layer-if* interface-ref
| +--ro speed? yang:gauge64
| +--ro statistics
| +--ro discontinuity-time yang:date-and-time
| +--ro in-octets? yang:counter64
| +--ro in-unicast-pkts? yang:counter64
| +--ro in-broadcast-pkts? yang:counter64
| +--ro in-multicast-pkts? yang:counter64
| +--ro in-discards? yang:counter32
| +--ro in-errors? yang:counter32
| +--ro in-unknown-protos? yang:counter32
| +--ro out-octets? yang:counter64
| +--ro out-unicast-pkts? yang:counter64
| +--ro out-broadcast-pkts? yang:counter64
| +--ro out-multicast-pkts? yang:counter64
| +--ro out-discards? yang:counter32
| +--ro out-errors? yang:counter32
x--ro interfaces-state
x--ro interface* [name]
x--ro name string
x--ro type identityref
x--ro admin-status enumeration {if-mib}?
x--ro oper-status enumeration
x--ro last-change? yang:date-and-time
x--ro if-index int32 {if-mib}?
x--ro phys-address? yang:phys-address
x--ro higher-layer-if* interface-state-ref
x--ro lower-layer-if* interface-state-ref
x--ro speed? yang:gauge64
x--ro statistics
x--ro discontinuity-time yang:date-and-time
x--ro in-octets? yang:counter64
x--ro in-unicast-pkts? yang:counter64
x--ro in-broadcast-pkts? yang:counter64
x--ro in-multicast-pkts? yang:counter64
x--ro in-discards? yang:counter32
x--ro in-errors? yang:counter32
x--ro in-unknown-protos? yang:counter32
x--ro out-octets? yang:counter64
x--ro out-unicast-pkts? yang:counter64
x--ro out-broadcast-pkts? yang:counter64
x--ro out-multicast-pkts? yang:counter64
x--ro out-discards? yang:counter32
x--ro out-errors? yang:counter32
Leave a Reply