Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Example: Configure Dual Routing Engines

If your device has redundant (also called dual) Routing Engines, your Junos OS configuration can be complex. This example shows how you can use commit scripts to simplify and control the configuration of dual Routing Engine platforms.

Requirements

This example uses a device running Junos OS with dual Routing Engines.

Overview and Commit Script

Junos OS supports two special configuration groups: re0 and re1. When these groups are applied using the apply-groups [ re0 re1 ] statement, they take effect if the Routing Engine name matches the group name. Statements included at the [edit groups re0] hierarchy level are inherited only on the Routing Engine named RE0, and statements included at the [edit groups re1] hierarchy level are inherited only on the Routing Engine named RE1.

This example includes two commit scripts. The first script, dual-re.xsl, generates a warning if the system host-name statement, any IP version 4 (IPv4) interface address, or the fxp0 interface configuration is configured in the target configuration instead of in a configuration group.

The second script, dual-re2.xsl, first checks whether the hostname configuration is configured and then checks whether it is configured in a configuration group. The otherwise construct generates an error message if the hostname is not configured at all. The first when construct allows the script to do nothing if the hostname is already configured in a configuration group. The second when construct takes effect when the hostname is configured in the target configuration. In this case, the script generates a transient change that places the hostname configuration into the re0 and re1 configuration groups, copies the configured hostname into those groups, concatenates each group hostname with -RE0 and -RE1, and deactivates the hostname in the target configuration so the configuration group hostnames can be inherited.

The example scripts are shown in both XSLT and SLAX syntax:

XSLT Syntax: dual-re.xsl Script

XSLT Syntax: dual-re2.xsl Script

SLAX Syntax: dual-re.xsl Script

SLAX Syntax: dual-re2.xsl Script

Configuration

Procedure

Step-by-Step Procedure

To download, enable, and run the scripts:

  1. Copy the scripts into two text files, name the files dual-re.xsl and dual-re2.xsl or dual-re.slax and dual-re2.slax as appropriate, and copy them to the /var/db/scripts/commit/ directory on the device.

  2. Select the following test configuration stanzas, and press Ctrl+c to copy them to the clipboard.

    If you are using the SLAX version of the script, change the filenames at the [edit system scripts commit file] hierarchy level to dual-re.slax and dual-re2.slax.

  3. In configuration mode, issue the load merge terminal command to merge the stanzas into your device configuration.

    1. At the prompt, paste the contents of the clipboard by using the mouse and the paste icon.

    2. Press Enter.

    3. Press Ctrl+d.

  4. Commit the configuration.

Verification

Verifying the Commit Script Changes

Purpose

Verify that the script behaves as expected.

Action

Review the output of the commit command. After the commit operation completes, the device hostname is changed to router1-RE0.