7 Replies Latest reply on Oct 22, 2018 4:23 AM by rfroembgen

    Mass Config Change - Updating mask on all devices

    jreichers

      The day has come where I need to expand our management subnet which means I need to update the mask on all our network devices.

       

      The hurdle I need to overcome is being able to use output from the device as a variable to change configuration.

       

      This is on Cisco IOS and Cisco NXOS. The command is pretty simple in concept:

       

           sh run int vlan 1000 (nxos: show run int mgmt0)

       

           int {interface}

           ip add {ip address from above output} 255.255.255.128 (nxos: /25)

       

      The trick is A: being able to store that output while the script is running, and B: to parse the IP address out of the output into a variable, and C: being able to call that variable into the running script.

        • Re: Mass Config Change - Updating mask on all devices
          rfroembgen

          Hi,

           

          if the IP address of the affected devices is like the interface ip, the following script could help you out:

           

          (Only tested it on a IOS-device)

           

          /*

          .CHANGE_TEMPLATE_DESCRIPTION

           

           

          .CHANGE_TEMPLATE_TAGS

                  Cisco, Nexus, NX-OS

          .PLATFORM_DESCRIPTION

                  Cisco IOS, NEXUS

           

          .PARAMETER_LABEL @ContextNode

                  NCM Node

          .PARAMETER_DESCRIPTION @ContextNode

                  The node the template will operate on.  All templates require this by default. The target node is selected during the first part of the wizard so it will not be available for selection when defining values of variables.

           

          */

           

           

          script UpdateNetMask  (

                                                   NCM.Nodes @ContextNode       )

          {

            // Only select Cisco devices

            foreach ( @node in @ContextNode )

            {

               if ( @node.SysDescr Contains 'NX-OS(tm) n' )

          //ONLY SELECT NX-OS DEVICES

              {

              // Set or update NEXUS Emergency User and Password

                CLI

                {

          configure terminal

          interface mgmt0

          ip add @node.AgentIP/25

                }

           

           

              }

               if (@node.SysDescr contains 'IOS' )

          // ONLY SELECT IOS DEVICES

              {

                // Enter configuration mode

                CLI

                {

          configure terminal

          interface vlan 1000

          ip add @node.AgentIP 255.255.255.128

                }

           

                CLI

                {

          exit

          copy run start

          startup-config

                }

              }

            }

          }

           

           

          An example output would look like:

           

          configure terminal

          interface vlan 1000

          ip add 1.1.1.1 255.255.255.128

          exit

          copy run start

          startup-config

           

          Regards

          Rene