Skip to main content
Back to Blog
Datacenter

NETCONF vs RESTCONF: Which Protocol to Choose

November 202614 min read
Engineer testing configuration on a network switch

NETCONF and RESTCONF allow clients to perform read and write operations against the configuration and state of a device, as specified by one or more YANG models. While there are similarities, they vary significantly in terms of transport layer, transactionality and applicability. NETCONF transmits XML over a persistent, secured channel, usually SSH, and allows for global transactions, locks and a candidate datastore. RESTCONF provides equivalent access via HTTP(S), returning XML or JSON. It is therefore ideal if you have existing systems or applications built around the HTTP protocol. However, there is no support for transactions, so every update will be applied live to the device. As such, NETCONF is the preferred option for programming network devices. RESTCONF is well suited to web-based consoles, portals and north-bound connections to orchestration platforms.

As mentioned above, the comparison between NETCONF and RESTCONF does not lend itself to a clear-cut conclusion as to which should be adopted. Rather, it comes down to the point in your solution where you want to make a device call, the extent of the target set of devices and how to deal with errors and failures. The following article aims to provide the key information needed by DC and other Critical Infrastructure practitioners.

PODTECH

Connect Infrastructure Data With Custom Software

PODTECH develops bespoke IT and system integration products for mission-critical industries, from Data Centers to Smart Buildings.

Visit

TL;DR

  • NETCONF (RFC 6241) is a management protocol based on XML RPC messages exchanged within a long-lived, authenticated channel, most commonly SSH. NETCONF also facilitates global transactions, lock management and a candidate datastore.
  • RESTCONF (RFC 8040) enables equivalent reads and writes to YANG-modeled data using standard HTTP verbs. Data is returned as XML or JSON, transmitted securely via HTTPS.
  • Each protocol leverages YANG, so neither can claim superiority in terms of the data they can represent. They serve complementary roles.
  • NETCONF is best deployed to configure devices. RESTCONF is best deployed where there is significant reliance on HTTP-based toolsets.
  • In practice, you may see a combination of NETCONF and RESTCONF in the same environment, for example downstream and upstream of an orchestrator respectively.

Table of Contents

What NETCONF and RESTCONF actually are

Historically, SNMP was the principal means of querying devices, although it was limited in its ability to safely program device configurations. You may continue to use SNMP for data collection purposes, in which case please see our Glossary. NETCONF and RESTCONF fill this gap.

NETCONF was formalized by the IETF and, per Cisco's response to frequently asked questions regarding their product, involves sending XML-based RPCs to a device via a long-lived, encrypted channel, typically SSH. For Cisco IOS-XE, this will be on TCP port 830, addressing another frequently-asked question. A number of fundamental functions can be performed using NETCONF: get, get-config, edit-config, copy-config, delete-config, lock, unlock, close-session and kill-session.

RESTCONF was introduced in RFC 8040 in Jan 2017, to provide an interface to NETCONF-like datastores defined in YANG, exposed via the HTTP protocol. Data may be returned as either XML or JSON. As noted in the Cisco FAQ, it appears the general consensus is that NETCONF is best applied to NMS and Controller-type systems, whereas RESTCONF can be used in more opportunistic cases.

Underpinning both of these protocols is the data modelling specification known as YANG. YANG is not itself a protocol, but rather sets out the configuration parameters and attributes available from a given device. The IETF NETCONF working group endorses the use of YANG 1.1, as defined in RFC 7950, for NETCONF and RESTCONF. Since the two protocols will rely on identical data models, any particular piece of information or configuration will be equally accessible. Therefore, the discussion here is focused solely on the transport and other differentiating features.

An additional note: although RESTCONF draws heavily upon REST principles, it is not simply a REST API. Its URIs, content-types and contents are all constrained by the relevant YANG model or models. Consequently, RESTCONF and a free-form REST API will share some common characteristics but remain distinct. Furthermore, RFC 8040 makes clear that RESTCONF is not meant to supersede NETCONF.

