搜档网
当前位置:搜档网 › Juniper CLI基本配置

Juniper CLI基本配置

Juniper CLI基本配置(小结)

CLI配置:
操作模式
进入和退出操作模式:
下面的例子显示了使用用户名 root登陆到路由器进入到操作模式
login: root
Password:
Last login: Wed Nov 28 18:40:03 from 192.168.161.250
--- JUNOS 5.0R2.4 built 2001-09-25 02:34:13 UTC
root@52network>
Exit the operational mode by using the quit command:
root@52network> quit
52network (ttyd0)
login:

设置CLI:
1. set cli命令:
root@52network> set CLI ?
Possible completions:
complete-on-space Toggle word completion on space
idle-timeout Set the CLI maximum idle time
prompt Set the CLI command prompt string
restart-on-upgrade Set CLI to prompt for restart after a software upgrade
screen-length Set number of lines on screen
screen-width Set number of characters on a line
terminal Set terminal type

2.set CLI complete-on-space
这个命令将允许自动完成命令,语法如下:
set CLI complete-on-space

例子:

root@52network> show p
^
'p' is ambiguous.
Possible completions:
pfe Show packet forwarding engine data
pim Show information about PIM
policy Show policy information
root@52network> show po
root@52network> show policy

3.set CLI idle-timeout
设置CLI会话空闲时的最大时间
语法:
set CLI idle-timeout (0-100000 minutes)
例子:
root@52network> set CLI idle-timeout 1
Idle timeout set to 1 minute
root@52network> Warning: session will be closed in 10 seconds if there is no activity
Idle timeout exceeded: closing session

4.set CLI prompt
设置cli会话操作模式下的提示符
语法:
set cli prompt
例子:
root@52network>set cli prompt newprompt
newprompt>

5.set CLI restart-on-upgrade
设置当软件更新完成,将提示去重新启动路由器,默认打开
语法:
set CLI restart-on-upgrade


6.set CLI screen-length and screen-width
设置cli屏幕长度和宽度
语法:
set CLI screen-length Number of lines on screen (0..100000)
set CLI screen-width Number of characters on a line (0..100000)
例子:
root@52network> set CLI screen-length 2
Screen length set to 2

root@52network> set CLI screen-width 5
Screen width set to 5

7. set CLI terminal
设置路由器的终端类型
root@52network> set CLI terminal ?
Possible completions:
ansi ANSI-compatible terminal
small-xterm Small (24 line) xterm window
vt100 VT100-compatible terminal
xterm Large (65 line) xterm window

7. set date
设置时间
语法:
set date

er Ctrl-b
Move cursor forward one character Ctrl-f
Move cursor to beginning of line Ctrl-a
Move cursor to end of line Ctrl-e
Delete character before the cursor Ctrl-h, Delete, Backspace
Delete character the cursor is on Ctrl-d
Delete word before cursor Ctrl-w, Esc-Backspace, Alt-Backspace
Insert most recently deleted text at the cursor Ctrl-y
Redraw the current line Ctrl-l
Scroll backward through history Ctrl-p
Scroll forward through history Ctrl-n
Search CLI history in reverse order Ctrl-r
Move cursor back one word Esc-b or Alt-b
Move cursor forward one word Esc-f or Alt-f
Delete the word after the cursor Esc-d, Alt-d
Search CLI history Esc-/
Specify the number of times to execute a key-board sequence (number from one to nine)

Esc-number sequence, Alt-number sequence

9. cli注释信息:
root@52network> show con
^
'con' is ambiguous.
(命令不完整)
root@52network> set CLI
^
syntax error, expecting
(语法错误)

