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 lab> get-config running
nnc lab> getFilters
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 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:
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 lab> get-config running --filter xpath /ietf-interfaces:interfaces
nnc lab> get --filter xpath /ietf-interfaces:interfaces/interface/nameresolve <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 lab> get-config running --with-defaults trim
nnc lab> get-config running --with-defaults report-all-tagged<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 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 lab> edit-config candidate {"ietf-system:system": {"location": "lab"}}
nnc lab> diff
nnc lab> discard-changes
nnc lab> diffEdit 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:
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:
nnc lab> edit-config candidate {"ietf-system:system": {"contact": "x", "@contact": {"ietf-netconf:operation": "remove"}}}
okEdit options
| Option | Values | |
|---|---|---|
--default-operation | merge, replace, none | the operation for elements that don't name one |
--test-option | test-then-set, set, test-only | whether the server validates the edit first, or only validates it (:validate) |
--error-option | stop-on-error, continue-on-error, rollback-on-error | what 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:
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:
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 missingWriting to running
A server with :writable-running takes edits to running directly, with no commit:
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 lab> edit-config candidate {"ietf-system:system": {"location": "rack-3"}}
nnc lab> commit --confirmed --confirm-timeout 120
nnc lab> status
nnc lab> commitconfirmed commit pending: rolls back at 2026-11-14T10:02:00.070Z (in 1m 59s) unless confirmedcancel-commit rolls it back now:
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/locationA 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 lab> lock candidate
nnc lab> monitoring-datastores
nnc lab> unlock candidateA lock held by another session is refused with lock-denied, naming the session that holds it:
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 7kill-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 lab> copy-config candidate runningA 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 lab> copy-config startup running
nnc lab> get-config startup --filter xpath /ietf-system:system
nnc lab> delete-config startupWith :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