The NETCONF server communicates with client applications within the context of a NETCONF session. The server and client explicitly establish a connection and session before exchanging data, and close the session and connection when they are finished.
Client applications access the NETCONF server using the SSH protocol and use the standard SSH authentication mechanism. After authentication, the NETCONF server uses the login usernames and classes already configured on the C Series Controller to determine whether a client application is authorized to make each request.
For information about establishing a connection and NETCONF session, see the following sections:
For an example of a complete NETCONF session, see Example of a NETCONF Session.
Each set of NETCONF and XML tag elements emitted by the NETCONF server and a client application within a <hello>, <rpc>, or <rpc-reply> tag element must constitute a well-formed XML document by obeying the structural rules defined in the document type definition (DTD) for the kind of information being sent. The client application must emit tag elements in the required order and only in the allowed contexts.
The NETCONF server and client applications must also comply with RFC 4742, Using the NETCONF Configuration Protocol over Secure Shell (SSH), available at http://www.ietf.org/rfc/rfc4742.txt. In particular, the server and applications must send the character sequence ]]>]]> after each XML document. This sequence is not legal within an XML document and so unambiguously signals the end of a document. In practice, the client application sends the sequence after the closing </hello> tag and each closing </rpc> tag, and the NETCONF server sends it after the closing </hello> tag and each closing </rpc-reply> tag.
![]() |
Note: In the following example (and in all examples in this document of tag elements emitted by a client application), bold font is used to highlight the part of the tag sequence that is discussed in the text. |
<!- - generated by a client application - ->
<hello | rpc>
<!-contents of top-level tag element - ->
</hello | /rpc>
]]>]]>
<!- - generated by the NETCONF server - ->
<hello | rpc-reply attributes>
<!- - contents of top-level tag element - ->
</hello | /rpc-reply>
]]>]]>
To enable a client application to establish an SSH connection to the NETCONF server, you must satisfy the requirements discussed in the following sections:
The client application must be able to access the SSH software on the computer where it runs.
If the application uses the NETCONF Perl module provided by Juniper Networks, no further action is necessary. As part of the installation procedure for the Perl module, you install a prerequisites package that includes the necessary SSH software.
If the application does not use the NETCONF Perl module, obtain the SSH software and install it on the computer where the application runs. For information about obtaining and installing SSH software, see http://www.ssh.com and http://www.openssh.com.
The client application must be able to log in to each C Series Controller on which it establishes NETCONF sessions. The following instructions explain how to create a login account for the application. Alternatively, you can skip this section and enable authentication through RADIUS or TACACS+. For instructions, see SRC PE Getting Started Guide.
To determine if a login account exists, enter SRC command-line interface (CLI) configuration mode on the C Series Controller and issue the following commands:
If the appropriate account does not exist, perform the following steps:
For a client application to authenticate with the NETCONF server, the login account that you created in Client Application Can Log In on C Series Controllers must have an SSH public/private key pair, a text-based password, or both. A public/private key pair is sufficient if the account is used only to connect to the NETCONF server through SSH. If the account is also used to access the C Series Controller in other ways (for login on the console, for example), it must have a text-based password. The password is also used (the SSH server prompts for it) if key-based authentication is configured but fails.
![]() |
Note: You can skip this section if you have chosen to enable authentication through RADIUS or TACACS+, as described in SRC PE Getting Started Guide. |
Follow the instructions in the appropriate section:
To create a text-based password, perform the following steps:
To enter a password as text, issue the following command. You are prompted for the password, which is encrypted before being stored.
- [edit system login user user-name authentication]
- user@host# set plain-text-password
- New password: password
- Retype new password: password
To store a password that you have previously created and hashed using Message Digest 5 (MD5) or Secure Hash Algorithm 1 (SHA-1), issue the following command:
To create an SSH public/private key pair, perform the following steps:
- [edit system login user user-name authentication]
- user@host# set ssh-authorized-keys [ssh-authorized-keys...]
The ssh-keygen command by default stores each public key in a file in the ssh subdirectory of the user home directory; the filename depends on the encoding (DSA or RSA) and SSH version. For more information about configuring SSH authentication, see SRC PE Getting Started Guide.
The client application must be able to access the public/private keys or password you created in Login Account Has Public/Private Key Pair or Password and provide it when the NETCONF server prompts for it.
There are several methods for enabling the application to access the key or password:
The IETF draft titled Using the NETCONF Configuration Protocol over Secure Shell (SSH) requires that the NETCONF server by default provide SSH access to client machines over a devoted Transmission Control Protocol (TCP) port, to make it easy to identify and filter NETCONF traffic. The port for the SRC NETCONF server is 32000. In addition, you can enable client applications to access the NETCONF server over the default SSH port (22). (For more information about the IETF draft, see Generating Well-Formed XML Documents.)
Perform the following steps:
Before a client application can connect to the NETCONF server, you must satisfy the requirements described in Prerequisites for Establishing a Connection.
When the prerequisites are satisfied, applications written in Perl use the NETCONF Perl module to connect to the NETCONF server. A client application that does not use the NETCONF Perl module uses one of two methods:
The -p option defines the port number on which the NETCONF server listens. This option can be omitted if you enabled access to SSH over the default port in NETCONF Service over SSH Is Enabled.
The -s option establishes the NETCONF session as an SSH subsystem.
The application must include code to intercept the NETCONF server’s prompt for the password or passphrase. Perhaps the most straightforward method is for the application to use a utility such as the expect command. The NETCONF Perl client uses this method, for example.
Each NETCONF session begins with a handshake in which the NETCONF server and the client application specify the NETCONF capabilities they support. The following sections describe how to start a NETCONF session:
The NETCONF server and client application each begin by emitting a <hello> tag element to specify which operations, or capabilities, they support from among those defined in the NETCONF specification. The <hello> tag element encloses the <capabilities> tag element and the <session-id> tag element, which specifies the process ID (PID) of the NETCONF server for the session. Within the <capabilities> tag element, a <capability> tag element specifies each supported function.
The client application must emit the <hello> tag element before any other tag element during the NETCONF session, and must not emit it more than once.
Each capability defined in the NETCONF specification is represented in a tag element by a uniform resource name (URN). Capabilities defined by individual vendors are represented by uniform resource identifiers (URIs), which can be URNs or URLs. The NETCONF API for SRC emits the following<hello> tag element (each<capability> tag element appears on three lines for legibility only):
<hello>
<capabilities>
<capability>urn:ietf:params:xml:ns:netconf:base:1.0</capability>
<capability>
urn:ietf:params:xml:ns:netconf:capability:candidate:1.0
</capability>
<capability>
urn:ietf:params:xml:ns:netconf:capability:url:1.0?protocol=http,ftp,file
</capability>
<capability>http://xml.juniper.net/netconf/junos/1.0</capability>
<capability>http://xml.juniper.net/netconf/junos/sdx/1.0</capability>
</capabilities>
<session-id>3911</session-id>
</hello>
]]>]]>
(For information about the ]]>]]> character sequence, see Generating Well-Formed XML Documents.)
The URIs in the <hello> tag element indicate the following supported capabilities:
To comply with the NETCONF specification, the client application also emits a <hello> tag element to define the capabilities it supports. It does not include the <session-id> tag element:
<hello>
<capabilities>
<capability>first-capability</capability>
<!- - tag elements for additional capabilities - ->
</capabilities>
</hello>
]]>]]>
Exchanging <hello> tag elements enables a client application and the NETCONF server to determine if they support the same capabilities. In addition, we recommend that the client application determine the version of the SRC software running on the NETCONF server. After emitting its<hello> tag element, it emits the <get-system-info> tag element in an <rpc> tag element:
The NETCONF server returns the <system-info> tag element, which encloses the <system-identification> and <software-version> tag elements. (For information about the <rpc-reply> tag element, see Parsing the NETCONF Server Response.) Some tag elements appear on multiple lines, for legibility only:
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" \
xmlns:sdx="http://xml.juniper.net/junos/sdx/1.0">
<system-info>
<system-identification>
<software-version>SRC Release 2.0.0</software-version>
<!- - other <system-identification> child tag elements - ->
</system-identification>
<!- - other <system-info> child tag elements - ->
</system-info>
</rpc-reply>
]]>]]>
Normally, the version is the same for all SRC software components running on the C Series Controller. (We recommend this configuration for predictable performance.) The client application can determine the version of the SRC software components running on the NETCONF server by emitting the <get-component-all> tag element in an<rpc> tag element:
The NETCONF server returns the <sdx-component-list> tag element, which encloses the <sdx-component> tag elements plus a <version> tag element for each installed SRC software component. (For information about the <rpc-reply> tag element, see Parsing the NETCONF Server Response.) The <version> tag element within the <sdx-component> tag element specifies the SRC release number (in the following example, 2.0 for SRC Release 2.0) and the build information. Some tag elements appear on multiple lines, for legibility only:
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" \
xmlns:sdx="http://xml.juniper.net/junos/sdx/1.0">
<sdx-component-list>
<sdx-component>
<status>stopped</status>
<version>Release: 2.0 Build: ACP.B.2.0.0.001</version>
<name>acp</name>
</sdx-component>
<!- - other <sdx-component> tag elements - ->
<sdx-component>
<status>running</status>
<version>Release: 2.0 Build: WEBADM.B.2.0.0.001</version>
<name>webadm</name>
</sdx-component>
</sdx-component-list>
</rpc-reply>
]]>]]>
In the NETCONF API for SRC, it is the responsibility of the client application to determine how to handle any differences in version or capabilities. For fully automated performance, include code in the client application that determines whether it supports the same capabilities and SRC version as the NETCONF server. Decide which of the following options is appropriate when there are differences, and implement the corresponding response: