Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

Example: Configuring a Routing Protocol

This topic provides a sample configuration that describes how to configure an OSPF backbone area that has two SONET interfaces.

The final configuration looks like this:

[edit]
protocols {ospf {area 0.0.0.0 {interface so-0/0/0 {hello-interval 5;dead-interval 20;}interface so-0/0/1 {hello-interval 5;dead-interval 20;}}}}

This topic contains the following examples of configuring a routing protocol:

Shortcut

You can create a shortcut for this entire configuration with the following two commands:

[edit]user@host# set protocols ospf area 0.0.0.0 interface so-0/0/0 hello-interval 5 dead-interval 20[edit]user@host# set protocols ospf area 0.0.0.0 interface so-0/0/1 hello-interval 5 dead-interval 20

Longer Configuration

This section provides a longer example of creating the previous OSPF configuration. In the process, it illustrates how to use the different features of the CLI.

  1. Enter configuration mode by issuing the configure top-level command:
    user@host> configure entering configuration mode[edit]user@host#

    Notice that the prompt has changed to a pound sign (#) to indicate configuration mode.

  2. To create the above configuration, you start by editing the protocols ospf statements:
    [edit]user@host# edit protocols ospf[edit protocols ospf]user@host#
  3. Now add the OSPF area:
    [edit protocols ospf]user@host# edit area 0.0.0.0[edit protocols ospf area 0.0.0.0]user@host#
  4. Add the first interface:
    [edit protocols ospf area 0.0.0.0]user@host# edit interface so0[edit protocols ospf area 0.0.0.0 interface so-0/0/0]user@host#

    You now have four nested statements.

  5. Set the hello and dead intervals.
    [edit protocols ospf area 0.0.0.0 interface so-0/0/0]
    user@host#set ?
    user@host# set hello-interval 5
    user@host# set dead-interval 20
    user@host#
  6. You can see what is configured at the current level with the show command:
    [edit protocols ospf area 0.0.0.0 interface so-0/0/0]user@host# show hello-interval 5;dead-interval 20;[edit protocols ospf area 0.0.0.0 interface so-0/0/0]user@host#
  7. You are finished at this level, so back up a level and take a look at what you have so far:
    [edit protocols ospf area 0.0.0.0 interface so-0/0/0]user@host# up [edit protocols ospf area 0.0.0.0]user@host# show
    interface so-0/0/0 {hello-interval 5;dead-interval 20;}
    [edit protocols ospf area 0.0.0.0]user@host#

    The interface statement appears because you have moved to the area statement.

  8. Add the second interface:
    [edit protocols ospf area 0.0.0.0]user@host# edit interface so-0/0/1[edit protocols ospf area 0.0.0.0 interface so-0/0/1]user@host# set hello-interval 5[edit protocols ospf area 0.0.0.0 interface so-0/0/1]user@host# set dead-interval 20[edit protocols ospf area 0.0.0.0 interface so-0/0/1]user@host# up [edit protocols ospf area 0.0.0.0]user@host# show
    interface so-0/0/0 {hello-interval 5;dead-interval 20;}
    interface so-0/0/1 {hello-interval 5;dead-interval 20;}
    [edit protocols ospf area 0.0.0.0]user@host#
  9. Back up to the top level and see what you have:
    [edit protocols ospf area 0.0.0.0]user@host# top[edit]user@host# show
    protocols {ospf {area 0.0.0.0 {interface so-0/0/0 {hello-interval 5;dead-interval 20;}interface so-0/0/1 {hello-interval 5;dead-interval 20;}}}}
    [edit]user@host#

    This configuration now contains the statements you want.

  10. Before committing the configuration (and thereby activating it), verify that the configuration is correct:
    [edit]user@host# commit checkconfiguration check succeeds[edit]user@host#
  11. Commit the configuration to activate it on the router:
    [edit]user@host# commitcommit complete[edit]user@host#

Making Changes to a Routing Protocol Configuration

Suppose you decide to use different dead and hello intervals on interface so-0/0/1. You can make changes to the configuration.

  1. Go directly to the appropriate hierarchy level by typing the full hierarchy path to the statement you want to edit:
    [edit]user@host# edit protocols ospf area 0.0.0.0 interface so-0/0/1[edit protocols ospf area 0.0.0.0 interface so-0/0/1]user@host# show hello-interval 5;dead-interval 20;[edit protocols ospf area 0.0.0.0 interface so-0/0/1]user@host# set hello-interval 7[edit protocols ospf area 0.0.0.0 interface so-0/0/1]user@host# set dead-interval 28[edit protocols ospf area 0.0.0.0 interface so-0/0/1]user@host# top[edit]user@host# show
    protocols {ospf {area 0.0.0.0 {interface so-0/0/0 {hello-interval 5;dead-interval 20;}interface so-0/0/1 {hello-interval 7;dead-interval 28;}}}}
    [edit]user@host#
  2. If you decide not to run OSPF on the first interface, delete the statement:
    [edit]user@host# edit protocols ospf area 0.0.0.0[edit protocols ospf area 0.0.0.0]user@host# delete interface so-0/0/0[edit protocols ospf area 0.0.0.0]user@host# top[edit]user@host# show
    protocols {ospf {area 0.0.0.0 {interface so-0/0/1 {hello-interval 7;dead-interval 28;}}}}
    [edit]user@host#

    Everything inside the statement you deleted was deleted with it. You can also eliminate the entire OSPF configuration by simply entering delete protocols ospf while at the top level.

  3. If you decide to use the default values for the hello and dead intervals on your remaining interface but you want OSPF to run on that interface, delete the hello and dead interval timers:
    [edit]user@host# edit protocols ospf area 0.0.0.0 interface so-0/0/1[edit protocols ospf area 0.0.0.0 interface so-0/0/1]user@host# delete hello-interval[edit protocols ospf area 0.0.0.0 interface so-0/0/1]user@host# delete dead-interval[edit protocols ospf area 0.0.0.0 interface so-0/0/1]user@host# top[edit]user@host# show
    protocols {ospf {area 0.0.0.0 {interface so-0/0/1;}}}
    [edit]user@host#

    You can set multiple statements at the same time as long as they are all part of the same hierarchy (the path of statements from the top inward, as well as one or more statements at the bottom of the hierarchy). This feature can reduce considerably the number of commands you must enter.

  4. To go back to the original hello and dead interval timers on interface so-0/0/1, enter:
    [edit]user@host# edit protocols ospf area 0.0.0.0 interface so-0/0/1[edit protocols ospf area 0.0.0.0 interface so-0/0/1]user@host# set hello-interval 5 dead-interval 20[edit protocols ospf area 0.0.0.0 interface so-0/0/1]user@host# exit[edit]user@host# show
    protocols {ospf {area 0.0.0.0 {interface so-0/0/1 {hello-interval 5;dead-interval 20;}}}}
    [edit]user@host#
  5. You also can re-create the other interface, as you had it before, with only a single entry:
    [edit]user@host# set protocols ospf area 0.0.0.0 interface so-0/0/1 hello-interval 5 dead-interval 20[edit]user@host# show
    protocols {ospf {area 0.0.0.0 {interface so-0/0/0 {hello-interval 5;dead-interval 20;}interface so-0/0/1 {hello-interval 5;dead-interval 20;}}}}
    [edit]user@host#

Published: 2013-01-15