Example: Using the Wildcard Command with the Range Option

 

Requirements

This example uses the following hardware and software components:

  • M Series, MX Series, T Series or EX Series device

  • Junos OS Release 12.1 or later running on the device

Overview

The range option with the wildcard command enables you to specify ranges in activate, deactivate, delete, protect, set, show, and unprotect commands. You can use ranges to specify a range of interfaces, logical units, VLANs, and other numbered elements. The wildcard range option expands the command you entered into multiple commands, each of which corresponds to one item in the range.

The wildcard range option enables you to configure multiple configuration statements using a single set command, instead of configuring each of them individually. For example, to configure 24 Gigabit Ethernet interfaces with different port numbers, you can use a single wildcard range set command instead of 24 individual set interfaces commands.

Similarly, to deactivate a group of 30 logical interfaces, you can use the wildcard range deactivate command instead of deactivating each logical interface individually.

You can use wildcard range with the active, deactivate, delete, protect, set, show, and unprotect configuration commands:

user@host# wildcard range ?

You can also specify all configuration hierarchy levels and their child configuration statements in the CLI by using wildcard range with the set option:

Configuration

The following examples show how to configure multiple configuration statements in a single step by using the range option with the wildcard configuration command:

Using the Range Option for Configuring a Series of Named Identifiers for a Configuration Statement

Step-by-Step Procedure

You can configure a series of identifiers for a configuration statement, by specifying a numerical range of values for the identifiers.

  • To configure a series of the same type of interface with different port numbers (0 through 23), specify the range for the port numbers by using the following format:

Results

Expands to 24 different set commands to configure interfaces with port numbers ranging from 0 through 23:

Specifying Multiple Ranges in the Syntax

Step-by-Step Procedure

You can have multiple ranges specified in a wildcard range command. Each range must be separated by a comma. You can also have overlapping ranges.

  • To specify more than one range in the syntax, include the minimum and maximum values for each range, separated by a comma.

Results

Expands to the following set commands:

Specifying a Range and Unique Numbers In the Syntax

Step-by-Step Procedure

You can also specify a combination of a range and unique numbers in the syntax of the wildcard range command.

  • To specify a range and unique numbers, separate them with a comma.

Results

Expands to the following set commands:

Excluding Some Values from a Range

Step-by-Step Procedure

You can exclude certain values from a range by marking the numbers or the range of numbers to be excluded by using an exclamation mark.

  • To exclude certain values from a range, include the portion to be excluded with ! in the syntax.

Results

Expands to the following set commands:

Specifying a Range with a Step Number

Step-by-Step Procedure

You can provide a step number for a range to have a constant interval in the range.

  • To provide a step, include the step value in the syntax preceded by a forward slash (/).

Results

Expands to the following set commands:

Verification

Confirm that the configuration is working properly.

Checking the Configuration

Purpose

Check the configuration created using the wildcard range option. The following sample shows output for the configuration described in Using the Range Option for Configuring a Series of Named Identifiers for a Configuration Statement.

Action

user@host> show configuration interfaces

Meaning

The output indicates that 24 Gigabit Ethernet interfaces ranging from ge-0/0/0 through ge-0/0/23 are created.