NETCONF vs RESTCONF side by side

CriterionNETCONFRESTCONF
StandardRFC 6241RFC 8040
TransportSSH (port 830 for Cisco IOS-XE) / TLSTLS / HTTPS (default port 443)
Data formatXMLJSON or XML
Verbsget, get-config, edit-config, ...GET, POST, PUT, PATCH, DELETE
Connection typePersistentStateless
LockingYesNo
Candidate datastoreYes, subject to device capabilityN/A, updates are live
TransactionsYesNo
Suitable forProgramming Network DevicesWeb portals, consoles, North-bound API

References: Cisco FAQ, RFC 8040 and InformIT.

Transport, ports and data formats

NETCONF has historically been transported over SSH. You will have existing mechanisms in place, such as SSH keys, jump boxes and firewall rules, and a long-lived connection established as long as the NETCONF session is active. It may additionally be run over a TLS connection.

As mentioned above, RESTCONF is purely based on the HTTP protocol. Per RFC 8040, a RESTCONF server MUST implement TLS and it is prohibited to expose RESTCONF over unencrypted HTTP. Therefore, servers must accept connections using the https URI with its IANA-assigned default port 443 and offer an X.509v3 certificate. Ideally, clients will authenticate using TLS client certificates and HTTP authentication mechanisms can be used as a last resort. Existing infrastructure supporting TLS and APIs will benefit from this.

NETCONF relies on an XML message format. As discussed earlier, RESTCONF allows JSON or XML messages. It is the former that leads many programmers to feel at home with RESTCONF.

A further similarity is that both NETCONF and RESTCONF define a Call Home option in RFC 8071, whereby the network element connects out to the management plane. Both allow this, but note that as discussed above, only the TLS transport is permitted for RESTCONF. This can be a significant factor depending on your network environment.

Mapping HTTP verbs to NETCONF actions

A useful summary is provided in the Cisco FAQ for translating the action set available via each protocol:

  • GET -> get, get-config
  • POST -> create or perform an RPC
  • PUT -> modify (replace) or create-and-replace
  • PATCH -> perform any action contingent upon the data in the PATCH

Once familiar with RESTful APIs, you should quickly appreciate this set of equivalences. Equally, if you know NETCONF well, you can see the gaps in RESTCONF.

Transactions

It's here that we hit the key differentiator.

An InformIT article discussing Data Model Driven Management describes how NETCONF transactions satisfy the ACID requirements: Atomicity, Consistency, Independence, Durability. In particular, it contrasts this to the limitations of SNMP. Clients are further able to acquire a lock on a datastore and build up a proposed configuration, candidate, before validating and committing.

In contrast, the InformIT article states that RESTCONF does not support multiple requests to comprise a transaction. Rather, each individual request is considered a separate transaction, and no provision exists to test a change prior to applying it. Consistent with this, RFC 8040 notes that RESTCONF does not support all features of NETCONF, in particular the existence of multiple datastores and datastore locks. In turn, the Cisco White Paper on Programmability of the Nexus 9000 series states that RESTCONF only supports interaction with the running config datastore.

NETCONFRESTCONFstaged, validated, committedrequest-by-request live updatesLockCandidateValidateCommit / RevertCall 1Call 2Call 3Call 27 failsAtomic workflow with lock, validation and controlled commitPartial success requires external rollback logic

Example scenario

Imagine you want to push a set of changes to a routing feature across 40 nodes as part of a service update. Using NETCONF, the orchestration platform would establish multiple connections, take out locks, populate the candidate datastore, verify the change has been applied correctly to all nodes and finally commit, or revert. In the case of RESTCONF, 40 distinct calls would need to be issued. Provided the 27th call is unsuccessful, your implementation would need to identify that the preceding 26 calls had completed successfully and reverse those actions. Benoît Claise, co-author of the InformIT piece, reiterates this observation in his Netconf vs. RestConf article, noting that although a single, atomic RESTCONF call may suffice as a north-bound API, it is not suitable to configure services onto network nodes. Of course, in the trivial case of updating a single node with a single, self-contained operation, there is nothing wrong with using RESTCONF.

