NETCONF and RESTCONF — Model-Driven Network APIs
How NETCONF (XML over SSH) and RESTCONF (JSON/XML over HTTPS) let you configure Cisco IOS-XE / NX-OS programmatically using YANG models. Config datastores, capabilities, and where each fits.
- Both protocols move network config as **structured data driven by YANG models** instead of screen-scraped CLI. NETCONF uses XML over SSH; RESTCONF uses HTTPS with JSON or XML.
- NETCONF has the richer feature set: **datastores** (running, candidate, startup), **capabilities**, transactions (commit / rollback). RESTCONF is a thinner REST-friendly subset.
- You reach for NETCONF when a device supports it and you need transactional / candidate config. You reach for RESTCONF when you want simple REST tooling (curl, Postman, Python `requests`) with the same YANG models.
The one-sentence mental model
Screen-scraping the CLI is fragile. Model-driven APIs are contracts. Instead of parsing “show ip interface brief” text output, you fetch a YANG-shaped tree of interface state — same on every version, same across platforms that share the model.
Layers stacked together
Your automation code (Python / Ansible / Terraform)
↓
Protocol: NETCONF (XML / SSH) or RESTCONF (JSON / HTTPS)
↓
YANG data model (structure of the config / state)
↓
Device (IOS-XE, NX-OS, IOS-XR, JunOS, Arista, etc.)
- YANG = the schema. Defines what fields exist and their types.
- NETCONF / RESTCONF = the wire protocols that carry YANG-modeled data.
- gNMI = a newer alternative — same YANG models but over gRPC (see the telemetry topic).
NETCONF quick facts
- Transport: SSH, port 830 (default).
- Encoding: XML.
- Operations:
<get>,<get-config>,<edit-config>,<commit>,<lock>,<validate>,<discard-changes>,<close-session>. - Datastores:
running(live),candidate(staging area),startup(saved), sometimesintended. - Capabilities: on session open, device advertises which YANG modules + features it supports.
Typical flow:
- Open SSH session on port 830.
- Exchange
<hello>— device sends capabilities. <lock>the candidate datastore.<edit-config>to stage changes.<validate>(optional) — syntax check.<commit>to apply.<unlock>→<close-session>.
Because commit is atomic across the candidate → running move, either everything applies or nothing does. That’s the killer feature vs REST.
RESTCONF quick facts
- Transport: HTTPS.
- Encoding: JSON (
application/yang-data+json) or XML. - Operations: standard HTTP verbs — GET, POST (create), PUT (replace), PATCH (merge), DELETE.
- Base URL:
https://<device>/restconf/data/<yang-module>:<container>/...
Sample GET on IOS-XE for a specific interface:
curl -k -u admin:pass \
-H "Accept: application/yang-data+json" \
https://10.0.0.1/restconf/data/ietf-interfaces:interfaces/interface=GigabitEthernet1
Sample PUT to set an IP:
curl -k -u admin:pass -X PUT \
-H "Content-Type: application/yang-data+json" \
-d '{"ietf-interfaces:interface":{"name":"GigabitEthernet1","enabled":true,"ietf-ip:ipv4":{"address":[{"ip":"10.10.1.1","netmask":"255.255.255.0"}]}}}' \
https://10.0.0.1/restconf/data/ietf-interfaces:interfaces/interface=GigabitEthernet1
Turning them on (IOS-XE)
netconf-yang
restconf
ip http secure-server
Then confirm:
show netconf-yang datastores
show netconf-yang sessions
show platform software yang-management process
Python quickstart
NETCONF with ncclient:
from ncclient import manager
with manager.connect(host="10.0.0.1", port=830, username="admin",
password="pass", hostkey_verify=False) as m:
print(m.get_config(source="running").data_xml[:2000])
RESTCONF with requests:
import requests
requests.packages.urllib3.disable_warnings()
r = requests.get(
"https://10.0.0.1/restconf/data/ietf-interfaces:interfaces",
auth=("admin","pass"),
headers={"Accept": "application/yang-data+json"},
verify=False)
print(r.json())
Ansible ships modules for both (ansible.netcommon.netconf_get, ansible.netcommon.restconf_config).
When to pick which
NETCONF when:
- You need atomic multi-change transactions (candidate + commit).
- You need
<lock>to prevent parallel changes during a change window. - You’re using a mature framework like NSO / OpenDaylight.
RESTCONF when:
- You want to script quick tooling with curl / Postman / vanilla
requests. - Your team already speaks REST.
- Transactional atomicity isn’t required (single-request changes).
gNMI when:
- You want telemetry (streaming state changes over persistent connection).
- Multi-vendor at scale — gNMI is more standardized across vendors than either.
Common exam / real-world mistakes
- Confusing YANG with NETCONF. YANG is the schema; NETCONF is the transport. Same YANG can be used over NETCONF, RESTCONF, or gNMI.
- Assuming RESTCONF is transactional. It isn’t. A PATCH that touches many fields may partially apply and error out. Reach for NETCONF if you need atomic.
- Mixing OpenConfig and Cisco-native models. Every device supports both. Same feature, different YANG structure. Standardize on one per project or pay in translation code.
- Ignoring capabilities. Two IOS-XE versions may advertise different YANG modules. Always fetch the device’s capabilities before assuming a path exists.
- Password in the config. Basic auth over HTTPS is convenient in the lab but painful in prod. Move to certificate-based auth or vault-managed secrets.
Cheat strip
YANG the schema. Both protocols speak it.
NETCONF XML over SSH port 830. Rich: locks, candidate/running/startup,
commit/rollback, atomic transactions. Client: ncclient.
RESTCONF JSON (or XML) over HTTPS. Standard REST verbs. curl-friendly.
Client: requests / Postman / any HTTP tool.
Enable IOS-XE:
netconf-yang
restconf
ip http secure-server
Operations
NETCONF <get> <get-config> <edit-config> <commit> <lock> <validate>
RESTCONF GET / POST / PUT / PATCH / DELETE
Pick transactional multi-change → NETCONF
quick REST scripts → RESTCONF
streaming telemetry → gNMI
EEM — Embedded Event Manager Applets and Scripts
How EEM lets a Cisco router react to on-box events automatically: syslog triggers, SNMP thresholds, timers, interface state — all handled with tiny applets or Tcl scripts. The CCNP ENCOR automation you can enable without any external tool.
Cisco StackWise Virtual (SVL) — Two Chassis as One Logical Switch
How StackWise Virtual makes a pair of Catalyst 9500/9600 chassis behave as a single logical switch. SVL links, DAD (dual-active detection), and why SVL replaced legacy VSS.
Want this drilled into reflex?
1:1 weekly sessions, live feedback on your labs, and US interview prep — built around the CCNP® exam blueprint. Free first session. No card on file until you decide.
Related topics
Ansible for Network Engineers
Push configuration to dozens of Cisco devices from one YAML playbook. Covers inventory, modules, idempotency, and why Ansible became the default automation tool for network teams who don't want to write a custom Python script for every change.
Automation & ProgrammabilityJSON, YAML & XML for Network Engineers
The three data formats you'll meet doing network automation. JSON for APIs, YAML for configs/playbooks, XML for legacy and NETCONF. Same data, three syntaxes, different ergonomics.
Automation & ProgrammabilitygRPC & gNMI — Streaming Telemetry
The modern alternative to SNMP polling. Devices stream structured data continuously to a collector over gRPC. Covers gNMI for config and monitoring, why streaming beats polling, and what's replacing SNMP in real networks.
Get the free CCNA 12-week roadmap
You're already reading up on NETCONF and RESTCONF — Model-Driven Network APIs. The roadmap is the order I recommend studying every CCNA topic in — with what to lab each week and where NETCONF and RESTCONF — Model-Driven Network APIs fits. A written personal reply, not an autoresponder. Expect it within one business day.
Personal reply from a senior network engineer. No third-party tracking. Unsubscribe any time.