[ Contents] [ Prev] [ Next] [ Index] [ Report an Error]

Loading a Configuration from a File

You can create a file, copy the file to the local router, and then load the file into the CLI. After you have loaded the file, you can commit it to activate the configuration on the router, or you can edit the configuration interactively using the CLI and commit it at a later time.

You can also create a configuration while typing at the terminal and then load it. Loading a configuration from the terminal is generally useful when you are cutting existing portions of the configuration and pasting them elsewhere in the configuration.

To load an existing configuration file that is located on the router, use the load configuration mode command:

[edit]
user@host# load (factory-default | merge | override | patch | replace | set | update)
filename <relative>

To load a configuration from the terminal, use the following version of the load configuration mode command:

[edit]
user@host# load (factory-default | merge | override | patch | replace | set | update)
terminal < relative>
[Type ^D to end input]

To replace an entire configuration, specify the override option at any level of the hierarchy.

An override operation discards the current candidate configuration and loads the configuration in filename or the one that you type at the terminal. When you use the override option and commit the configuration, all system processes reparse the configuration. For an example, see Figure 17.

To replace only the configuration that has changed, specify the update option at any level of the hierarchy. An update operation compares the current configuration and the current candidate configuration, and loads only the changes between these configurations in filename or the one that you type at the terminal. When you use the update operation and commit the configuration, the JUNOS software attempts to notify the smallest set of system processes that are affected by the configuration change.

To combine the current configuration and the configuration in filename or the one that you type at the terminal, specify the merge option. A merge operation is useful when you are adding a new section to an existing configuration. If the existing configuration and the incoming configuration contain conflicting statements, the statements in the incoming configuration override those in the existing configuration. For an example, see Figure 19.

To replace portions of a configuration, specify the replace option. For this operation to work, you must include replace: tags in the file or configuration you type at the terminal. The software searches for the replace: tags, deletes the existing statements of the same name, if any, and replaces them with the incoming configuration. If there is no existing statement of the same name, the replace operation adds to the configuration the statements marked with the replace: tag. For an example, see Figure 18.

To load a configuration that contains the set configuration mode command, specify the set option. This option executes the configuration instructions line by line as they are stored in a file or from a terminal. The instructions can contain any configuration mode command, such as set, edit, exit, and top. For an example, see Figure 21.

To use the merge, replace, set, or update option without specifying the full hierarchy level, specify the relative option. For example:

[edit system]
user@host# show static-host-mapping
bob sysid 987.654.321ab
[edit system]
user@host# load replace terminal relative
{Type ^D at a new line to end input]
replace: static-host-mapping {
bob sysid 0123.456.789bc;
}
load complete
[edit system]
user@host# show static-host-mapping
bob sysid 0123.456.789bc;

To change part of the configuration with a patch file and mark only those parts as changed, specify the patch option. For an example, see Figure 20.

If, in an override or merge operation, you specify a file or type text that contains replace: tags, the replace: tags are ignored and the override or merge operation is performed.

If you are performing a replace operation and the file you specify or text you type does not contain any replace: tags, the replace operation is effectively equivalent to a merge operation. This might be useful if you are running automated scripts and cannot know in advance whether the scripts need to perform a replace or a merge operation. The scripts can use the replace operation to cover either case.

For information about specifying the filename, see Specifying Filenames and URLs.

To copy a configuration file from another network system to the local router, you can use the SSH and Telnet utilities, as described in the JUNOS System Basics and Services Command Reference.

Note: If you are using JUNOS software in a Common Criteria environment, system log messages are created whenever a secret attribute is changed (for example, password changes or changes to the RADIUS shared secret). These changes are logged during the following configuration load operations:

load merge
load replace
load override
load update

For more information, see the Secure Configuration Guide for Common Criteria and JUNOS-FIPS.

Examples: Loading a Configuration from a File

Figure 17: Example 1: Load a Configuration from a File

Image h1628.gif

Figure 18: Example 2: Load a Configuration from a File

Image h1629.gif

Figure 19: Example 3: Load a Configuration from a File

Image h1705.gif

Figure 20: Example 4: Load a Configuration from a File

Image h1969.gif

Figure 21: Example 5: Load a Configuration from a File

Image g017215.gif

Additional Details About Specifying Statements and Identifiers

