You just got promoted to network automation lead.
Your company has Cisco routers in one site, Juniper in another, and Arista in a third.Your first task: add a description on the WAN interface of every router.
You open your terminal, and there is the problem: each vendor speaks a different dialect.
Figure 1 – Three vendors, three CLI dialects
To automate this with the CLI, your script has to learn every vendor's dialect, and any future IOS update can break your parsing.
You need a common vocabulary that every vendor agrees on.
One Model, All Vendors
This is where YANG comes in.
Instead of typing vendor-specific commands, you describe the change once using a shared data schema that Cisco, Juniper, and Arista all agree on.
Figure 2 – One YANG model, three vendors
You build your payload using
ietf-interfaces, a standard YANG model published by the IETF.
Every modern device implements it.
Only the interface name changes: GigabitEthernet0/1 on Cisco, ge-0/0/1 on Juniper, Ethernet1 on Arista.Answer the question below
What is the main benefit of using a data modeling language like YANG instead of vendor-specific CLI?
YANG stands for Yet Another Next Generation. It is a data modeling language.
Think of it as a way to write down what a router's configuration looks like, in a format every vendor agrees on.Two RFCs define YANG: RFC 6020 for version 1.0 and RFC 7950 for version 1.1.
Both define the same language, with version 1.1 refining version 1.0.What a YANG Module Looks Like
A YANG file is called a module.
It lists every field a device exposes and the type of value each field accepts.
Inside a module, the value-holding fields are called leaves.Here is a simplified extract of the
ietf-interfacesmodule:module ietf-interfaces { container interfaces { list interface { key "name"; leaf name { type string; } leaf description { type string; } leaf enabled { type boolean; } } } }You do not write YANG modules yourself.
Vendors and standards bodies write them.Your job is to read them and send matching data.
Answer the question below
What is the name of a YANG file that defines fields and their data types?
Validation Before Apply
Before applying any change, the device checks your data against its YANG modules.

Figure 3 – YANG rejects the change before it applies
In the example above, the script sends
"enabled": "yes".
R1 sees thatenabledexpects a boolean, finds a string instead, and answers with400 Bad Request.
The running config stays untouched.The YANG model enforces two things: semantics (what each field means) and constraints (which values are allowed).
With the CLI, you only notice the error once the device has tried to apply your change.
With YANG, validation happens upfront.Answer the question below
What two things does a YANG model enforce when a device receives a configuration change?
Time to see what a YANG model contains and what your script actually sends.
Anatomy of a YANG Interface
The
ietf-interfacesmodel describes a network interface.
Here are four of its key fields.
Figure 4 – How an interface is described in YANG
Every field has a name and a strict data type.
Thenameanddescriptionare strings,enabledis a boolean, andtypeidentifies the kind of interface (Ethernet, VLAN, loopback).When your script wants to configure an interface, it sends a payload that follows this exact structure:
{ "ietf-interfaces:interface": { "name": "GigabitEthernet0/1", "description": "WAN", "enabled": true, "type": "iana-if-type:ethernetCsmacd" } }Each key matches a field from the YANG module.
Each value matches the type declared in the module.
Send
"yes"forenabledand the router rejects the payload.
Theenabledfield only acceptstrueorfalse.Answer the question below
In the ietf-interfaces model, what data type does the enabled field accept?
Open YANG and Native YANG
There are two families of YANG models you will meet on a Cisco device.
Open models come from standards bodies.
ietf-interfacesis published by the IETF and works the same way across vendors. OpenConfig, a vendor-neutral working group, publishes another large set of open models.
Native models come from the vendor.
Cisco-IOS-XE-nativeexposes every Cisco-specific feature, including those not yet covered by an open model.
Open models maximize portability. Native models maximize coverage.
Most automation projects use a mix of both.Answer the question below
Which family of YANG models is published by standards bodies like the IETF and works the same way across vendors?
Custom Data Types
YANG ships with basic types (string, boolean, integer) but model developers can go further.
They can create custom data types with built-in constraints.For example, a vendor can define a
vlan-idtype:typedef vlan-id { type uint16 { range "1..4094"; } }Any field declared with this type only accepts integers between 1 and 4094.
The device rejects0,5000, or any string before reaching the running config.Answer the question below
YANG lets model developers do something the CLI cannot: extend the type system. What is this feature called?
Answer the question below
Module: id 1..1000, mtu 576..9216, enabled boolean, description string. Payload: id 1000, mtu 9217, enabled false, description "5000": which leaf fails validation?
YANG describes the data, but it does not move it.
To carry a YANG-modeled payload between your script and the device, you need a transport protocol.
Two of them speak YANG:NETCONF sends data as XML over SSH on TCP 830.
RESTCONF sends the same data as JSON or XML over HTTPS on TCP 443.

Figure 5 – YANG is the schema, NETCONF and RESTCONF are the transports
Think of YANG as the blueprint of a house.
NETCONF and RESTCONF are the trucks that deliver the materials.Same YANG, Two Encodings
Here is the same interface configuration, sent over each protocol.
Over NETCONF (XML):
<interface> <name>GigabitEthernet0/1</name> <description>WAN</description> <enabled>true</enabled> </interface>Over RESTCONF (JSON):
{ "ietf-interfaces:interface": { "name": "GigabitEthernet0/1", "description": "WAN", "enabled": true } }Only the encoding on the wire changes.
Answer the question below
Switching from NETCONF to RESTCONF, only the ___ on the wire changes.
Answer the question below
On which TCP port does NETCONF listen by default?