Errors and other issues

Per RFC 8040, errors returned by RESTCONF conform to the HTTP specification, i.e. the relevant status code will be returned along with a body of type application/problem+json containing the attributes: error-type, error-tag, error-path and error-message. Again, your current solutions to monitor, proxy and log HTTP traffic can readily parse and act on these.

NETCONF communicates errors within the XML response to an RPC. Furthermore, given the persistent nature of the NETCONF connection, additional considerations will be required around the lifecycle of the connection. As noted previously, a mechanism, kill-session, is therefore defined to release any locks that may remain if a NETCONF session terminates abnormally.

Finally, we can consider the similarities and differences around security. Assuming correct deployment, both will require a secure channel, SSH or TLS. The following points highlight some areas that may warrant further investigation:

  • Credential handling: How will you store and deploy the requisite keys and credentials, for example SSH and AAA versus certificates and API access?
  • Network policy: Can your current network fabric accommodate the additional ports required, such as 443 versus 830?
  • Authorization scope: As always, you will want to restrict users and their permissions to the required data models and RPCs.

Regardless of the protocol or protocols employed, equivalent care should be taken when enabling any form of remote access. As described in our article on remote monitoring using identity controls, there are a set of principles that we adopt within our IT and OT solutions.

NETCONF vs RESTCONF

An excellent starting point is provided by the InformIT book, written by Benoît Claise, Joe Clarke and Jan Lindblad. Their advice is straightforward: if you are free to pick between the two, and not limited by other systems in your stack, NETCONF is the preferred mechanism to make changes to network equipment. Of course, RESTCONF has its place as a north-bound interface to orchestration and control systems. In practice, the decision will likely come down to ease of fit with, and reduced TCO of, a predominantly HTTP-based toolset.

NETCONF is appropriate when:

  • A transaction needs to be applied to multiple devices, and should either apply in full or revert entirely.
  • There is a requirement to pre-validate proposed changes and or facilitate reversion.
  • The orchestration or control system will drive changes to, and manage the life cycle of, the network.
  • Device-level lock mechanisms are desired.

RESTCONF is appropriate when:

  • The network team and associated systems are familiar with, and can leverage, the HTTP ecosystem.
  • You wish to present information from the network to external parties, for example via web portals and consumer-facing applications.
  • Individual changes will be isolated to single devices and therefore inherently self-contained.
  • You require a drop-in interface to a specific piece of equipment.

There's also another protocol worth noting. As set out in various whitepapers and articles from Cisco, gNMI forms part of the current suite of Model Driven Networking options. In a blog post dated Dec 2019, Cisco outline that IOS-XE, IOS-XR and NX-OS each provide NETCONF over YANG; IOS-XE and NX-OS additionally offer RESTCONF; and IOS-XR is enabled for gNMI. As always, you will need to check the capabilities of your target equipment.

Combining the two

Because both protocols are driven by YANG, they are well suited to being used in tandem. A typical deployment would involve:

  1. NETCONF being used by an orchestration or control layer to effect, and manage, changes to the south.
  2. The orchestration or control layer presenting, via RESTCONF or a RESTful interface, relevant data to north-bound consumers such as ticketing and self-service platforms.
  3. Network state and telemetry being aggregated to a suitable monitoring solution for reporting, performance and event management.

By splitting responsibilities in this manner, you gain the benefits of NETCONF's robustness while still taking advantage of the ubiquity of HTTP.

Implications for DC and high-assurance sites

As noted above, there are almost invariably other systems in a datacentre that will need to exchange data with the network. These may include but are not limited to: BMS, PMS, NMS, HVAC and general telemetry. All will utilise their respective protocol or protocols, so consideration needs to be given to how these can be harmonised.