This section provides more detailed information about CLI container and leaf statements so that you can better understand how you must specify them when creating ASCII configuration files. It also describes how the CLI performs type-checking to verify that the data you entered is in the correct format.

Specifying Statements

Statements are shown one of two ways, either with braces or without:

The statement-name is the name of the statement.

The identifier is a name or other string that uniquely identifies an instance of a statement. The identifier is used when a statement can be specified more than once in a configuration.

When specifying a statement, you must specify either a statement name or an identifier, or both, depending on the statement hierarchy.

You specify identifiers in one of the following ways:

The following examples illustrate how statements and identifiers are specified in the configuration:

protocol {# Top-level statement (statement-name).
ospf {# Statement under "protocol" (statement-name).
area 0.0.0.0 {# OSPF area "0.0.0.0" (statement-name identifier),
interface so-0/0/0 {# which contains an interface named "so-0/0/0."
hello-interval 25;# Identifier and value (identifier-name value).
priority 2;# Identifier and value (identifier-name value).
disable;# Flag identifier (identifier-name).
interface so-0/0/1;# Another instance of "interface," named so-0/0/1,
}# this instance contains no data, so no braces
}# are displayed.
policy-options {# Top-level statement (statement-name).
term term1 {# Statement under "policy-options"
# (statement-name value).
from {# Statement under "term" (statement-name).
route-filter 10.0.0.0/8 orlonger reject;# One identifier ("route-filter") with
route-filter 127.0.0.0/8 orlonger reject;# multiple values.
route-filter 128.0.0.0/16 orlonger reject;
route-filter 149.20.64.0/24 orlonger reject;
route-filter 172.16.0.0/12 orlonger reject;
route-filter 191.255.0.0/16 orlonger reject;
then {# Statement under "term" (statement-name).
next term;# Identifier (identifier-name).

When you create an ASCII configuration file, you can specify statements and identifiers in one of the following ways. However, each statement has a preferred style, and the CLI uses that style when displaying the configuration in response to a configuration mode show command.

Performing CLI Type-Checking

When you specify identifiers and values, the CLI performs type-checking to verify that the data you entered is in the correct format. For example, for a statement in which you must specify an IP address, the CLI requires you to enter an address in a valid format. If you have not, an error message indicates what you need to type. Table 15 lists the data types the CLI checks.

Table 15: CLI Configuration Input Types

Data Type

Format

Examples

Physical interface name (used in the [edit interfaces] hierarchy)

type-fpc/pic/port

Correct: so-0/0/1

Incorrect: so-0

Full interface name

type-fpc/pic/port<:channel>.logical

Correct: so-0/0/1.0

Incorrect: so-0/0/1

Full or abbreviated interface name (used in places other than the [edit interfaces] hierarchy)

type-<fpc</pic/port>><<:channel>.logical>

Correct: so, so-1, so-1/2/3:4.5

IP address

0xhex-bytesoctet<.octet<.octet.<octet>>>

Correct: 1.2.3.4, 0x01020304, 128.8.1, 128.8

Sample translations:

1.2.3 becomes 1.2.3.0

0x01020304 becomes 1.2.3.4

0x010203 becomes 0.1.2.3

IP address (destination prefix) and prefix length

0xhex-bytes</length>octet<.octet <.octet.<octet>>>< /length >

Correct: 10/8, 128.8/16, 1.2.3.4/32, 1.2.3.4

Sample translations:

1.2.3 becomes 1.2.3.0/32

0x01020304 becomes 1.2.3.4/32

0x010203 becomes 0.1.2.3/32

default becomes 0.0.0.0/0

International Organization for Standardization (ISO) address

hex-nibble <hex-nibble ...>

Correct: 47.1234.2345.3456.00, 47123423453456.00, 47.12.34.23.45.34.56.00

Sample translations:

47123456 becomes 47.1234.56

47.12.34.56 becomes 47.1234.56

4712.3456 becomes 47.1234.56

OSPF area identifier (ID)

0xhex-bytesoctet <.octet<.octet.< octet >>> decimal-number

Correct: 54, 0.0.0.54, 0x01020304, 1.2.3.4

Sample translations:

54 becomes 0.0.0.54

257 becomes 0.0.1.1

128.8 becomes 128.8.0.0

0x010203 becomes 0.1.2.3


[ Contents] [ Prev] [ Next] [ Index] [ Report an Error]