Network Assurance · Topic 7 of 7
NETCONF and RESTCONF
Configure and verify NETCONF and RESTCONF on IOS XE: ports, transport, datastores, operations, HTTP methods, YANG data paths and enabling commands.
- 5 min
- Includes a diagram
- NETCONF uses XML over SSH on port 830. RESTCONF uses HTTPS.
- Both use YANG data models.
- NETCONF operations include
get,get-config,edit-config,lockandcommit.
What it is
NETCONF and RESTCONF are standard protocols that let software configure and read a network device using YANG data models.
The command line is made for people, and scripts that parse it break easily.
These protocols give programs a structured and predictable way to work. NETCONF is the older of the two, and it uses XML over SSH. RESTCONF gives a REST style interface over HTTPS, and it uses JSON or XML.
How it works
Both protocols read and write the same data models, with different transports.
NETCONF
NETCONF is defined in RFC 6241. It runs over SSH, and the standard port is 830. The messages are XML, and the protocol is built on remote procedure calls.
A session starts with a hello exchange. Each side sends the capabilities it supports, and these include the YANG models that the device offers.
NETCONF works with named stores of configuration, called datastores.
| Datastore | Meaning |
|---|---|
| Running | The active configuration |
| Startup | The configuration that loads at boot, where the device supports it |
| Candidate | A working copy that you edit and then commit, where the device supports it |
The main operations are:
| Operation | Purpose |
|---|---|
get | Read configuration and operational data |
get-config | Read configuration from a datastore |
edit-config | Change configuration |
copy-config | Copy one datastore to another |
delete-config | Delete a datastore |
lock and unlock | Stop others changing a datastore while you work |
commit | Apply a candidate datastore |
A change can be sent as a single transaction. When the client asks for rollback on error, a failed change is rejected as a whole, so the device is not left half configured.
Enabling NETCONF on IOS XE
Router(config)# username admin privilege 15 secret PASSWORD
Router(config)# aaa new-model
Router(config)# aaa authentication login default local
Router(config)# aaa authorization exec default local
Router(config)# netconf-yang
Router# show netconf-yang sessions
The command netconf-yang starts the NETCONF server on port 830. Authentication and authorisation are needed, since the session uses the device credentials. show netconf-yang sessions lists the active sessions.
A client connects with SSH to port 830 and asks for the netconf subsystem. Tools and libraries such as the Python library ncclient do this for you.
RESTCONF
RESTCONF is defined in RFC 8040. It maps NETCONF ideas onto HTTP. It uses HTTPS, and the device exposes the data under a path that starts with /restconf.
| HTTP method | Action |
|---|---|
| GET | Read data |
| POST | Create a new resource |
| PUT | Replace a resource |
| PATCH | Merge a change into a resource |
| DELETE | Remove a resource |
The data format is set by headers. The media types are application/yang-data+json and application/yang-data+xml. Use the Accept header to say what you want back, and Content-Type to say what you send.
GET /restconf/data/ietf-interfaces:interfaces HTTP/1.1
Host: 10.1.1.1
Accept: application/yang-data+json
The path names the YANG module, then the container. A reply looks like this:
{
"ietf-interfaces:interfaces": {
"interface": [
{
"name": "GigabitEthernet1",
"type": "iana-if-type:ethernetCsmacd",
"enabled": true
}
]
}
}
Enabling RESTCONF on IOS XE
Router(config)# restconf
Router(config)# ip http secure-server
Router(config)# ip http authentication local
Router# show platform software yang-management process
RESTCONF depends on the secure HTTP server, so it must be on. The user credentials are sent with HTTP basic authentication, and that is why the transport must be HTTPS. The last command shows whether the processes behind NETCONF and RESTCONF are running.
NETCONF compared with RESTCONF

| Feature | NETCONF | RESTCONF |
|---|---|---|
| Transport | SSH, port 830 | HTTPS, port 443 |
| Encoding | XML | JSON or XML |
| Style | Remote procedure calls | REST, with HTTP methods |
| Transactions | Datastores, lock and commit | Each request is its own operation |
| Standard | RFC 6241 | RFC 8040 |
Checking the setup
If a client cannot connect, work through these checks:
- Is the feature enabled, and are the processes running?
- Does the device accept SSH or HTTPS from the client address?
- Do the credentials work, and does the user have privilege 15?
- Does the data path name a YANG module that the device supports?
What to remember for the exam
Eight facts cover most questions on this topic.
- NETCONF uses XML over SSH on port 830. RESTCONF uses HTTPS.
- Both use YANG data models.
- NETCONF operations include
get,get-config,edit-config,lockandcommit. - NETCONF datastores are running, startup and candidate.
- RESTCONF uses GET, POST, PUT, PATCH and DELETE.
- RESTCONF data paths start with
/restconf/data. netconf-yangenables NETCONF on IOS XE.restconfenables RESTCONF.- RESTCONF needs
ip http secure-server.
If a question mentions XML and port 830, the answer is NETCONF. If it mentions HTTP methods and JSON, the answer is RESTCONF.
Common mistakes
These four mistakes appear often.
Forgetting the secure HTTP server for RESTCONF. The restconf command alone does not give you a working HTTPS service.
Using HTTP methods with NETCONF. NETCONF uses its own operations, not GET and PUT.
Skipping authentication setup. Without a valid user, the session is refused.
Mixing up PUT and PATCH. PUT replaces a resource, and PATCH merges a change.
Do not send credentials over plain HTTP. Use HTTPS for RESTCONF and SSH for NETCONF.
Check yourself
Work through these three questions.
Which port does NETCONF use, and over which transport?
NETCONF uses port 830 over SSH.
Which two commands are needed on IOS XE before RESTCONF works?
restconfandip http secure-server, plus working authentication.What is the difference between PUT and PATCH in RESTCONF?
PUT replaces a resource, and PATCH merges a change into it.
Topic 7 of 7 in Network Assurance
Test yourself on Network Assurance
The full Cisco CCNP 350-401 ENCOR question bank has 854 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Cisco. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.