Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?


Edit the Configuration Using NETCONF

In a NETCONF session with a device running Junos OS, you can use NETCONF XML management protocol operations along with Junos XML or command-line interface (CLI) configuration statements to change the configuration on a routing, switching, or security platform. The NETCONF protocol operations <copy-config>, <edit-config>, and <discard-changes> offer functionality that is analogous to configuration mode commands in the Junos OS CLI. The Junos XML tag elements described here correspond to Junos OS configuration statements.

To change the configuration on a device, a client application emits the <copy-config>, the <edit-config>, or the <discard-changes> tag element and the corresponding tag subelements within the <rpc> tag element.

The following examples shows the various tag elements available:

The only acceptable value for the <target> element is <candidate/>, which can refer to either the candidate configuration or the open configuration database. If a client application issues the Junos XML protocol <open-configuration> operation to open a specific configuration database before executing a <copy-config> or <edit-config> operation, Junos OS performs the operation on the open configuration database. Otherwise, the operation is performed on the candidate configuration.

The three tags—<copy-config>, <edit-config>, and <discard-changes>—correspond to the three basic configuration tasks available to you, which are described here:

  • Overwriting the target configuration with a new configuration—Using the <copy-config> tag element, you can replace the configuration in the target configuration with a new configuration.

  • Editing configuration elements—Using the <edit-config> tag element, you can add, change, or delete specific configuration elements within the target configuration. To specify how the device should handle configuration changes, see Set the Edit Configuration Mode in a NETCONF Session.

  • Rolling back changes to the current configuration—Using the <discard-changes> tag element, you can roll back the candidate configuration to match the contents of the current running (active) configuration. This tag element provides functionality analogous to the CLI command rollback 0.


    The <discard-changes/> tag element cannot be used to discard uncommitted changes that have been loaded into the ephemeral configuration database.