The Managing Junos Devices using REST API learning byte demonstrates how to manage Junos devices using REST API. Since most programming languages can communicate with REST API , programmers can easily integrate with Junos devices with REST without learning Junos CLI.
The REST API is a "Representational State Transfer" (REST) interface that enables you to securely connect to Juniper Networks Junos operating system (Junos OS) devices, execute remote procedure calls (rpc commands), use a REST API Explorer GUI enabling you to conveniently experiment with any of the REST APIs, and use a variety of formatting and display options, including JavaScript Object Notation (JSON).
The REST API can be configured on Junos OS devices using commands available under the [edit system services rest] hierarchy level. Once configured, the REST API becomes available as the rest service, a REST-based interface that enables you to submit rpc commands to the device from a remote location, and supports GET and POST requests. With the REST API you can:
Use GET requests to submit rpc commands;
Use POST requests to submit information via rpc commands;
Retrieve configuration information in XML, ASCII (plain text), or JSON;
Retrieve operational data in XML, ASCII, or JSON.
Once the REST API is configured on the device, new REST endpoints are available for executing either single rpc commands via GET or POST requests, or executing multiple rpc commands via a single POST request.
Enabling commands on router:
#set system services netconf ssh
#set system services rest enable-explorer
#set system services rest http
OR
#set system service rest https server-certificate REST_CERT
Now you can go to your browser and insert your IP router and your port enabled: (http or https)
http://192.168.0.1:3000
https://192.168.0.1:3443
Open a browser, and go to the following URL: scheme://device-name:port (for example, http://192.168.0.1:3000).
Some other security commands:
set system services rest control allowed-sources [ip-address]
set system services rest http addresses [ip-address]
set system services rest https addresses [ip-address]
set system services rest control connection-limit [number]
set system services rest https server-certificate [name]
set system services rest https cipher-list rsa-with-3des-ede-cbc-sha
set system services rest https mutual-authentication certificate-authority [name]
set system services rest traceoptions flag all
Comments