Navigating a JUNOS Configuration

In the previous post on JUNOS I gave you a brief overview of the software architecture, with a particular emphasis on modularity. In this post, we'll have a first look at maneuvering around within a JUNOS configuration file.

The JUNOS configuration file is well organized in a hierarchical structure; once you understand that structure and its various levels, it's easy to navigate the file and find exactly the parts you want to examine or change without being distracted by parts you are not interested in at the moment.

To begin, I log into the router:

Juniper5 (ttyd0) login: jeff

Password:

--- JUNOS 8.5R1.13 built 2007-11-14 17:54:24 UTC

jeff@Juniper5>

The prompt shows the user name (jeff) and the name of the router (Juniper5). The router is now in operational mode, from which you can perform operational tasks such as displaying router states and databases, ping and traceroute, telnet and ssh, restarting system processes – most commands that you need for monitoring and troubleshooting the system. The JUNOS operational mode is equivalent to the IOS user EXEC mode; in fact the prompts of both is a "greater than" (>) sign.

As with IOS, the question mark is your friend; it's the primary informational tool when you can't quite remember the next statement in a command string, or just want to see what options are available to you. I can use the question mark to see all of the commands available in operational mode:

<font size="-3" face="Courier New, Courier, Monaco, monospace">jeff@Juniper5> </font><font size="-3" color="red" face="Courier New, Courier, Monaco, monospace">?</font><font size="-3" face="Courier New, Courier, Monaco, monospace">
Possible completions:<br>
    clear           Clear information in the system<br>
    configure       Manipulate software configuration information<br>

    diagnose        Invoke diagnose script|<br>
    file            Perform file operations<br>
    help            Provide help information<br>
    monitor         Show real-time debugging information
    mtrace          Trace multicast path from source to receiver
    ping            Ping remote target
    quit            Exit the management session
    request         Make system-level requests
    restart         Restart software process
    set             Set CLI properties, date/time, craft interface message
    show            Show system information
    ssh             Start secure shell on another host
    start           Start shell
    telnet          Telnet to another host
    test            Perform diagnostic debugging
    traceroute      Trace route to remote host
							  
						</font>

To make configuration changes, I enter configuration mode by entering the configure command:

jeff@Juniper5> configure Entering configuration mode [edit]

jeff@Juniper5#

The JUNOS configuration mode is equivalent to the IOS privileged EXEC or "enabled" mode. Notice that the prompt changed from > to #, again the same way IOS does after you enter the enable command.

Another characteristic of the JUNOS configuration mode is the [edit] banner just above the prompt. You can maneuver around within the configuration hierarchy to observe or change just the part of the file that are of interest to you; the banner indicates precisely where you are within the hierarchy. When the banner just shows [edit], you are at the top of the hierarchy. So for example, if you type show at this level with no modiiers, JUNOS displays the entire configuration.

Using the question mark with the show command, you can see the top levels of the configuration hierarchy:

<font face="Courier New, Courier, Monaco, monospace"><font size="-3">[edit]
jeff@Juniper5# </font><font size="-3" color="red">show ?</font><font size="-3">
Possible completions:
  <[Enter]>            Execute this command

> access               Network access configuration
> accounting-options   Accounting data configuration
> applications         Define applications by protocol characteristics
+ apply-groups         Groups from which to inherit configuration data
> chassis              Chassis configuration
> class-of-service     Class-of-service configuration
> event-options        Event processing configuration
> firewall             Define a firewall configuration
> forwarding-options   Configure options to control packet forwarding
> groups               Configuration groups

> interfaces           Interface configuration
> policy-options       Routing policy option configuration
> protocols            Routing protocol configuration
> routing-instances    Routing instance configuration
> routing-options      Protocol-independent routing option configuration
> security             Security configuration
> services             Service PIC applications settings
> snmp                 Simple Network Management Protocol configuration
> system               System parameters
  |                    Pipe through a command
							</font></font>

The labels accompanying this list explain the levels pretty well. For example, all interfaces are configured under the interfaces level, all protocols are configured under the protocols level, and all routing policies are configured under the policy-options level.

Below each of these top levels are many sub-levels. For example, under protocols you can find BGP, OSPFv2, OSPFv3, MPLS, RSVP, and so on. And under each of those will find further sub-levels specific to the protocol. Under OSPF, for example, you will find a level for the area configurations and then under each area level you will find a level for specifying the interfaces that are in that area. I'll show you an example of that in a moment.

The hierarchical structure of the configuration allows you to focus on just the part of the configuration in which you are interested. For example, suppose you want to look at just the BGP portion of the configuration. show protocols bgp shows you the entire BGP configuration:

<font size="-3" face="Courier New, Courier, Monaco, monospace">[edit]
jeffr@Juniper5# </font><font size="-3" color="red" face="Courier New, Courier, Monaco, monospace">show protocols bgp</font><font size="-3" face="Courier New, Courier, Monaco, monospace"> 
local-address 192.168.50.10;
local-as 65503;
group CustomerX {
    export XPolicy;
    peer-as 65510;
    neighbor 192.168.1.1 {
        authentication-key "$9$-Ud2aji.5z6qm"; ## SECRET-DATA
    }
    neighbor 192.168.1.5 {
        authentication-key "$9$JiZHmzF/t0I69ev"; ## SECRET-DATA
    }
    neighbor 192.168.1.10 {
        authentication-key "$9$mPF/u0Icrv1Rbs"; ## SECRET-DATA
    }
}
group CustomerY {
    neighbor 192.168.10.20;
    neighbor 192.168.10.30;
    neighbor 192.168.10.40;
}
group CustomerZ {
    neighbor 192.168.20.100;
}
						</font>

