Skip to content

Configuration ​

Each operation of RFC 6241 is a command of the same name, with its parameters as options. help <command> shows them, and Tab completes them. The examples run against the lab device: Run types a command into the terminal at the bottom of the page.

For changing one value at a time by its YANG path, with the locking and committing done for you, see Paths. This page is the operations themselves.

Reading ​

get-config reads configuration from a datastore, and get reads the running configuration together with state data:

nnc
nnc lab> get-config running
nnc lab> get

Filters ​

A subtree filter selects part of the data. Give it as XML, or as RFC 7951 JSON, which nnc converts with the device's YANG schema:

nnc
nnc lab> get-config running --filter subtree {"ietf-system:system": {}}
nnc lab> get --filter subtree {"openconfig-lldp:lldp": {}}

The XML filter for the same data names the namespace:

Output
nnc lab> get-config running --filter subtree <system xmlns="urn:ietf:params:xml:ns:yang:ietf-system"/>
<system xmlns="urn:ietf:params:xml:ns:yang:ietf-system">
  <contact>tutorial@example.net</contact>
  <hostname>lab1</hostname>
</system>

A server with the :xpath capability, as the lab device has, also takes an XPath filter:

nnc
nnc lab> get-config running --filter xpath /ietf-interfaces:interfaces
nnc lab> get --filter xpath /ietf-interfaces:interfaces/interface/name

resolve <path> shows the subtree filter a YANG path turns into, without sending anything; see Paths.

Default values ​

With the :with-defaults capability (RFC 6243), --with-defaults says how leaves at their default value are reported: report-all, trim, explicit or report-all-tagged. The lab device's basic mode is explicit. An interface's enabled defaults to true, so trim leaves it out of eth0, and report-all-tagged marks it there:

nnc
nnc lab> get-config running --with-defaults trim
nnc lab> get-config running --with-defaults report-all-tagged
Output
<enabled xmlns:ncwd="urn:ietf:params:xml:ns:netconf:default:1.0" ncwd:default="true">true</enabled>

Editing ​

edit-config sends configuration to a datastore: XML, or RFC 7951 JSON. The lab device has a candidate datastore, so edits go there first. diff shows what a commit would change, validate checks it, and commit makes it the running configuration:

nnc
nnc lab> edit-config candidate {"ietf-system:system": {"location": "rack-1"}}
nnc lab> diff
nnc lab> validate candidate
nnc lab> commit
nnc lab> get-config running --filter subtree {"ietf-system:system": {}}

discard-changes throws away what the candidate holds and starts again from running:

nnc
nnc lab> edit-config candidate {"ietf-system:system": {"location": "lab"}}
nnc lab> diff
nnc lab> discard-changes
nnc lab> diff

Edit operations ​

An edit merges by default. Each element can carry its own nc:operation: merge, replace, create, delete or remove. create fails if the node exists, and delete if it doesn't; remove succeeds either way:

Output
nnc lab> edit-config candidate <system xmlns="urn:ietf:params:xml:ns:yang:ietf-system" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><contact nc:operation="delete"/></system>
ok
nnc lab> diff
- delete   /ietf-system:system/contact   tutorial@example.net
1 change (running → candidate)

In JSON, the operation is RFC 7952 metadata on the node:

Output
nnc lab> edit-config candidate {"ietf-system:system": {"contact": "x", "@contact": {"ietf-netconf:operation": "remove"}}}
ok

Edit options ​

OptionValues
--default-operationmerge, replace, nonethe operation for elements that don't name one
--test-optiontest-then-set, set, test-onlywhether the server validates the edit first, or only validates it (:validate)
--error-optionstop-on-error, continue-on-error, rollback-on-errorwhat the server does after an error part-way (rollback-on-error needs :rollback-on-error)

--test-option test-only checks an edit and leaves the datastore as it was:

Output
nnc lab> edit-config candidate {"ietf-system:system": {"location": "x"}} --test-option test-only
ok
nnc lab> diff
no differences (running → candidate)

The server refuses an edit its YANG model doesn't allow, with the path and the rule. An interface without its mandatory type, for example:

Output
nnc lab> edit-config candidate {"ietf-interfaces:interfaces": {"interface": [{"name": "eth9"}]}}
rpc-error: data-missing
  type      application
  severity  error
  path      /ietf-interfaces:interfaces/ietf-interfaces:interface[ietf-interfaces:name='eth9']/ietf-interfaces:type
  message   mandatory leaf type is missing

Writing to running ​

A server with :writable-running takes edits to running directly, with no commit:

nnc
nnc lab> edit-config running {"ietf-system:system": {"location": "rack-2"}}
nnc lab> get-config running --filter subtree {"ietf-system:system": {}}

Confirmed commit ​

commit --confirmed commits for a while only (RFC 6241 §8.4): unless a second commit confirms it in time, the server rolls the change back. That keeps a change that cuts you off from the device from being permanent. status counts down:

nnc
nnc lab> edit-config candidate {"ietf-system:system": {"location": "rack-3"}}
nnc lab> commit --confirmed --confirm-timeout 120
nnc lab> status
nnc lab> commit
Output
confirmed commit  pending: rolls back at 2026-11-14T10:02:00.070Z (in 1m 59s) unless confirmed

cancel-commit rolls it back now:

nnc
nnc lab> edit-config candidate {"ietf-system:system": {"location": "rack-4"}}
nnc lab> commit --confirmed --confirm-timeout 120
nnc lab> cancel-commit
nnc lab> value /ietf-system:system/location

A confirmed commit ends with the session that made it, unless it was given --persist <id>. Then any session can confirm it with commit --persist-id <id>, or cancel it with cancel-commit --persist-id <id>.

Locks ​

lock keeps other sessions from changing a datastore until you unlock it, or your session ends:

nnc
nnc lab> lock candidate
nnc lab> monitoring-datastores
nnc lab> unlock candidate

A lock held by another session is refused with lock-denied, naming the session that holds it:

Output
nnc lab> lock candidate
rpc-error: lock-denied
  type      protocol
  severity  error
  message   The candidate datastore is already locked by session 7
  info      session-id 7

kill-session <id> ends that session, and frees its locks. monitoring-sessions lists the open sessions; see Server data.

Copying and deleting configurations ​

copy-config <target> <source> replaces a whole configuration with another datastore's, or with inline configuration:

nnc
nnc lab> copy-config candidate running

A server with :startup has a startup datastore: the configuration the device loads when it starts. Save the running configuration there, read it, and empty it with delete-config:

nnc
nnc lab> copy-config startup running
nnc lab> get-config startup --filter xpath /ietf-system:system
nnc lab> delete-config startup

With :url, copy-config and delete-config take a URL as source or target. The lab device doesn't have it, so nnc refuses them before sending; see Checked before sending.

Next ​

  • Paths: read and change values by their YANG path
  • Transactions: several changes, committed as one

Released under the MIT Licence.