Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Example: Automatically Configure Logical Interfaces and IP Addresses

Every interface you configure requires at least one logical unit and one IP address. Asynchronous Transfer Mode (ATM) interfaces also require a virtual circuit identifier (VCI) for each logical interface. If you need to configure multiple logical units on an interface, you can use a commit script and macro to complete the task quickly and with no errors.

Requirements

This example uses a device running Junos OS with physical ATM interfaces.

Overview and Commit Script

The following commit script expands an apply-macro statement that provides the name of a physical ATM interface and a set of parameters that specify how to configure a number of logical units on the interface. The units and VCI numbers are numbered sequentially from the unit variable to the max variable and are given IP addresses starting at the address variable. To loop through the logical units, Extensible Stylesheet Language Transformations (XSLT) uses recursion, which is implemented in the <emit-interface> template. Calculation of the next address is performed in the <next-address> template.

The example script is shown in both XSLT and SLAX syntax:

XSLT Syntax

SLAX Syntax

Configuration

Procedure

Step-by-Step Procedure

To download, enable, and run the script:

  1. Copy the script into a text file, name the file atm-logical.xsl or atm-logical.slax as appropriate, and download it to the /var/db/scripts/commit/ directory on the device.

  2. Select the following test configuration stanzas, and press Ctrl+c to copy them to the clipboard.

    If you are using the SLAX version of the script, change the filename at the [edit system scripts commit file] hierarchy level to atm-logical.slax.

  3. In configuration mode, issue the load merge terminal command to merge the stanzas into your device configuration.

    1. At the prompt, paste the contents of the clipboard by using the mouse and the paste icon.

    2. Press Enter.

    3. Press Ctrl+d.

  4. Issue the commit command to commit the configuration.

Verification

Verifying the Configuration

Purpose

Verify that the correct changes are integrated into the configuration.

Action

Before you commit the configuration, you can verify that the commit script will produce the correct results by issuing the show interfaces at-1/2/3 | display commit-scripts configuration mode command. After you commit the configuration, you can review the active configuration by issuing the show configuration interfaces at-1/2/3 operational mode command. The following output appears:

Meaning

The | display commit-scripts option displays the configuration data after all commit scripts have been applied. The output includes both persistent and transient changes. If the appropriate unit and vci are configured on each ATM interface, the commit script executes successfully during a commit operation. After you commit the configuration, you can review the active configuration by issuing the show configuration interfaces at-1/2/3 operational mode command.