10.控制cli输出信息:
1.显示输出:
root@52network> show configuration
version 5.0R3.3;
system {
host-name 52network;
login {
user test {
uid 2001;
class superuser;
authentication {
encrypted-password "$Upc0"; # SECRET-D
ATA
}
}
user root {
uid 2000;
class superuser;
authentication {
encrypted-password "0"; # SECRET-D
ATA
---(more)---

定制输出信息使用管道参数:
这个参数可以帮助在一个大的文件中快速的找到制定的信息
root@52network> show configuration | ?
Possible completions:
count Count occurrences
display Display additional information
except Show only text that does not match a pattern
find Search for the first occurrence of a pattern
hold Hold text without exiting the --More-- prompt
match Show only text that matches a pattern
no-more Don't paginate output
resolve Resolve IP addresses
save Save output text to a file
trim Trim specified number of columns from start of line

2.过滤输出信息
1. count:
显示文件或列表行数
语法:
show route protocol isis | count
例子:
root@52network> show configuration | count
Count: 143 lines

root@52network> show route protocol isis | count
Count: 59 lines
2.display:
display命令提供显示输出xml格式
语法:
show configuration | display xml
例子:
root@52network> show configuration | display xml | find interfaces


fxp0

100m
full-duplex

0
802.3-llc



192.168.161.16/24








3.except:
此参数设置显示输出信息不包含指定信息
语法:
show configuration | except pattern to avoid
例子:
root@52network> show configuration
version 5.0R3.3;
system {
host-name 52network;
login {
user test {
uid 2001;
class superuser;
authentication {
encrypted-password "$1$A"; # SECRET-DATA
}
}
user root {
uid 2000;
class superuser;
authentication {
encrypted-password "niG0"; # SECRET-DATA

root@52network> show configuration | except uid
version 5.0R3.3;
system {
host-name 52network;
login {
user test {
class superuser;
authentication {
encrypted-password "$1$A"; # SECRET-DATA
}
}
user root {
class superuser;
authentication {
encrypted-password "niG0"; # SECRET-DATA

4.find 和match命令
find查找指定信息,并且显示所有相似信息
match查找指定信息,并且只显示此指定信息
语法:
show route | find pattern to search for
show route | match pattern to match against
例子:
root@52network> show route | find 192.168.161.0
192.168.161.0/24 *[Direct/0] 3d 02:05:58
> via fxp0.0
192.168.161.16/32 *[Local/0] 3d 02:05:58
Local

root@52network> show route | match 192.168.161.0
192.168.161.0/24 *[Direct/0] 3d 02:06:08

5.hold
hold参数设置通过up和down翻动查看文件。
语法:
show configuration | hold
6.save
将捕获信息保存到文件中
语法:
show configuration | save Output file name (or URL)
file list <[Enter]>
file show Filename to display
例子:
root@52network> show configuration | save my_local_file
Wrote 54 l

ines of output to 'my_local_file'

root@52network> file list
.ssh/
my_local_file

root@52network> file show my_local_file
version 4.3R1.4;
system {
host-name 52network;
ports {
console type vt100;
}
login {
class superuser {
permissions all;
}
user root {
uid 2000;
root@52network> show configuration | save ftp://192.168.5.107/my_ftp_file
Wrote 54 lines of output to 'ftp://192.168.5.107/my_ftp_file'

7.trim
trim参数设置显示输出整齐的行数
语法:
show configuration | trim Number of columns to trim
例子:
root@52network> show configuration | trim 3
sion 4.3R1.4;
tem {
host-name 52network;
ports {
console type vt100;

8.搜索输出信息
搜索和操作屏幕信息,下面是一些常用快捷键
Keyboard Sequences for Searching and Manipulating On-screen Data

Function Keyboard Sequence
List the keyboard sequences available when the -(more)- prompt is displayed h
Display output all at once (like no-more option) N
Repeat previous search for a string n
Search for a text string (like match option) m or M
Search, ignoring a text string (like except option) e or E
Do not redisplay prompt after displaying the output (like hold option) H
Clear match conditions and display complete output c or C
Save output to a file (like save option) s or S
Scroll down one line Enter, k, Ctrl-m, Ctrl-n, down arrow
Scroll down a half screen Tab, d, Ctrl-d, Ctrl-x
Scroll down whole screen Space, Ctrl-f
Scroll down to bottom of output Ctrl-e, G
Display previous line output j, Ctrl-h, Ctrl-p, up arrow
Scroll up a half screen u, Ctrl-u
Scroll up a whole screen b, Ctrl-b
Scroll to top of screen g, Ctrl-a
Search forward /string
Search backward ?string

/参数可以非常有用的帮助我们搜索文件。输入 / 参数,然后输入字符串。
下面的例子中,我们搜索bgp的信息
root@52network> show configuration
version 5.0R2.4;
system {
host-name 52network;
login {
class superuser {
permissions all;
}
user root {
uid 2000;
class superuser;
authentication {
encrypted-password "lGdV/"; # SECRET-DATA
Search for: bgp
bgp {
traceoptions {
file 539test4again2;
flag all;
}
local-address 2.2.2.2;
group IPV4_IBGP_ONLY {
type internal;
family inet {
unicast;
}
family inet-vpn {
unicast;
}
neighbor 4.4.4.4 {
traceoptions {
file vpntest;
flag all;
}

}
}
}
ospf {

11.查看cli历史信息:
root@52network> show CLI history
09:48:23 ?show route table mpls.0
09:48:33 ?show route table inet.0
09:48:42 ?show chassis hardware
09:48:50 ?show CLI history
12.查看用户信息
root@52network> show system users
8:04AM up 41 days, 18 hrs, 2 users, load averages: 0.02, 0.01, 0.00
USER TTY FROM LOGIN@ IDLE WHAT
root d0 - 8:03AM - CLI
lab p0 192.168.161.10 7:55AM 2 /bin/csh
13.cli帮助信息:
root@52network> help ?
Possible completions:
reference Reference material
topic Help for high level topics

topic (主题信息 )
下面帮助信息告诉你如何配置多播源发现协议(msdp)
root@52network> help topic msdp group

Configure MSDP Groups

An MSDP router must know which routers are its peers (neighbors). You define
the peer relationships explicitly by configuring the neighboring routers that
are the MSDP peers of the local router. After peer relationships are
established, the MSDP peers exchange messages to advertise active multicast
sources. You can arrange peers into different groups. Each group must contain
at least one peer. Arranging peers into groups is useful if you want to block
sources from some peers and accept them from others or set tracing options on
one group and not the others.
To configure MSDP groups, include one or more of the following statements at
the [edit protocols msdp group group-name] hierarchy level:
[edit protocols msdp]
group group-name {
disable;
export [ policy-name ];
import [ policy-name ];
local-address address;
mode <(mesh-group | standard)>;
traceoptions {
file name
<(world-readable | no-world-readable)>;
traceflag flag ;
}
peer address; {
disable;
export [ policy-name ];
import [ policy-name ];
local-address address;
traceoptions {
file name

<(world-readable | no-world-readable)>;
flag flag ;
}
}

The individual statements are discussed in separate sections.

reference 参数将告诉更多的一些详细信息

root@52network> help reference msdp group

group

Syntax

group group-name {
disable;
export [ policy-name ];
import [ policy-name ];
local-address address;
mode (mesh-group|standard)
traceoptions {
file name
<(world-readable | no-world-rea

dable)>;
flag flag ;
peer address; {
disable;
export [ policy-name ];
import [ policy-name ];
local-address address;
traceoptions {
file name
<(world-readable | no-world-readable)>;
flag flag ;
}
}
}

Hierarchy Level

[edit protocols msdp]

Description

Define an MSDP peer group. MSDP peers within groups share common
traceoptions, if present and not overridden for an individual
peer with the peer statement. To configure multiple MSDP groups, include multiple group
statements.

By default, the group's options are identical to the global MSDP options.
To override the global options, include group-specific options within the
group statement.

The group must contain at least one peer.

Options