You can see in this configuration that there is a local address (192.168.50.10) from which all the BGP TCP sessions originate, the local AS number is 65503, and there are three peer groups: CustomerX, CustomerY, and CustomerZ. CustomerX has an outgoing (export) routing policy I've named XPolicy; and because the AS number for that group (65510) is different from the local AS number, we know these are EBGP peers. There are three neighbors configured under this group, all of which are authenticated with individual passwords. Peer groups CustomerY, with three neighbors, and CustomerZ, with one neighbor, are IBGP because they have no separate AS numbers specified, and no authentication is configured.

Suppose, rather than the entire BGP configuration, you are interested in only the configuration of neighbor 192.168.1.5 under group Customer X. I can tell JUNOS to display just that part of the configuration file simply by being more explicit with the show command:

<font face="Courier New, Courier, Monaco, monospace"><font size="-3">[edit]
jeff@Juniper5# </font><font size="-3" color="red">show protocols bgp group CustomerX neighbor 192.168.1.5</font><font size="-3">    
authentication-key "$9$JiZHmzF/t0I69ev"; ## SECRET-DATA</font></font>

Of course if you are in configuration mode you probably want to do more than just look at parts of the configuration; you want to make changes. Using the question mark alone while in configuration mode, you can see the different actions you can take:

<font size="-3" face="Courier New, Courier, Monaco, monospace">[edit]
jeff@Juniper5# </font><font size="-3" color="red" face="Courier New, Courier, Monaco, monospace">?</font><font size="-3" face="Courier New, Courier, Monaco, monospace">     
Possible completions:
  <[Enter]>            Execute this command
  activate             Remove the inactive tag from a statement
  annotate             Annotate the statement with a comment
  commit               Commit current set of changes
  copy                 Copy a statement
  deactivate           Add the inactive tag to a statement
  delete               Delete a data element
  edit                 Edit a sub-element
  exit                 Exit from this level
  help                 Provide help information
  insert               Insert a new ordered data element
  load                 Load configuration from ASCII file
  quit                 Quit from this level
  rename               Rename a statement
  replace              Replace character string in configuration
  rollback             Roll back to previous committed configuration
  run                  Run an operational-mode command
  save                 Save configuration to ASCII file
  set                  Set a parameter
  show                 Show a parameter
  status               Show users currently editing configuration
  top                  Exit to top level of configuration
  up                   Exit one level of configuration
  wildcard             Wildcard operations
						</font>

The remainder of this post and all of the next post discuss the actions on this list.

I want to add some elements to the configuration, and the command for doing that is set. Lets' say we want to add interface fe-0/0/0 to OSPF area 5. Using set, we specify each level down through the hierarchy until we get to the point – under the area 5 level – where the interface is to be added:

<font size="-2" face="Courier New, Courier, Monaco, monospace">[edit]
jeff@Juniper5# </font><font size="-2" color="red" face="Courier New, Courier, Monaco, monospace">set protocols ospf area 5 interface fe-0/0/0</font><font size="-2" face="Courier New, Courier, Monaco, monospace"> </font>

By the way, if OSPF was not enabled or area 5 did not yet exist, the same command would enable the protocol and create area 5 in addition to adding the interface to the area.

Another approach is to first move down to the level you want to configure, using the edit command, and then make the changes you want:

<font size="-2" face="Courier New, Courier, Monaco, monospace">[edit]
jeff@Juniper5# </font><font size="-2" color="red" face="Courier New, Courier, Monaco, monospace">edit protocols ospf area 5</font><font size="-2" face="Courier New, Courier, Monaco, monospace"> </font>
<font size="-2" face="Courier New, Courier, Monaco, monospace">[edit protocols ospf area 0.0.0.5]
jeff@Juniper5# </font><font size="-2" color="red" face="Courier New, Courier, Monaco, monospace">set interface fe-0/0/1</font><font size="-2" face="Courier New, Courier, Monaco, monospace"> 
						</font>

Notice here that after entering edit protocols ospf area 5, the banner over the prompt changed to show where I am in the hierarchy – I always know where I am. I then used the set command to add interface fe-0/0/1 at that level. I don't need to specify the entire hierarchy this time, because I am already at the level where I want to make a change.

These two approaches give you the flexibility to manage a configuration in the manner most convenient to you. If you are just adding a statement or two to a configuration, it is usually easier to do that from the top level, specifying the full path down to the level you want to change. If you are making extensive changes to a particular level, it is usually easier to move to that level first using the edit command, and then make the changes directly without having to specify the full path with every command.

While edit takes you to the specific level where you want to work, up moves you up one level in the hierarchy. For instance, suppose that from where we are at the OSPF area 5 level, we want to move up to the full OSPF level:

1 2 Page 1
Page 1 of 2
The 10 most powerful companies in enterprise networking 2022