Advanced CLI and Other Cool Stuff

Lots of other fantastic configuration options are available, but explaining them all would require a separate book. The JUNOS documentation contains many time-saving tips, and the JUNOS Cookbook by Aviva Garrett (O’Reilly) is a great resource too. To whet your appetite, here are three JUNOS software CLI tips.

Most changes that you need to make on a router can be done at only certain times, often referred as maintenance windows. Since these windows are often at the most inconvenient times for those who have to use them, changes represented by commit can actually be scheduled:

[edit]
doug@Hops#commit at 07:05
configuration check succeeds
commit at will be executed at 2007-06-10 07:05:00 UTC
Exiting configuration mode

When the commit has been scheduled, other users cannot change any piece of the new locked configuration:

joe@Hops>configure
Entering configuration mode
Users currently editing the configuration:
  doug terminal d0 (pid 11035) on since 2007-06-05 05:04:51 UTC
      commit-at

[edit]
joe@Hops# set system host-name foo
error: configuration database locked by:
  doug terminal d0 (pid 11035) on since 2007-06-05 05:04:51 UTC
      commit at

[edit]
joe@Hops# commit
error: Another commit is pending

If the system needs to be unlocked before the specified time, a clear command can stop the timed action:

joe@Hops#run clear system commit
Pending commit cleared

You can take advantage of another fantastic shortcut when large common pieces of configuration need to be removed from the router. The router can search through the entire configuration looking for a string and delete every line that contains that string:

[edit]
jane@R1#wildcard delete interfaces fe-
  matched: fe-0/0/1
  matched: fe-2/0/0
  matched: fe-2/0/1
Delete 3 objects? [yes,no] (no) yes

Lastly, you can make common configuration changes in one large swoop with the replace command. Any string can replace any other string, with a string being anything from a character to any POSIX 1003.2 expression. For example, this command could be useful is when IPs referenced in filters, policies, and so on need to be updated to a new value:

[edit]
jane@R1#replace pattern 172.17.30.254 with 172.17.30.200

Get JUNOS Enterprise Routing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.