By Aviva Garrett
Book Price: $54.99 USD
£38.99 GBP
PDF Price: $43.99
Cover | Table of Contents | Colophon
root# cli root@> cli> configure [edit] root@# set system host-name router1 root@# set system domain-name mynetwork.com root@# set interfaces fxp0 unit 0 family inet address 192.168.15.1/24 root@# set system backup-router 192.168.15.2 root@# set system name-server 192.168.15.3 root@# set system root-authentication plain-text-password New password: Retype password: root@ show system { host-name router1 ; domain-name mynetwork.com; backup-router 192.168.15.2; root-authentication { encrypted-password "$1$ZUlES4dp$OUwWo1g7cLoV/aMWpHUnC/"; ## SECRET-DATA; } name-server { 192.168.15.3; } interfaces { fxp0 { unit 0 { family inet { address 192.168.15.1/24; } } } } root@# commit root@router1# exit root@router1>
aviva@router1> configure
Entering configuration mode
[edit]
aviva@router1#
aviva@router1> configure
exclusive
warning: uncommitted changes will be discarded on exit
Entering configuration mode
[edit]
aviva@router1#
aviva@router1> configure
Entering configuration mode
Users currently editing the configuration:
mike terminal p3 (pid 1088) on since 2005-02-30 19:47:58 PST, idle 00:00:44
[edit]
aviva@router1#
mike is also logged in, is working in configuration mode, and has not typed anything for 44 seconds. However, if someone enters configuration mode after you do, the CLI does not display any message, so you will not be notified. Instead, you need to check:
[edit]
aviva@router1#
status
Users currently editing the configuration:
aviva terminal p0 (pid 3358) on since 2005-06-09 11:22:18 PDT
[edit]
mike terminal p1 (pid 3768) on since 2005-06-09 11:48:31 PDT
[edit]
configure exclusive command to enter configuration mode. With this option, no other users can change the configuration as long as you are in configuration mode. If you do not commit the changes you make, they are lost when you exit from configuration mode.aviva@router1> request system logout user mike
status command.
[edit]
aviva@RouterA# show |
display set
show | display set command is a handy way to
reverse-engineer a router configuration when you are trying to duplicate portions of a configuration on many routers or when you need to write up configuration, monitoring, or troubleshooting procedures for your network operations staff. This command is especially useful if the configuration is complex and when setting it up involves many long commands and lots of typing.show command
into the display set command, the JUNOS CLI prints a list of the commands you need to issue from that hierarchy level to create the existing configuration. When you use the command at the top level of the configuration (at the [edit] level), the CLI shows all the commands necessary to configure the router, which for most routers is a lot of commands. By way of illustration, here's a sample of the output for four interfaces on the router from the [edit interfaces] level:
[edit interfaces]
aviva@RouterA# show | display set
set interfaces fe-0/0/1 unit 0 family inet address 10.0.15.2/24
set interfaces se-0/0/2 unit 0 family inet address 10.0.21.1/24
set interfaces se-0/0/3 serial-options clocking-mode dce
set interfaces se-0/0/3 unit 0 family inet address 10.0.16.1/24
set interfaces lo0 unit 0 family inet address 192.168.13.1/32
[edit interfaces]
aviva@RouterA# show
fe-0/0/1 {
unit 0 {
family inet {
address 10.0.15.2/24;
}
}
}
se-0/0/2 {
unit 0 {
family inet {
address 10.0.21.1/24;
}
}
}
se-0/0/3 {
serial-options {
clocking-mode dce;
}
unit 0 {
family inet {
address 10.0.16.1/24;
}
}
}
lo0 {
unit 0 {
family inet {
address 192.168.13.1/32;
}
}
}
[edit protocols ospf] aviva@router1# set area 0.0.0.0 interface fe-0/0/0 aviva@router1# annotate area 0.0.0.0 "backbone routers" aviva@router1# show /* backbone routers */ area 0.0.0.0 { interface fe-0/0/0.0; }
[edit protocols ospf] level. The comment appears immediately before the statement.[edit protocols ospf] aviva@router1# annotate area 0.0.0.0 ""
[edit]
aviva@router1# commit check
configuration check succeeds
[edit]
aviva@router1#
commit check command from time to time to check the syntax of the configuration. This command only checks the syntax; it does not activate the configuration.configuration check succeeds.[edit] aviva@router1# commit check [edit protocols rip group alpha-rip-group] 'neighbor fe-0/0/0.0' Failed to configure neighbor fe-0/0/0.0: already in group alpha-rip-group error: configuration check-out failed
[edit protocols rip group alpha-rip-group] hierarchy level of the configuration.
[edit]
aviva@router1# commit
commit complete
[edit]
aviva@router1#
commit check command; see Recipe 1.6). The commit command batches up all your changes (as well as changes made by anyone else who is also in configuration mode) and activates them all at once. This means that interdependent configuration segments take effect at the same time, so you don't have to worry about the order in which you add statements to the configuration.commit command for it to take effect. It is a common mistake to forget to commit your changes, so this is often the first thing to check when debugging an operational problem on the router. It's very easy to see how this might happen. You might make a change in the configuration and then immediately use the run command to issue an operational mode command to verify that the router behavior matches the changed configuration, or you might get interrupted or distracted while configuring and issue a commit command continues to fail.
[edit]
aviva@router1# commit | display detail
2005-02-24 11:49:49 PST: exporting juniper.conf
2005-02-24 11:49:49 PST: expanding groups
2005-02-24 11:49:49 PST: finished expanding groups
2005-02-24 11:49:49 PST: setup foreign files
2005-02-24 11:49:49 PST: propagating foreign files
2005-02-24 11:49:49 PST: complete foreign files
2005-02-24 11:49:50 PST: dropping unchanged foreign files
2005-02-24 11:49:50 PST: daemons checking new configuration
2005-02-24 11:49:50 PST: commit wrapup…
2005-02-24 11:49:50 PST: updating '/var/etc/filters/filter-define.conf'
2005-02-24 11:49:50 PST: activating '/var/etc/keyadmin.conf'
2005-02-24 11:49:50 PST: activating '/var/etc/gtpcd.conf'
2005-02-24 11:49:50 PST: activating '/var/etc/certs'
2005-02-24 11:49:50 PST: executing foreign_commands
2005-02-24 11:49:50 PST: /bin/sh /etc/rc.ui ui_setup_users (sh)
2005-02-24 11:49:50 PST: executing ui_commit in rc.ui
2005-02-24 11:49:51 PST: copying configuration to juniper.save
2005-02-24 11:49:51 PST: activating '/var/run/db/juniper.data'
2005-02-24 11:49:51 PST: notifying daemons of new configuration
2005-02-24 11:49:51 PST: signaling 'Routing protocol daemon', pid 2884, signal 1,
status 0 with notification errors enabled
commit complete
[edit]
aviva@router1# commit | display detail
2005-02-24 13:46:03 PST: exporting juniper.conf
2005-02-24 13:46:03 PST: expanding groups
2005-02-24 13:46:03 PST: finished expanding groups
2005-02-24 13:46:03 PST: setup foreign files
2005-02-24 13:46:03 PST: propagating foreign files
2005-02-24 13:46:03 PST: complete foreign files
2005-02-24 13:46:03 PST: dropping unchanged foreign files
2005-02-24 13:46:03 PST: daemons checking new configuration
[edit protocols rip group alpha-rip-group]
'neighbor fe-0/0/0.0'
Failed to configure neighbor fe-0/0/0.0: already in group alpha-rip-group
error: configuration check-out failed
[edit] aviva@router1# commit aviva@router1# quit aviva@router1>
[edit system] aviva@router1# commit aviva@router1# top [edit] aviva@router1# quit aviva@router1>
[edit system] aviva@router1# commit aviva@router1# exit configuration-mode aviva@router1>
[edit system]
aviva@router1# commit and-quit
aviva@router1>
commit and quit (or exit) commands, you must be at the top level of the hierarchy (at the [edit] level) for the exit command to quit configuration mode. From a lower level, use the top command to return quickly to the [edit] level. If you use the exit command at a lower level, it returns you to the highest hierarchy from which you previously issued an edit command.exit commands to illustrate this:[edit] aviva@router1# edit protocols [edit protocols] aviva@router1# edit ospf [edit protocols ospf] aviva@router1# edit area 0.0.0.1 [edit protocols ospf area 0.0.0.1] aviva@router1# exit [edit protocols ospf] aviva@router1# exit [edit protocols] aviva@router1# exit [edit] aviva@router1# exit Exiting configuration mode aviva@router1>
commit command followed by the
exit configuration-mode command.
aviva@router1# commit comment "turned on telnet"
comment option with the commit command.
aviva@router1> show system commit
0 2005-03-31 20:26:16 UTC by aviva via cli
turned on telnet
1 2005-03-31 11:12:28 UTC by aviva via cli
set host gildor facility-override local4
[edit]
aviva@RouterG# show | compare
[edit interfaces]
- fe-1/0/1 {
- unit 0 {
- family inet {
- address 10.0.1.2/24;
- }
- }
- }
[edit]
aviva@RouterG# show | compare rollback 1
[edit protocols ospf]
- export send-direct;
show command from time to time to see the configuration statements that were added or deleted so you can confirm the configuration. However, when making changes throughout the configuration hierarchy, you generally just want a summary of all the changes so you don't have to dig through the entire router configuration. The easiest way to see all the changes is to move to the top of the configuration hierarchy with the top command and then use the show |
compare command, which is equivalent to the
show | compare rollback 0 command. This is actually two commands: the show command displays the entire configuration, and the output is piped to the compare command, which lists only the differences between the two commands (just like the Unix diff command).fe-1/0/1 interface
from the [edit interfaces] configuration hierarchy. The first line of the output shows the hierarchy level, and the minus signs indicate the deletions.
Plus signs are used when you have added statements, as in this example:
[edit]
aviva@RouterG#
show | compare
[edit interfaces lo0 unit 0 family inet]
address 192.168.19.1/32 { … }
+ address 127.0.0.1/32;
aviva@router1> file copy server1:router- base-configuration . aviva@router1's password: router-base-configuration 100% 10KB 10.0KB/s 00:00
aviva@router1> file list
/var/home/aviva/:
.ssh/
router-base-configuration
[edit] aviva@router1# load override router-base-configuration load complete
show command to review the loaded configuration and make sure it's what you expect:
aviva@router1# show
[edit]
aviva@router1# commit
commit complete
file copy command on the router to copy the file from the server to the router. This command is similar to the Unix
scp command. In this example, the file is copied from the user's home directory on the server to her home directory on the router. The home directory is effectively the current directory, so you can type a
dot (.) for the directory name, just as in Unix. The explicit path is /var/home/aviva. No text is shown here for the password because the CLI does not echo what you type when you enter the password.file copy command uses SSH, the server must also be running SSH. (You can use the
file copy command because you enabled SSH when you initially configured the router [see Recipe 1.1].)aviva@router1> file copy server1:/tmp/config/router-base-configuration .
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]
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;
}
}
}
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
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, aviva@router1> file copy /config/juniper.conf.gz server1:/homes/aviva/tmp aviva@server1's password: juniper.conf.gz 100% 2127 2.1KB/s 00:00
save command to copy the candidate configuration to your home directory on a server:
[edit]
aviva@router1# save server1:configuration-march02
aviva@server1's password:
tempfile 100% 11KB 11.2KB/s 00:00
Wrote 433 lines of configuration to 'server1:configuration-march02'
[edit] aviva@router1# save configuration-march02 Wrote 433 lines of configuration to 'configuration-march02' aviva@router1# run file list /var/home/aviva: .ssh/ configuration-march02
[edit system] aviva@router1# set archival configuration transfer-on-commit aviva@router1# set archival configuration archive-sites ftp://aviva:password@server1. mynetwork.com:/m20-config-archives
save command after committing the configuration, you are effectively
backing up the running configuration. The save command saves the configuration starting at your current hierarchy level. In this recipe, the commands are issued from the top hierarchy level (the [edit] level), so the entire configuration is saved. If you issue the command from a lower level, only that portion of the configuration is saved. The following command saves only the BGP configuration:[edit] aviva@router1# commit at 10:45 configuration check succeeds commit at will be executed at 2005-02-25 10:45:00 PST Exiting configuration mode
[edit]
aviva@router1#
commit at 22:45
configuration check succeeds
commit at will be executed at 2005-02-25 22:45:00 PST
Exiting configuration mode
[edit]
aviva@router1# commit at "2005-02-26 10:45"
configuration check succeeds
commit at will be executed at 2005-02-26 10:45:00 PST
Exiting configuration mode
commit at command, use the following command:
aviva@router1>
clear system commit
Pending commit cleared
commit at command. The first two commands in this recipe commit the configuration at a specific time on the current day, one at 10:45 a.m. and the second at 10:45 p.m. The third command schedules the commit at 10:45 a.m. on another day.commit command has actually executed by looking at the timestamp on the currently running configuration file:
[edit]
aviva@router1#
commit confirmed
commit confirmed will be automatically rolled back in 10 minutes unless confirmed
commit complete
[edit]
aviva@router1# commit
commit complete
commit confirmed command.commit confirmed command activates the configuration for 10 minutes. Within this time, you must explicitly confirm that the configuration is acceptable—either by issuing another commit command or by entering the commit check command—to make the provisional activation permanent. If you do not, the router loads and activates the previous configuration when 10 minutes have passed. You have to keep track of the time yourself, because the CLI doesn't warn you when it is expiring. The CLI displays a message if you do not confirm the commit when returning to the previous configuration:Broadcast Message from root@router1 (no tty) at 15:05 PDT… Commit was not confirmed; automatic rollback complete.
[edit]
aviva@router1# commit confirmed 1
commit confirmed will be automatically rolled back in 1 minutes unless confirmed
commit complete
rollback configuration mode command loads a previous router configuration as the candidate configuration:[edit] aviva@router1# rollback 1 load complete [edit] aviva@router1# show [edit] aviva@router1# commit commit complete
rollback command only loads the configuration, making it the candidate configuration, but does not activate it. The commit command activates the retrieved configuration. While using the show command here is optional, it's good practice to verify that the configuration you loaded is what you expect.
show system commit and
file list detail /config. You can use the file list detail /var/db/config command to find out when the older configuration files were activated and by whom. You can also see this information when you issue the rollback command by using the router's built-in help:
[edit]
aviva@router1# rollback ?
Possible completions:
<[Enter]> Execute this command
0 2005-02-25 12:31:52 PST by aviva via cli
1 2005-02-25 10:45:12 PST by aviva via cli commit at
2 2005-02-25 03:10:21 PST by root via cli
…
48 2005-02-19 03:01:04 PST by root via cli
49 2005-02-18 18:24:21 PST by aviva via cli
| Pipe through a command
aviva@router1> request system configuration rescue save
aviva@router1# run request system configuration rescue save
rollback
command. You use the
rescue configuration when you need to roll back to a known configuration or as a last resort if your router configuration and the backup configuration files become damaged beyond repair. The JUNOS software does not provide a default rescue configuration.[edit] aviva@router1# rollback rescue [edit] aviva@router1# commit commit complete
aviva@router1> file list /config
/config:
juniper.conf.1.gz
juniper.conf.2.gz
juniper.conf.3.gz
juniper.conf.gz
rescue.conf.gz
request system configuration rescue save command to overwrite the existing file. If you discover that the existing rescue configuration is not correct, but you don't have something to replace it with, delete the rescue configuration so no one accidentally uses it:
aviva@router1> request system configuration rescue delete
aviva@router1>
request system snapshot
request system snapshot command copies the files and filesystems from the current running active partitions to standby partitions. Specifically, it copies the / (root) filesystem to
/altroot, and the /config filesystem to
/altconfig. You see information about the copying as the command is running:
aviva@router1> request system snapshot
Copying '/' to '/altroot' .. (this may take a few minutes)
Copying '/config' to '/altconfig' .. (this may take a few minutes)
The following filesystems were archived: / /config
aviva@RouterA> request system snapshot media usb
aviva@RouterA> request system snapshot media removable-compact-flash
aviva@RouterA> request system storage cleanup
file list command to check what they contain:
aviva@RouterA> file list detail /cf/var/tmp
/cf/var/tmp:
total 28
-rw-r--r-- 1 root wheel 6379 Nov 3 00:10 cleanup-pkgs.log
drwxrwxrwx 2 root wheel 512 Apr 15 2005 install/
-rw-r----- 1 root wheel 2492 Nov 3 00:10 sampled.pkts
aviva@RouterA>
aviva@RouterA> request system software reboot media disk
aviva@RouterA> request system software reboot media removable-compact-flash or aviva@RouterA> request system software reboot media usb
aviva@router1>
request system snapshot
aviva@RouterA> request system snapshot media removable-compact-flash
snapshot command again, which copies the filesystem from the alternate media to the media from which you didn't boot.M-series and T-series routers normally boot from the internal flash drive, and the hard disk is the
alternate boot media.
J-series routers also normally boot from an internal flash drive, and the
alternate boot media is a compact flash card that is either installed in the router's compact flash drive or in a USB device connected to the router.
jinstall, from the Juniper Networks web site (http://www.juniper.net/support) and place it on a local server. You can install the software directly from the server:
aviva@router1> request system software add validate server1:jinstall-7.4R1.7-domestic
-signed. Tgz
aviva@router1> file copy server1:jinstall-7.4R1.7-domestic-signed.tgz /var/tmp aviva@server1's password: jinstall-7.4R1.7-domestic-signed.tgz 100% 64MB 774.5KB/s 01:24 aviva@router1> file list /var/tmp /var/tmp: cores/ install/ jbundle-7.4jbundle-7.4R1.7-domestic-signed.tgz
aviva@router1> request system software add validate ftp://aviva:prompt@
server1.mynetwork.com/jinstall-7.4R1.7-domestic-signed.tgz
aviva@router1> request system software add validate ftp://server1.mynetwork.com/jinstall-
7.4R1.7-domestic-signed.tgz
avive@router1> file copy ftp://aviva:prompt@
server1.mynetwork.com/jinstall-7.4R1.7-domestic
-signed.tgz /var/tmp/jinstall-
7.4R1.7-domestic-signed
Password for aviva@server1.mynetwork.com:
/var/home/aviva/…transferring.file.........YoE4Qe/
jinstall-7.4R1.7-domestic-signed.
tgz100% of 63 MB 794 kBps 00m00s
aviva@router1> request system software add validate /var/tmp/jinstall-
7.4R1.7-domestic-signed.tgz
aviva@router1> request system reboot
junos-jseries, from the Juniper Networks web site (http://www.juniper.net/support) and copy it to a local server. Y