A few thoughts:

  • Select the most appropriate protocol for the task at hand. There is no one size fits all approach.
  • Where feasible, aim to adopt common YANG-defined data models. This will help limit the volume of bespoke model translations required.
  • Account for failure scenarios where the orchestration or control system fails to correctly validate and execute a sequence of RESTCONF-based updates spanning multiple devices.
  • Recognise that these protocols transport significant privilege within your site. Security and audit should be integral to your approach.
  • Consider the broader context of how the network will interact with the other disciplines, BMS, PMS and so on. See our BMS and PMS Integration service for further information.

Similarly, if deploying automated systems in the wider industrial and smart-building sectors, a coordinated strategy around protocols, security and interoperability will be key. For guidance on establishing these types of environments, see our step-by-step guide to implementing industrial automation, and how telemetry can be utilized to inform and improve building management via our Smart Buildings offering.

Final considerations

Once a protocol, or combination of protocols, has been identified, the real challenge lies in developing the suite of supporting software and processes. This will include the automation functions required to perform the desired activities, interfaces to harmonize with the BMS, PMS and NMS, telemetry aggregation and end-user consoles.

PODTECH specialize in designing and supplying bespoke software solutions to support these requirements. From our Enterprise Automation and Telemetry offerings, through to our Master Systems Integrations, we have supported more than 250 implementations to date and maintain a 99.9% guaranteed availability offering backed by worldwide support. Please contact our Data Centre Services team to discuss your requirements.

Finally, for edge-based telemetry, we offer the A1 Controller and a wide array of complementary products as detailed on our Products page.

Our perspective

Our view?

Rather than focusing on whether NETCONF or RESTCONF is better, the focus for our customers is typically on the connectivity required and the business impact of a misapplied change. In high-assurance deployments, the consequence of an errant update is almost invariably significant disruption. Accordingly, our development of these solutions is motivated by this concern, i.e. if a change is only successfully executed against a subset of devices, how will this be detected and remediated?

Secondly, the network is only one component of a site's infrastructure. There will be multiple disciplines reporting back: electrical, plant, building and of course the network. By integrating BMS, PMS and NMS, we aim to provide a single pane of glass and consistent means of controlling the site. It's important that any protocol chosen for one system doesn't leave gaps elsewhere.

Finally, protocols will inevitably change. We create bespoke solutions to allow this flexibility and growth, enabling our customers' automation to evolve as new protocols emerge and take hold. The software is therefore key to avoiding disruption.

Should you be considering a range of protocols for your automation requirement, we would welcome the opportunity to discuss the relevant assets. From there we can develop a solution to tie them all together.

Harry

FAQ

What is the difference between NETCONF and YANG?

YANG provides a framework to define the configuration and running data available from a piece of equipment. NETCONF is one of the protocols which can access this information, and RESTCONF is another. In effect, the data model defines the parameters, while the protocol determines the mechanism to send the commands to the target.

Which protocols are compatible with YANG?

NETCONF, RFC 6241, and RESTCONF, RFC 8040. The current recommendation from the IETF NETCONF WG is to utilise YANG version 1.1. Additionally, some vendors have implemented support for gNMI and YANG. You should therefore investigate the supported options on your equipment.

Why would I need to open port 830?

Port 830 allows NETCONF to execute actions via an underlying SSH session, per Cisco's FAQ for IOS XE. If you choose to implement RESTCONF, you would require port 443, IANA assigned per RFC 8040. Appropriate firewall rules should then be applied.

Does RESTCONF mean that my system will have a RESTful API?

While RESTCONF draws heavily on REST principles and communicates using standard HTTP verbs and typically JSON or XML, it is constrained by the YANG data model or models and specified in RFC 8040. As such, it retains compatibility with NETCONF.

Can I still run NETCONF if I want to utilise RESTCONF?

Absolutely. Both draw on the same set of, typically, vendor-specific YANG models, and in some instances it may be desirable to exploit NETCONF for device programming and expose RESTCONF to upstream consumers. They are complementary rather than mutually exclusive.

Sources