查看配置
配置 show
模式命令显示运行 Junos OS设备的当前配置。
显示当前配置
要显示瞻博网络设备的当前配置,在 show
配置模式下使用命令。此命令显示当前层级或指定层级的配置。
user@host# show <statement-path>
配置语句按固定顺序出现,接口按类型的字母顺序显示,然后按插槽编号、PIC 编号和端口号的数字顺序出现。请注意,配置设备时,您可以按任意顺序输入语句。
您还可以使用 CLI 操作模式 show configuration
命令显示上次提交的配置,即当前在路由器上运行的配置:
user@host> show configuration
显示配置时,配置顶部的时间戳标明了上次更改配置的时间:
## Last commit: 2018-07-18 11:21:58 PDT by echen version 8.3
如果在配置模式下发出 show
命令时省略了特定层级的必需语句,则将显示一条消息,指示缺少哪条语句。如果缺少必需语句,则 CLI 在每次发出 show
命令时都会继续显示此消息。
例如:
[edit]
user@host# show
protocols {
pim {
interface so-0/0/0 {
priority 4;
version 2;
# Warning: missing mandatory statement(s): 'mode'
}
}
}
CLI 配置中包含的不受支持的语句将在配置中显示“不支持”文本。例如,如果在不受支持的平台上配置了语句,CLI 将显示一条消息,说明将在配置中忽略该语句,因为该语句配置在了不受支持的平台上。使用选项发出 show
命令 | display xml
时,您可以看到 unsupported="unsupported”
不受支持的配置的属性。
当 RPC 调用中包含属性时 unsupported="unsupported"
,将向脚本提供文本配置或 XML 配置中包含的“不支持” <get-configuration>
属性。
示例:显示当前配置
以下示例说明如何显示当前设备配置。
设置并提交配置:
[edit] user@host#set protocols ospf area 0.0.0.0 interface xe-0/0/0 hello-interval 5
[edit] user@host#commit
commit complete [edit] user@host#quit
exiting configuration mode
显示当前配置:
[edit]
user@host# show
protocols {
ospf {
area 0.0.0.0 {
interface xe-0/0/0 {
hello-interval 5;
}
}
}
}
显示特定层级的配置:
[edit]
user@host# show protocols ospf area 0.0.0.0
interface xe-0/0/0 {
hello-interval 5;
}
下移一个级别并显示该级别的配置:
[edit] user@host#edit protocols ospf area 0.0.0.0
[edit protocols ospf area 0.0.0.0] user@host#show
interface xe-0/0/0 { hello-interval 5; }
显示上次提交的配置:
user@host> show configuration
## Last commit: 2018-08-10 11:21:58 PDT by user
version 8.3
protocols {
ospf {
area 0.0.0.0 {
interface xe-0/0/0 {
hello-interval 5;
}
}
}
}
显示有关配置的附加信息
仅在配置模式下,要显示有关设备配置的附加信息,请 display detail
结合命令在管道 ( |) 之后结合使用 show
命令。附加信息包括帮助字符串,用于说明添加和修改配置语句所需的每个配置语句和权限位。
user@host# show <hierarchy-level> | display detail
例如:
[edit]
user@host# show | display detail
##
## version: Software version information
## require: system
##
version 21.3-202107190949.0;
system {
##
## host-name: Host name for this router
## match: ^[[:alnum:]._-]+$
## require: system
##
}
host-name router-name;
##
## domain-name: Domain name for this router
## match: ^[[:alnum:]._-]+$
## require: system
##
domain-name isp.net;
##
## backup-router: Address of router to use while booting
##
backup-router 192.168.100.1;
root-authentication {
##
## encrypted-password: Encrypted password string
##
encrypted-password "$ABC123"; # SECRET-DATA
}
##
## name-server: DNS name servers
## require: system
##
name-server {
##
## name-server: DNS name server address
##
208.197.1.0;
}
login {
##
## class: User name (login)
## match: ^[[:alnum:]_-]+$
##
class super-user {
##
## permissions: Set of permitted operation categories
##
permissions all;
}
...
##
## services: System services
## require: system
##
services {
## services: Service name
##
ftp;
##
## services: Service name
##
telnet;
##
}
syslog {
##
## file-name: File to record logging data
##
file messages {
##
## Facility type
## Level name
##
any notice;
##
## Facility type
## Level name
##
authorization info;
}
}
}
chassis {
alarm {
sonet {
##
## lol: Loss of light
## alias: loss-of-light
##
lol red;
}
}
}
interfaces {
##
## Interface name
##
xe-2/1/1 {
atm-options {
##
## vpi: Virtual path index
## range: 0 .. 255
## maximum-vcs: Maximum number of virtual circuits on this VP
##
vpi 0 maximum-vcs 512;
}
##
## unit: Logical unit number
## range: 0 .. 16384
##
unit 0 {
##
## vci: ATM point-to-point virtual circuit identifier ([vpi.]vci)
}
##
vci 0.128;
}
}
...
显示配置中的 set 命令
在配置模式下,您可以将配置显示为重新创建配置所需的一系列配置模式命令。如果您不熟悉如何使用配置模式命令,或者想要剪切、粘贴和编辑显示的配置,此功能会很有用。
要将配置显示为从层次结构顶层将配置重新创建为 set
命令所需的一系列配置模式命令,请发出 show
带有 display set
选项的配置模式命令:
user@host# show | display set <explicit>
当您使用| display set
管道选项发出show configuration
命令,以命令形式set
查看配置时,您没有权限查看的配置部分将替换为文本ACCESS-DENIED
。
您可以将选项与命令一起<explicit>
| display set
,在从层次结构顶层配置某些语句时,将系统内部创建的所有配置语句显式显示为一系列集命令。
例如,假设您发出 set 接口 ge-0/0/0.0 系列 inet 配置模式命令。然后,使用 show interfaces ge-0/0/0 | 显示生成的配置显示 set 命令。输出显示您输入的相同的 set 命令。如果包括显式参数,则输出还显示创建指定家族 inet 语句的层次结构所需的配置语句。因此,特别是对于此示例,除了 set 接口 ge-0/0/0/0.0 系列 inet 语句外,输出还包括 set 接口 ge-0/0/0 单元 0 语句。
示例:显示配置中的 set 命令
在 set
[edit interfaces
] 层级显示配置中的命令:
[edit interfaces xe-0/0/0] user@host#show
unit 0 { family inet { address 192.107.1.230/24; } family iso; family mpls; } inactive: unit 1 { family inet { address 10.0.0.1/8; } } [edit interfaces ge-0/0/0] user@host#show | display set
set interfaces ge-0/0/0 unit 0 family inet address 192.107.1.230/24 set interfaces xe-0/0/0 unit 1 family inet address 10.0.0.1/8 deactivate interfaces xe-0/0/0 unit 1 [edit interfaces ge-0/0/0] user@host#show | display set | explicit
set interfaces ge-0/0/0 unit 0 family inet address 192.107.1.230/24 set interfaces xe-0/0/0 unit 0 family iso set interfaces xe-0/0/0 unit 0 family mpls set interfaces ge-0/0/0 unit 0 family inet set interfaces ge-0/0/0 unit 0 set interfaces xe-0/0/0 unit 1 family inet address 10.0.0.1/8 deactivate interfaces xe-0/0/0 unit 1
要将配置显示为从当前层级重新创建配置所需的一系列配置模式命令,请发出 show
带有 show | display set relative
选项的配置模式命令。您可以使用 <explicit>
选项以一系列命令形式显式显示系统在当前层级配置特定语句时在内部创建的所有配置。
[edit interfaces fe-0/0/0] user@host# show unit 0 { family inet { address 192.107.1.230/24; } family iso; family mpls; } inactive: unit 1 { family inet { address 10.0.0.1/8; } } [edit interfaces xe-0/0/0] user@host#show | display set relative
set unit 0 family inet address 192.107.1.230/24 set unit 0 family iso set unit 0 family mpls set unit 1 family inet address 10.0.0.1/8 deactivate unit 1 user@host#show | display set relative | explicit
set unit 0 family inet address 192.168.1.230/24 set unit 0 family inet set unit 0 family iso set unit 0 family mpls set unit 0 set unit 1 family inet address 10.0.0.1/8 set unit 1 family inet deactivate unit 1
示例:显示带有匹配选项的 set 命令
要将配置显示为 set
命令并通过过滤输出搜索与正则表达式匹配的文本,请在 match
管道 ( |) 后指定选项:
user@host# show | display set | match regular-expression
显示与接口关联的 IP 地址:
xe-2/3/0 {
unit 0 {
family inet {
address 192.107.9.106/30;
}
}
}
so-5/1/0 {
unit 0 {
family inet {
address 192.107.9.15/32 {
destination 192.107.9.192;
}
}
}
}
lo0 {
unit 0 {
family inet {
address 127.0.0.1/32;
}
}
}
user@host# show interfaces | display set | match address
set interfaces xe-2/3/0 unit 0 family inet address 192.168.9.106/30
set interfaces so-5/1/0 unit 0 family inet address 192.168.9.15/32 destination 192.168.9.192
set interfaces lo0 unit 0 family inet address 127.0.0.1/32