はじめに:CLI のクイック ツアー
ネットワーク管理者は、 Junos OS Evolved CLI を使用して、設定の変更、運用モードと設定モードの切り替え、ユーザー アカウントの作成、一部の基本的なコマンドの実行を行うために、以下のトピックを参照してください。
Junos OS Evolved に固有の入門および概要情報については、 Introducing Junos OS Evolvedを参照してください。
この Junos OS Evolved CLI ガイドは、 読者が Junos OS Evolved の概念と動作原理を理解していることを前提としています。
コマンド ライン インタフェースを使い始める
このトピックでは、 Junos OS Evolved CLIを起動する方法、コマンド階層を表示する方法、および小規模な設定変更を行う方法について説明します。
開始する前に、デバイス ハードウェアがセットアップされ、 Junos OS Evolved がインストールされていることを確認してください。コンソールとデバイスを直接接続するか、またはコンソールから SSH または Telnet を使用してネットワークにアクセスできる必要があります。デバイスがセット アップされていない場合は、先に進む前に、デバイスに同梱されているインストール手順に従ってください。
デバイスにログインして CLI を起動するには、次の手順に従います。
デバイスで初めて root アカウントを使用する場合、デバイスは root に必要なパスワードなしで出荷されていることを忘れないでください。初めてコンフィギュレーションをコミットするときは、root パスワードを設定する必要があります。Telnet セッションでは、root アクセスは許可されていません。SSH 接続経由で root アクセスを有効にするには、 system services ssh root-login allow
ステートメントを設定する必要があります。
CLI コマンドは、プラットフォームやソフトウェアのリリースによって異なる場合があります。CLI には、利用可能なコマンドに関するヘルプを得るための方法がいくつかあります。このセクションでは、ヘルプの確認方法に関する例をいくつか示します。
-
?
を入力すると、動作モードで使用可能な最上位のコマンドが表示されます。root@> ? Possible completions: clear Clear information in the system configure Manipulate software configuration information diagnose Invoke diagnose script file Perform file operations help Provide help information 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
-
file ?
を入力して、file
コマンドのすべての補完候補を表示します。root@> file ? Possible completions: <[Enter]> Execute this command archive Archives files from the system checksum Calculate file checksum compare Compare files copy Copy files (local or remote) delete Delete files from the system list List file information rename Rename files show Show file contents source-address Local address to use in originating the connection | Pipe through a command
-
file archive ?
と入力すると、file archive
コマンドのすべての補完候補が表示されます。root@> file archive ? Possible completions: compress Compresses the archived file using GNU gzip (.tgz) destination Name of created archive (URL, local, remote, or floppy) source Path of directory to archive
オペレーション モードとコンフィギュレーション モードの切り替え
Junos OS Evolvedを実行しているデバイスを監視および設定する場合、モードの切り替えが必要になる場合があります。運用モードとコンフィギュレーションモードを切り替えると、コマンド プロンプトも変化します。動作モード プロンプトは、直角ブラケット(>
)である。コンフィギュレーション モードのプロンプトは、ポンド記号またはハッシュ記号(#
)です。
動作モードと設定モードを切り替える方法は、以下の通りです。
キーボードシーケンスを使用して、CLIを移動したり編集することができます。
Junos OS Evolved CLI のキーボード シーケンスを使用して、コマンド ラインを移動したり編集したりできます。また、キーボードシーケンスを使用して、最近実行されたコマンドのリストをスクロールすることもできます。以下の表は、CLIのキーボードシーケンスの一部を示しています。Emacsで使用されるものと同じものです。
キーボードシーケンス |
アクション |
---|---|
Ctrl+b |
カーソルを1 文字戻します。 |
Esc+bまたはAlt+b |
カーソルを1単語戻します。 |
Ctrl+f |
カーソルを1 文字進めます。 |
Esc+fまたはAlt+f |
カーソルを1単語進めます。 |
Ctrl+a |
カーソルをコマンドラインの先頭に移動します。 |
Ctrl+e |
カーソルをコマンドラインの末尾に移動します。 |
Ctrl+h、Delete、 またはバックスペース |
カーソルの前にある文字を削除します。 |
Ctrl+d |
カーソルの位置にある文字を削除します。 |
Ctrl+k |
カーソルの位置からコマンドラインの末尾までのすべての文字を削除します。 |
Ctrl+uまたは Ctrl+x |
コマンドラインのすべての文字を削除します。 |
Ctrl+w、Esc+Backspace、 または Alt+Backspace |
カーソルの前にある単語を削除します。 |
Esc+dまたはAlt+d |
カーソルの後ろにある単語を削除します。 |
Ctrl+y |
カーソルで最後に削除されたテキストを挿入します。 |
Ctrl+l |
現在の行を再度入力します。 |
Ctrl+p |
最近実行されたコマンドのリストを後ろにスクロールします。 |
Ctrl+n |
最近実行されたコマンドのリストを前にスクロールします。 |
Ctrl+r |
検索文字列に一致する行を逆の順序で、CLI履歴から順次検索します。 |
Esc+/または Alt+/ |
現在の単語がプレフィックスである単語をCLI 履歴から検索します。 |
Esc+。またはAlt+。 |
最近コマンドラインに入力された単語のリストを後ろにスクロールします。 |
Esc+number sequence またはAlt+number sequence |
キーボードシーケンスを実行する回数を指定します。 |
ジュニパーネットワークス デバイスのユーザー アカウントを設定する
このトピックでは、ルート アカウントを使用して Juniper Networks デバイスにログインし、新しいユーザー アカウントを設定する方法について説明します。自分自身のアカウントを設定したり、テスト アカウントを作成したりできます。
デバイスに新しいユーザー アカウントを設定するには、次の手順に従います。
これで、CLI を使用してデバイスの状態を表示し、簡単な設定変更ができました。
例を含めた、デバイスの設定に必要なコマンドの詳細については、 『Junos OS Evolved 』設定ガイドを参照してください。
設定モードでのCLIエディターの使用
このトピックでは、CLIエディターで設定モードに入るために使用できる基本的なコマンドについて説明します。また、このトピックでは、設定階層のナビゲーション、ヘルプの取得、および設定セッション中に行う変更のコミットまたは取り消しに使用するコマンドについても説明します。
タスク |
コマンド/ステートメント |
例 |
---|---|---|
設定の編集 | ||
構成モードにします。 CLI を起動すると、デバイスは動作モードになります。設定モードを明示的に入力する必要があります。入力すると、CLI プロンプトが [ |
configure |
user@host> [edit] user@host# |
ステートメントの階層を作成します。
|
edit hierarchy-level value |
[edit]
user@host# [edit security zones security-zone myzone] user@host# |
ステートメント階層を作成し、識別子値を設定します。
|
set hierarchy-level value |
[edit]
user@host# [edit] user@host# |
階層の移動 | ||
既存の階層レベルに下がります。 |
edit hierarchy-level |
[edit]
user@host# [edit security zones] user@host# |
1 レベル上の階層に移動します。 |
up |
[edit security zones]
user@host# [edit security] user@host# |
階層の最上位に移動します。 |
top |
[edit security zones]
user@host# [edit] user@host# |
変更のコミットまたは取り消し | ||
設定をコミットします。 |
commit |
[edit]
user@host# commit complete |
現在のセッションから変更がロールバックされます。
|
rollback |
[edit]
user@host# load complete |
設定モードの終了 | ||
設定をコミットし、設定モードを終了します。 |
commit and-quit |
[edit] user@host# commit and-quit user@host> |
設定をコミットせずに、設定モードを終了します。 設定モードを終了する前に、 |
exit |
[edit]
user@host# The configuration has been changed but not committed Exit with uncommitted changes? [yes,no] (yes) |
ヘルプの取得 | ||
現在の階層レベルで有効なオプションのリストを表示します。 |
? |
[edit ]
user@host# Possible completions: <[Enter]> Execute this command > functional-zone Functional zone > security-zone Security zones | Pipe through a command [edit] |
ジュニパーネットワークス デバイスのステータスを確認
動作モードでは、 show
コマンドを使用してデバイスの状態を確認し、デバイスの活動を監視できます。
show
コマンドに慣れるには、以下を使用します。
show ?
と入力して、ルーターの監視に使用できるshow
コマンドのリストを表示します。root@>
show ?
Possible completions: accounting Show accounting profiles and records aps Show Automatic Protection Switching information arp Show system Address Resolution Protocol table entries as-path Show table of known autonomous system paths bfd Show Bidirectional Forwarding Detection information bgp Show Border Gateway Protocol information chassis Show chassis information class-of-service Show class-of-service (CoS) information cli Show command-line interface settings configuration Show current configuration connections Show circuit cross-connect connections dvmrp Show Distance Vector Multicast Routing Protocol info dynamic-tunnels Show dynamic tunnel information information esis Show end system-to-intermediate system information firewall Show firewall information helper Show port-forwarding helper information host Show hostname information from domain name server igmp Show Internet Group Management Protocol information ike Show Internet Key Exchange information ilmi Show interim local management interface information interfaces Show interface information ipsec Show IP Security information ipv6 Show IP version 6 information isis Show Intermediate System-to-Intermediate System info l2circuit Show Layer 2 circuit information l2vpn Show Layer 2 VPN information lacp Show Link Aggregation Control Protocol information ldp Show Label Distribution Protocol information link-management Show link management information llc2 Show LLC2 protocol related information log Show contents of log file mld Show multicast listener discovery information mpls Show Multiprotocol Label Switching information msdp Show Multicast Source Discovery Protocol information multicast Show multicast information ntp Show Network Time Protocol information ospf Show Open Shortest Path First information ospf3 Show Open Shortest Path First version 3 information passive-monitoring Show information about passive monitoring pfe Show Packet Forwarding Engine information pgm Show Pragmatic Generalized Multicast information pim Show Protocol Independent Multicast information policer Show interface policer counters and information policy Show policy information ppp Show PPP process information rip Show Routing Information Protocol information ripng Show Routing Information Protocol for IPv6 info route Show routing table information rsvp Show Resource Reservation Protocol information sap Show Session Announcement Protocol information security Show security information services Show services information snmp Show Simple Network Management Protocol information system Show system information task Show routing protocol per-task information ted Show Traffic Engineering Database information version Show software process revision levels vpls Show VPLS information vrrp Show Virtual Router Redundancy Protocol informationshow chassis routing-engine
コマンドを使用して、ルーティング エンジンのステータスを表示します。root@>
show chassis routing-engine
Routing Engine status: Slot 0: Current state Master Election priority Master (default) Temperature 31 degrees C / 87 degrees F CPU temperature 32 degrees C / 89 degrees F DRAM 768 MB Memory utilization 84 percent CPU utilization: User 0 percent Background 0 percent Kernel 1 percent Interrupt 0 percent Idle 99 percent Model RE-2.0 Serial ID b10000078c10d701 Start time 2005-12-28 13:52:00 PST Uptime 12 days, 3 hours, 44 minutes, 19 seconds Load averages: 1 minute 5 minute 15 minute 0.02 0.01 0.00-
show system storage
コマンドを使用して、デバイスで使用可能なストレージを表示します。root@>
show system storage
Filesystem Size Used Avail Capacity Mounted on /dev/root 33M 33M 0 100% /run/initramfs /dev/vda2 16G 1.2G 14G 8% /soft /dev/vda5 3.0G 32M 2.8G 2% /data /dev/vda7 16G 4.5G 11G 31% /var /dev/loop0 2.3G 3.6M 2.2G 1% /data/var/external devtmpfs 7.7G 0 7.7G 0% /dev /tmp 7.7G 0 7.7G 0% /run/initramfs/uswitch/tmp /dev/loop1 4.2M 4.2M 0 100% /run/initramfs/uswitch/data/hashes/2fe9eb9ec67b489f02706e8d527937dbb2c0654b /dev/loop2 29M 29M 0 100% /run/initramfs/uswitch/data/hashes/ce7ca7504fda6e5a4ebb5476d1afaaee21ccd40a /dev/loop3 36M 36M 0 100% /run/initramfs/uswitch/data/hashes/b1e137c20a6c197bb5e32473ac59b4e79ed9feef /dev/loop4 602M 602M 0 100% /run/initramfs/uswitch/data/hashes/4c4d7a56fb4e27b41dbc4c994decbb0e4c3bf732 /dev/loop5 12M 12M 0 100% /run/initramfs/uswitch/data/hashes/3a20f9d431928916ad4651e5106dc88400c62de4 /dev/loop6 51M 51M 0 100% /run/initramfs/uswitch/data/hashes/e9da1c4dfa20207a83b1d1d930f372d5239452ab /dev/loop7 9.8M 9.8M 0 100% /run/initramfs/uswitch/data/hashes/bc5da75f89c534aac7b7c085001607fb630522b4 /dev/loop8 59M 59M 0 100% /run/initramfs/uswitch/data/hashes/048c311a16be258ee61e9f5d7620a697e14eeec5 /dev/loop9 6.4M 6.4M 0 100% /run/initramfs/uswitch/data/hashes/7eccac8ea0accc0caee8806515e165c1ccc688a4 /dev/loop10 34M 34M 0 100% /run/initramfs/uswitch/data/hashes/20ed997fccd04026da26c9138397b4908921a207 /dev/loop11 8.2M 8.2M 0 100% /run/initramfs/uswitch/data/hashes/93c46df17bc4ff252d945b3f54545d169ae9db99 /dev/loop12 33M 33M 0 100% /run/initramfs/uswitch/data/hashes/b0f7d08ed2bf60f4d1de1638d3a99ef33e34a6da /dev/loop13 7.2M 7.2M 0 100% /run/initramfs/uswitch/data/hashes/b5bcf77cdf5fda2b7fdefe785430901b9495959a /dev/loop14 4.8M 4.8M 0 100% /run/initramfs/uswitch/data/hashes/4b8707670eb7a3419fd16d4a743ce868e0b6c646 /dev/loop15 8.0K 8.0K 0 100% /run/initramfs/uswitch/data/hashes/0293de3480e2b1d19dce284adeeb84937e7738aa /dev/loop16 147M 147M 0 100% /run/initramfs/uswitch/data/hashes/092a08988fac0a35f755e3324633b032dc3541a1 uswitchd 4.2M 4.2M 0 100% / /dev/vda1 189M 5.3M 170M 4% /boot /dev/vda6 984M 1.3M 916M 1% /data/config /tmp 7.7G 48K 7.7G 1% /tmp tmpfs 7.7G 6.6M 7.7G 1% /run tmpfs 7.7G 236M 7.5G 3% /dev/shm tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup tmpfs 1.6G 0 1.6G 0% /run/user/928
関連項目
設定変更のロールバック
このトピックでは、 rollback
コマンドを使用して、コミットされていないが改訂されたコンフィギュレーションを、最後にコミットした Junos OS Evolved 構成の状態に戻す方法を説明します。 rollback
コマンドは、設定を変更した後、それを保持しないことを決定した場合に便利です。
次の手順は、Juniper Networks デバイスで SNMP ヘルスモニターを設定し、ヘ ルスモニターを含まない、最近コミットされた設定に戻る方法を示しています。SNMP 正常性監視が設定されている場合、デバイスのファイル システムの使用率、CPU の使用率、メモリ使用率に関する、事前定義された監視情報が NMS(ネットワーク管理システム)に提供されます。
設定モードにします。
user@host>
configure
entering configuration mode [edit] user@host#SNMP の現在の設定があれば、それを表示します。
[edit] user@host#
show snmp
SNMP がデバイスで設定されていないため、
snmp
ステートメントは表示されません。正常性監視を設定します。
[edit] user@host#
set snmp health-monitor
新しい設定を表示します。
[edit] user@host#
show snmp
health-monitor;health-monitor
ステートメントは、SNMP 正常性監視がデバイスで設定されていることを示します。rollback
設定モード コマンドを入力して、直近のコミットされた設定に戻します。[edit] user@host#
rollback
load complete再度設定を表示して、変更がなくなったことを確認します。
[edit] user@host#
show snmp
snmp
設定ステートメントは表示されません。正常性監視は設定されていません。commit
コマンドを入力して、ロールバックした設定をアクティブにします。[edit] user@host#
commit
設定モードを終了します。
[edit] user@host#
exit
Exiting configuration mode
また、 rollback
コマンドを使用して、以前の設定に戻すこともできます。