Supported Platforms
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 ?
Possible completions: activate Remove the inactive tag from a statement deactivate Add the inactive tag to a statement delete Delete a data element protect Protect the statement set Set a parameter show Show a parameter unprotect Unprotect the statement
You can also specify all configuration hierarchy levels and their child configuration statements in the CLI by using wildcard range with the set option:
Possible completions:
> > access Network access configuration
> > access-profile Access profile for this instance
> > accounting-options Accounting data configuration
> > applications Define applications by protocol characteristics
...
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
Specifying Multiple Ranges in the Syntax
Specifying a Range and Unique Numbers In the Syntax
Excluding Some Values from a Range
Specifying a Range with a Step Number
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:
[edit]user@host# wildcard range set interfaces ge-0/0/[0-23] unit 0 family vpls
Results
Expands to 24 different set commands to
configure interfaces with port numbers ranging from 0 through 23:
[edit]user@host# set interfaces ge-0/0/0 unit 0 family vplsuser@host# set interfaces ge-0/0/1 unit 0 family vplsuser@host# set interfaces ge-0/0/2 unit 0 family vpls...user@host# set interfaces ge-0/0/23 unit 0 family vpls
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.
[edit]user@host# wildcard range protect event-options policy p[1-3,5-7,6-9]
Results
Expands to the following set commands:
[edit]user@host# set protect event-options policy p1user@host# set protect event-options policy p2user@host# set protect event-options policy p3user@host# set protect event-options policy p5user@host# set protect event-options policy p6user@host# set protect event-options policy p7user@host# set protect event-options policy p8user@host# set protect event-options policy p9
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.
[edit]user@host# wildcard range protect event-options policy p[1-3,5,7,10]
Results
Expands to the following set commands:
[edit]user@host# set protect event-options policy p1user@host# set protect event-options policy p2user@host# set protect event-options policy p3user@host# set protect event-options policy p5user@host# set protect event-options policy p7user@host# set protect event-options policy p10
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.
[edit]user@host# wildcard range protect event-options policy p[1-5,!3-4]
Results
Expands to the following set commands:
[edit]user@host# set protect event-options policy p1user@host# set protect event-options policy p2user@host# set protect event-options policy p5
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 (/).
[edit]user@host# wildcard range protect event-options policy p[1-10/2]
Results
Expands to the following set commands:
[edit]user@host# set protect event-options policy p1user@host# set protect event-options policy p3user@host# set protect event-options policy p5user@host# set protect event-options policy p7user@host# set protect event-options policy p9
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
ge-0/0/0 {
unit 0 {
family vpls;
}
}
ge-0/0/1 {
unit 0 {
family vpls;
}
}
ge-0/0/2 {
unit 0 {
family vpls;
}
}
ge-0/0/3 {
unit 0 {
family vpls;
}
}
...
ge-0/0/23 {
unit 0 {
family vpls;
}
}
Meaning
The output indicates that 24 Gigabit Ethernet interfaces
ranging from ge-0/0/0 through ge-0/0/23 are created.
Related Documentation
EX Series
Using Wildcard Characters in Interface Names
J Series
Using Wildcard Characters in Interface Names
M Series
Using Wildcard Characters in Interface Names
MX Series
Using Wildcard Characters in Interface Names
PTX Series
Using Wildcard Characters in Interface Names
T Series
Using Wildcard Characters in Interface Names
Published: 2013-01-15
Supported Platforms
Published: 2013-01-15