YANG

term

networking

Kept in this browser · My desk

The data modelling language of RFC (Request for Comments) 7950, used to model configuration data, state data, remote procedure calls and notifications for network management protocols.

A YANG module defines the tree that NETCONF (Network Configuration Protocol) and RESTCONF read and change: containers, lists keyed by a leaf, and typed leaves. The ietf-interfaces module of RFC (Request for Comments) 8343 is the usual first example; encoded in JSON (JavaScript Object Notation) under RFC 7951, its data carries the module name in front, as in ietf-interfaces:interfaces, so a program knows exactly which model a value belongs to.

YANG is a schema language, not a protocol and not an encoding. A module is a text file that describes data as a tree in which every node has a name and either a value or a set of child nodes, together with the types, constraints and operations that go with it. What travels on the wire is something else: the same model is carried as XML (Extensible Markup Language) by NETCONF (Network Configuration Protocol) and as XML or JSON (JavaScript Object Notation) by RESTCONF, and the specification notes that other protocols and encodings are possible. Module files are named after the module, optionally followed by an at sign and a revision date, with the extension .yang; an equivalent XML notation called YIN (YANG Independent Notation) exists for tools and loses nothing in translation.

The language answers a complaint operators made in public. An IAB (Internet Architecture Board) workshop held from 4 to 6 June 2002 in Reston, Virginia, recorded in RFC (Request for Comments) 3535, found that SNMP (Simple Network Management Protocol) worked reasonably well for monitoring but that equipment was usually not fully configurable through it, and listed what operators wanted instead: a clear distinction between configuration data, operational state and statistics, the ability to fetch each separately, configuration transactions across devices, and a way to dump and restore a configuration. NETCONF, now RFC 6241, supplied the protocol. YANG supplied the description of the content: version 1 is RFC 6020 of October 2010, edited by Martin Bjorklund, and version 1.1 is RFC 7950 of August 2016, a maintenance release with a small number of backward incompatibilities that expressly does not obsolete RFC 6020, so both versions remain valid and a 1.1 module must say so with a yang-version statement. Both are Proposed Standards; RFC 7950 has been updated by RFC 8342 and RFC 8526, and RFC 6020 by RFC 9890 (October 2025), which revised how IANA (Internet Assigned Numbers Authority) keeps module names unique.

Four kinds of data node do most of the work. A leaf holds one value of one type and has no children; a leaf-list is a sequence of such values; a container groups other nodes; a list is a sequence of entries, each identified by the value of its key leaf or leaves. A container is by default only structure, and can be declared a presence container when its mere existence carries meaning. The config statement marks a subtree as configuration (true) or state (false), which is the distinction the operators asked for in 2002. There are 19 built-in types, among them the signed and unsigned integers from 8 to 64 bits, decimal64, string, boolean, enumeration, bits, binary, empty, union and three kinds of reference: leafref, which points at another leaf, identityref and instance-identifier. A typedef derives a new type by restricting a base type with a range or a pattern, and the common derived types (addresses, counters, dates) are published as modules of their own, since December 2025 in RFC 9911, which obsoleted RFC 6991. Constraints between nodes are written with must and when statements in XPath (XML Path Language) 1.0. Operations are modelled as well: rpc for a procedure on the whole device, action, added in version 1.1, for one tied to a container or list entry, and notification for events.

Modules are built to be extended and to be honest. Each has a namespace, a prefix and dated revision statements; it can import other modules and reuse definitions through grouping and uses. An augment statement lets one module add nodes to the tree of another, which is how a vendor attaches its own leaves to a standard model. A feature marks part of a model as optional. A deviation statement declares where a server does not implement a module faithfully, and the specification says deviations must never be part of a published standard: they exist so that a client can learn how a particular implementation differs. The YANG Library of RFC 8525 (March 2019) completes the picture by having the server list the modules, datastores and schemas it actually uses.

Nobody reads a long module from top to bottom; engineers read its tree diagram, a notation fixed by RFC 8340 (March 2018). Each line shows a node with flags and markers: rw for configuration, ro for state, -x for an rpc or action, -n for a notification, a question mark for an optional node, an asterisk for a list or leaf-list, the keys of a list in square brackets and an exclamation mark for a presence container. The ietf-interfaces module of RFC 8343 reads, in that notation, as a container interfaces holding a list interface keyed by name, with the writable leaves name, description, type and enabled and the read-only oper-status and statistics, whose octet counters are 64 bits wide. pyang, a validator and converter written in Python, prints such trees and checks modules; yanglint, from the libyang toolkit written in C, does the same job.

Encoding rules are where client code goes wrong. In XML, a node belongs to its module's namespace. In JSON, RFC 7951 uses the module name, not the namespace or the prefix: a member name is qualified as module, colon, node at the top level and wherever a child comes from a different module than its parent, and is written bare everywhere else. Values of the 64-bit types int64, uint64 and decimal64 are encoded as JSON strings, because many JSON parsers cannot hold them exactly as numbers, so an interface counter arrives in quotation marks. The empty type is encoded as an array holding a single null. The same precision limit applies inside constraints: XPath 1.0 numbers are double-precision floating point, and RFC 7950 warns that equality comparisons on 64-bit values may yield unexpected results.

Datastores tie the model to a device. The Network Management Datastore Architecture (NMDA) of RFC 8342 (March 2018) names the configuration datastores running, candidate, startup and intended, which share one schema, and a separate operational datastore for the state in use. Before it, models duplicated every tree, one for configuration and one for state; RFC 8343, which obsoleted RFC 7223, deprecates the old interfaces-state subtree for that reason and keeps it only for servers and clients that do not implement NMDA.

Models come from three kinds of author. The IETF (Internet Engineering Task Force) publishes its own in RFCs, under review guidelines that are now RFC 9907 (March 2026). OpenConfig, a group of network operators, maintains vendor-neutral models written in YANG, and its gNMI (gRPC Network Management Interface) protocol is specified on the assumption that it carries data instances of those schemas. Vendors publish native modules for whatever the first two do not cover; the YangModels repository on GitHub collects the modules of the IETF, of other standards bodies and of vendors in one place. F5 documents that the RESTCONF and NETCONF interface of F5OS is based on OpenConfig models extended with F5-specific namespaces, which is why its paths mix openconfig and f5 prefixes.

The practical difficulties follow from that plurality. The same interface or route can exist in an IETF model, an OpenConfig model and a native one, each with different paths and types, and a device may implement any subset of them with features disabled and deviations applied; the list the device itself reports is the only reliable inventory. A client built against one revision of a module can meet another on the device. And a model is not a behaviour: YANG says what the data looks like and what values are legal, while what the device does on a change is decided by the protocol operation and by the implementation.

Also known as: rfc 7950, yang 1.1, yang module, yang data model

Sources

← Back to Y Back to the glossary