Working with IP addresses
In this recipe, we'll build on our original op script, show-int.slax
, and enhance its functionality so that it can limit the output based on characteristics of the interface. In this case, it will allow the user to nominate an IP address range in the CIDR notation, for example 8.0.0.0/24
, and will then restrict its output to interfaces associated with that address range.
Getting ready
In order to complete this recipe, you'll need access to a JUNOS router running with a varied set of network interfaces for different addresses.
How to do it...
We're going to write a SLAX script to call the interface information RPC and then filter the output based upon the IP address. Save the code in a file called show-int-ipaddr.slax
, or similar.
The steps for the recipe are as follows:
- Start with the usual SLAX boilerplater which defines namespaces and versions:
version 1.0; ns junos = "http://xml.juniper.net/junos/*/junos"; ns xnm = "http://xml.juniper.net/xnm/1.1/xnm...