Configure And Verify
4.6 Configure and verify NETCONF and RESTCONF
Aligned to Cisco's 350-401 ENCOR v1.2 exam topics.
On this page
What this objective tests
NETCONF and RESTCONF are model-driven management protocols. Software uses them to read and change device state as structured data, not as parsed CLI text. The exam tests how to enable both on IOS XE, how each protocol works, and how to read a reply.
| Topic | NETCONF | RESTCONF |
|---|---|---|
| Transport | SSH | HTTPS |
| Common port | TCP 830 | TCP 443 |
| Data encoding | XML | JSON or XML |
| Operation style | Remote Procedure Call (RPC) | HTTP methods on URIs |
| Data model | YANG | YANG |
Both protocols use the same YANG models. YANG defines the valid configuration and state tree on the device.
Why model-driven management matters
Traditional automation logs in with SSH, runs a CLI command, and parses human text. It breaks when the output format changes.
Model-driven automation connects to a management protocol, requests a modeled resource, and receives structured XML or JSON. It is easier to validate and safer to integrate with software.
Automation client
|
+-- NETCONF (SSH, TCP 830): RPC <get>, <edit-config> -> XML reply
|
+-- RESTCONF (HTTPS, TCP 443): GET /restconf/data/... -> JSON or XML
|
v
YANG models define the config and state tree on the deviceEnable NETCONF and RESTCONF on IOS XE
Both protocols need a local user, a domain name, and crypto keys:
conf t
hostname R1
ip domain-name lab.local
username ccnp privilege 15 secret STRONG_PASSWORD
crypto key generate rsa modulus 2048
ip ssh version 2
ip http secure-server
netconf-yang
restconf
endnetconf-yangenables NETCONF over SSH.restconfenables RESTCONF. It needsip http secure-serverfor HTTPS.
Verify on the device:
show platform software yang-management process
show netconf-yang status
show ip http server statusFrom the automation host, test reachability:
nc -vz 10.10.10.1 830
nc -vz 10.10.10.1 443Note: Give the YANG processes time to start after netconf-yang. Check show netconf-yang status before you blame the client.
RESTCONF example: GET interfaces with curl
This example reads operational interface data with the Cisco-IOS-XE-interfaces-oper model:
curl -k -u ccnp:STRONG_PASSWORD \
https://10.10.10.1/restconf/data/Cisco-IOS-XE-interfaces-oper:interfaces \
-H 'Accept: application/yang-data+json'Expected JSON reply (shortened):
{
"Cisco-IOS-XE-interfaces-oper:interfaces": {
"interface": [
{
"name": "GigabitEthernet1",
"interface-type": "iana-if-type:ethernetCsmacd",
"admin-status": "if-state-up",
"oper-status": "if-oper-state-ready",
"speed": "1000000000",
"statistics": {
"in-octets": 12849302,
"out-octets": 9022118
}
}
]
}
}Read the URI in parts. The model prefix before the colon names the YANG module. The path after it names the container or list. A wrong module name or key returns 404, even when credentials and TLS are correct.
Note: curl -k disables TLS certificate checks. Use it only in a disposable lab with a self-signed certificate. In production, trust the correct CA bundle.
NETCONF example: a get RPC
NETCONF sends XML RPCs over the SSH session. This <get> asks for the same operational interface data:
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
<get>
<filter type="subtree">
<interfaces xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-interfaces-oper"/>
</filter>
</get>
</rpc>The device answers with an <rpc-reply> that carries the matching <data> in XML. Common RPC operations:
| RPC | Purpose |
|---|---|
<get> | Read configuration and state data. |
<get-config> | Read configuration from a datastore. |
<edit-config> | Change configuration. |
<lock> / <unlock> | Protect a datastore during changes. |
<commit> | Apply a candidate configuration. |
Read the datastore name in client code. <get-config> on running returns configuration, not live counters. An interface can show enabled in configuration and still be operationally down. Use <get> or a state model for operational data.
RESTCONF methods and response codes
The HTTP method tells the device what to do:
| Method | Meaning |
|---|---|
GET | Read data. |
POST | Create data under a parent resource. |
PUT | Create or replace a resource. |
PATCH | Merge changes into a resource. |
DELETE | Delete a resource. |
Know the common response codes:
| Code | Meaning | Typical cause |
|---|---|---|
200 OK | Read succeeded. | Correct GET with a reply body. |
201 Created | Resource created. | Successful POST or PUT. |
204 No Content | Change succeeded, no reply body. | Successful PATCH or DELETE. |
400 Bad Request | Malformed payload or URI. | Bad JSON, wrong leaf value. |
401 Unauthorized | Authentication failed. | Wrong username or password. |
403 Forbidden | Authenticated but not allowed. | User privilege too low. |
404 Not Found | Resource does not exist. | Wrong module, path, or list key. |
405 Method Not Allowed | Method not supported on this resource. | DELETE on a read-only model. |
409 Conflict | Datastore locked or edit conflict. | Another session holds the lock. |
500 Internal Server Error | Device-side failure. | YANG process or datastore problem. |
Note: PUT replaces the target resource. PATCH merges into it. Using PUT to change one field can remove sibling configuration.
Lab: enable and test both protocols
Topology:
Automation host 10.10.10.50 ---- R1 10.10.10.1Goal: enable NETCONF and RESTCONF on R1, then read interface data with curl.
Do these steps:
- Configure R1 with hostname, domain name, a privilege 15 user, RSA keys, SSH v2,
ip http secure-server,netconf-yang, andrestconf. - Verify on R1:
show netconf-yang statusandshow ip http server status. - From the host, test ports:
nc -vz 10.10.10.1 830andnc -vz 10.10.10.1 443. - Read operational interface data with curl:
curl -k -u ccnp:STRONG_PASSWORD \
https://10.10.10.1/restconf/data/Cisco-IOS-XE-interfaces-oper:interfaces \
-H 'Accept: application/yang-data+json'- Confirm the reply contains interface entries with
admin-status,oper-status, and counters. - Change a URI component to a wrong module name. Send the request again and confirm the reply is
404. - Send a wrong password and confirm the reply is
401. - Send the NETCONF
<get>RPC from the example with an SSH NETCONF client. Confirm the<rpc-reply>contains interface XML.
Expected result: the curl GET returns JSON like the example above. The wrong URI gives 404. The wrong password gives 401. The NETCONF <get> returns matching data in XML.
Exam traps
- Port swap is the classic trap. NETCONF runs over SSH on TCP 830. RESTCONF runs over HTTPS on TCP 443.
- NETCONF is XML only. RESTCONF uses JSON or XML. Both are model-driven by the same YANG models.
- RESTCONF needs
ip http secure-server.restconfalone is not enough. - A
401means authentication. A404means the URI. Do not confuse them. PUTreplaces;PATCHmerges. PickPATCHfor a one-field change.
Pass check
You are ready when you can do these things:
- Enable
netconf-yangandrestconfon IOS XE with the supporting commands. - Build a RESTCONF URI from a model name and read the JSON reply.
- Read a NETCONF
<get>RPC and say what it asks for. - Map common HTTP response codes to their causes.
- Explain why YANG models matter more than the transport choice.