Blog Viewer

Scripting How-To: Use local scripts to find open ports across multiple devices

By Erdem posted 08-10-2015 19:25

  

Use Local Scripts to Query Across Devices for Open Ports

 

You can use this script to query one or more devices about port(s) that are open. 
 
The parameter PORTS expects one or more port numbers separated by a comma, for example, 22,23,80. If no port numbers are provided, then the script displays the output you would normally expect to see from a "show system connections" command.
 
This script returns the data in an HTML table format and should be readable in all supported browsers.
 
Select one or more devices from the Device Management view, then execute the script from within the Actions menu.
 
Enter the list of port numbers to search for in the parameter PORTS value field.
 
7.png
 
Once executed, the script will display the results in a table as shown below.
 
8.png
 
If the PORTS parameter value was left empty, you should see results such as the following:
 
9.png

 

Junos Space Script

 

NOTE: This script is not designed to be executed from the CLI, but only from within Junos Space.
001
version 1.1;
002
 
003
/* Junos standard namespaces */
004
ns junos = "http://xml.juniper.net/junos/*/junos";
005
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
006
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
007
 
008
ns str = "http://exslt.org/strings";
009
ns func extension = "http://exslt.org/functions";
010
ns jspace = "http://jspace-utils/asharp@juniper.net";
011
 
012
import "../import/junos.xsl";
013
 
014
/* @ISLOCAL = "true" */
015
/* @CONTEXT = "/device" */
016
/* 

#JunosSpace
#How-To
#opscript
#configlet
#examples
#ScriptingHow-To

Permalink