Configuring the Router by Copying Text from a Terminal Window
Problem
You have a portion of a router configuration displayed in another window on your terminal or computer and you want to copy it to another router and activate it.
Solution
Use the load merge terminal command:
aviva@router1> configure Entering configuration mode [edit] aviva@router1# load merge terminal [Type ^D at a new line to end input]
Then, cut the configuration snippet and paste it here. When you are done, type Ctrl-d.
Discussion
A time-saver when configuring the router is to cut the configuration text from one window on your computer and paste it into the router's terminal window with the load merge terminal command. This is a great technique when you are copying configuration text from a browser or email window or when you are propagating identical or similar configurations from one router to another. To illustrate with a simple example, suppose you are configuring PIM-SM on all routers and are copying the configuration from a browser window. Here's the configuration in the browser:
protocols { pim { interface all { mode sparse; version 2; } interface fxp0.0 { disable; } } }
Copy the text from the browser window; then, in the router's configuration window, go into configuration mode, move to the correct configuration hierarchy level, and paste the text.
If PIM is not yet configured, merge it into the existing configuration:
aviva@router1> configure Entering configuration mode [edit] aviva@router1# load merge terminal [Type ^D at a new line to end input] cut and paste here to add the lines shown below protocols { pim { interface all { mode sparse; version 2; } interface fxp0.0 { disable; } } } ^D load complete
First type the load merge terminal command and press Enter. Then paste the copied text and press Ctrl-d when done. This snippet starts at the top level of the configuration, [edit protocol], so you can drop it in with no typing. If the snippet is at a lower level, you either need to move down to that hierarchy level in the configuration (using the edit configuration mode command) or type in the opening hierarchy statements and closing braces yourself. If the PIM configuration you have is just the two interface commands and you are at the [edit] level, you need to type opening lines for protocols { and pim { and two lines of closing braces:
[edit] aviva@router1# load merge terminal [Type ^D at a new line to end input] protocols { pim { type your paste command here to paste the lines shown below interface all { mode sparse; version 2; } interface fxp0.0 { disable; } } } ^D load complete
If you forget to include the proper number of closing braces, the CLI displays an error.
Here, the first line of the error shows that one closing brace was omitted, and the second line indicates the hierarchy level:
terminal:9:(0) syntax error: } [edit protocols pim] '' syntax error load complete (1 errors)
However, for a simple syntactical error like this, the CLI adds the remaining closing brace. You can verify this by checking the configuration:
[edit] aviva@router1# show protocols pim { interface all { mode sparse; version 2; } interface fxp0.0 { disable; } } <-- CLI added this last brace [edit] aviva@router1# commit check configuration check succeeds
You see that the CLI added the final brace. The commit check command confirms this correction, indicating that there are no syntax errors in the configuration file.