Supported Platforms
Related Documentation
- ACX, EX, J, M, MX, PTX, QFX, T Series
- Examples: Loading a Configuration from a File
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:
For information about specifying the filename, see Viewing Files and Directories on a Device Running Junos OS.
To load a configuration from the terminal, use the following version of the load configuration mode command. Type ^D to end input.
To replace an entire configuration, specify the override option at any level of the hierarchy. A load override operation completely replaces the current candidate configuration with the file you are loading. So if you saved a complete configuration, this is the option to use.
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 Examples: Loading a Configuration from a File.
To replace portions of a configuration, specify the replace option. The load replace operation looks for replace: tags that you added to the loaded file, and replaces the parts of the candidate configuration with whatever is specified after the tag. This is useful when you want more control over exactly what is being changed. 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 Examples: Loading a Configuration from a File.
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.
The load merge operation adds the saved file to the existing candidate configuration. This is useful if you are adding new configuration sections. For example, if you are adding a BGP configuration to the [edit protocols] level, where there was no BGP configuration before. If the existing configuration and the incoming configuration contain conflicting statements, the statements in the incoming configuration override those in the existing configuration.
To replace only the configuration that has changed, specify the update option at any level of the hierarchy. The load update operation compares the candidate configuration and the file you are loading, and only changes the parts of the candidate configuration that are different from the new configuration. You would use this, for example, if there is an existing BGP configuration and the file you are loading changes it in some way.
To change part of the configuration with a patch file, specify the patch option. The load patch operation loads a file or terminal input that contains configuration changes. First, on a device that already has the configuration changes, you type the show | compare command to output the differences between two configurations. Then you can load the differences on another router. The advantage of the load patch command is that it saves you from having to copy snippets from different hierarchy levels into a text file prior to loading them into the target device. This might be a useful time saver if you are configuring several devices with the same options. For example, suppose you configure a routing policy on Device router1 and you want to replicate the policy configuration on Device router2, router3, and router4.
First, run the show | compare command.
user@router1# show | compare rollback 3
[edit protocols ospf] + export default-static; - export static-default [edit policy-options] + policy-statement default-static { + from protocol static; + then accept; + }
Copy the output of the show | compare command to the clipboard, making sure to include the hierarchy levels. On Device router2, router3, and router4, type load patch terminal and paste the output. Press Enter and type Ctrl-D to end the operation. If the patch input specifies different values for an existing statement, the patch input overrides the existing statement.
To use the merge, replace, set, or update option without specifying the full hierarchy level, specify the relative option. For example:
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 Examples: Loading a Configuration from a File.
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 OS Operational Mode Commands.
![]() | Note: If you are using Junos OS 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. |
Related Documentation
- ACX, EX, J, M, MX, PTX, QFX, T Series
- Examples: Loading a Configuration from a File
Published: 2013-01-23
Supported Platforms
Related Documentation
- ACX, EX, J, M, MX, PTX, QFX, T Series
- Examples: Loading a Configuration from a File