O'Reilly logo

JUNOS Automation Cookbook by Adam Chappell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. 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";      ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";      import "../import/junos.xsl";
  1. Declare an op script parameter called subnet and default this to the string 0/0—an acceptable abbreviation for the IPv4 default route, meaning all addresses:
        param $subnet="0/0";        var $arguments = {             <argument> { <name> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required