JUNOS有两种模式:操作模式和配置模式。
1,操作模式
监控和排错 软件,网络连接、路由器硬件。
2,配置模式
test@lab2>
配置路由器包括:interface、路由信息、路由协议、用户访问、系统硬件参数。
test@lab2> configure
[edit]
test@lab2#
操作模式
(1)命令层次
(2)主要命令
{master}
lab@ex4200-vc> ?
Possible completions:
clear Clear information in the system
configure Manipulate software configuration information
file Perform file operations
help Provide help information
monitor Show real-time debugging information
mtrace Trace multicast path from source to receiver
op Invoke an operation script
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
{master}
lab@ex4200-vc>
(3)可以配合使用下列管道符号 |
compare Compare configuration changes with prior version
count Count occurrences
display Show additional kinds of information
except Show only text that does not match a pattern
find Search for first occurrence of pattern
hold Hold text without exiting the --More-- prompt
last Display end of output only
match Show only text that matches a pattern
no-more Don't paginate output
request Make system-level requests
resolve Resolve IP addresses
save Save output text to file
trim Trim specified number of columns from start of line
(4)使用set cli 命令设置 cli 环境
{master}
lab@ex4200-vc> set cli ?
Possible completions:
complete-on-space Set whether typing space completes current word
directory Set working directory
idle-timeout Set maximum idle time before login session ends
prompt Set CLI command prompt string
restart-on-upgrade Set whether CLI prompts to restart after software upgrade
screen-length Set number of lines on screen
screen-width Set number of characters on a line
terminal Set terminal type
timestamp Timestamp CLI output
{master}
(5)编辑环境在VT-100
(6)空格键功能
lab@ex4200-vc> show i
^
'i' is ambiguous.
Possible completions:
igmp Show Internet Group Management Protocol information
igmp-snooping Show IGMP snooping information
ike Show Internet Key Exchange information
interfaces Show interface information
ipsec Show IP Security information
isis Show Intermediate System-to-Intermediate System information
(7)?号命令提示
lab@ex4200-vc> ?
Possible completions:
clear Clear information in the system
configure Manipulate software configuration information
file Perform file operations
help Provide help information
monitor Show real-time debugging information
mtrace Trace multicast path from source to receiver
op Invoke an operation script
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
配置模式
(1) 进入配置模式
root@lab2> configure
Entering configuration mode
[edit]
root@lab2#
example:
root@lab2#set system services ftp
system {
services {
ftp;
}
}
(2) 配置模式层次
(3)使用edit 命令类似于cd 命令
使用edit chassis alarm ethernet 可以直接在ethernet 这一级操作而不需要 set chassis alarm Ethernet 操作。
(4) 使用up 和top 命令
user@host# up
[edit chassis alarm]
user@host# top
[edit]
(5)显示Candidate 配置
[edit]
user@host# show chassis alarm
user@host# edit chassis alarm
[edit chassis alarm]
user@host# show
[edit chassis alarm]
(6)区分配置文件
比较Candidate 与active 配置的区别
[edit chassis]
user@host# show | compare
alarm {
xxx {
+ xxx xxx
- xxx xxx;
}
}
其它选项
user@host# show | compare filename
user@host# show | compare rollback number
(7)配置的差异更新
root@router# show | compare
[edit interfaces]
[edit]
root@router# show | compare | save /var/tmp/patch.cfg
Wrote 9 lines of output to '/var/tmp/patch.cfg'
[edit]
root@router# load patch /var/tmp/patch.cfg
load complete
(8)删除配置
[edit]
user@host# edit chassis alarm xxx
[edit chassis alarm xxxx]
user@host# delete xxx
[edit chassis alarm xxxx]
user@host# delete xxx
[edit chassis alarm xxxx]
user@host#
9)配置生效
使用 commit 是配置生效。rollback 恢复配置。
ser@host#commit
and-quit 如果配置成功退出配置模式
at 在定义的时间后commit 配置
check 检测配置,不改变配置
confirmed 知道回滚等到下一个commit 模式是10 分钟
rollback 恢复配置。系统默认9 个配置在 /config/ 3 个。file show /config/6 个
rollback 或rollback 0 就恢复到刚刚改变的配置
(10)配置模式层次改变。
使用exit 退回到上一层配置模式
使用exit configuration-mode 从任意层次退去配置模式
(11)保存加载配置文件
可以使用save filename 在任何配置模式保持这个层次的配置内容到一个指定存放位置便于下
一次load。
[edit]
cli# save filename
[edit]
cli#
load (replace | merge | override)
replace 取代现有的配置并且配置正确
merge 合并配置
override 取代现有的配置
user@host# load merge /var/db/config/juniper.conf.4
可以通过 show system storage 查看文件系统,或用file show