分一次edit进入ospf,最后输入exit退回最外层.
lab@EX4200# edit protocols
[edit protocols] lab@EX4200# edit ospf
[edit protocols ospf] lab@EX4200# top [edit] lab@EX4200#
输入top直接退出到最外层。
另外,juniper的配置参数有些可以一次写几个,比如要一次配置ospf的hello-time和dead-time可以按照下面写法:
lab@EX4200# set protocols ospf area 0 interface ge-0/0/1.0 hello-interval 10 dead-interval 10
输入以上命令之后,交换机的配置如下:
protocols { ospf {
area 0.0.0.0 {
interface ge-0/0/1.0 { hello-interval 10; } }
} }
注意:如果不知道一条命令里面后面是否还可以跟其它配置参数,那么最好使用 ? 帮助一下:
第11页 共86页
lab@EX4200# set protocols ospf area 0 interface ge-0/0/1.0 hello-interval 10 ? Possible completions:
<[Enter]> Execute this command
+ apply-groups Groups from which to inherit configuration data + apply-groups-except Don't inherit configuration data from these groups > authentication
> bfd-liveness-detection Bidirectional Forwarding Detection options dead-interval Dead interval (seconds) (1..65535) demand-circuit Interface functions as a demand circuit disable Disable OSPF on this interface interface-type Type of interface
ipsec-sa IPSec security association name
> ldp-synchronization Advertise maximum metric until LDP is operational metric Interface metric (1..65535) > neighbor NBMA neighbor
no-neighbor-down-notification Don't inform other protocols about neighbor down events
> passive Do not run OSPF, but advertise it
poll-interval Poll interval for NBMA interfaces (1..65535) priority Designated router priority (0..255)
retransmit-interval Retransmission interval (seconds) (1..65535) te-metric Traffic engineering metric (1..65535) transit-delay Transit delay (seconds) (1..65535) | Pipe through a command [edit]
1.2.3 TAB和空格键的使用
交换机JUNOS命令配置中,可以使用TAB键和空格键来进行参数的补全,在补全系统参数中两个键的作用是一样的,例如:
lab@EX4200# set pro <-输入TAB键或者空格键,则会补全protocols lab@EX4200# set protocols
第12页 共86页
而对于用户自己定义的参数,则只能用TAB来补全,比如我们定义了一个Test_Policy_1的策略,要在ospf中配置时可以使用 ?来显示:
lab@EX4200# set protocols ospf export ? Possible completions:
[ Open a set of values [edit]
也可以直接输入T之后按TAB键来补全,而此时按空格键则无法补全:
lab@EX4200# set protocols ospf export T <-输入TAB键,则会补全Test_Policy_1 lab@EX4200# set protocols ospf export Test_Policy_1
1.2.4 用户模式和配置模式show的区别
在用户模式下,是无法进行配置操作的,而只能查看系统的一些参数。所以用户模式下的show命令是查看系统参数。要看系统配置则使用show configure命令。例如用户模式下show interface是查看端口信息: lab@EX4200> show interfaces
Physical interface: ge-0/0/1, Enabled, Physical link is Up Interface index: 142, SNMP ifIndex: 31
Link-level type: Ethernet, MTU: 1518, Speed: 100mbps, Loopback: Disabled, Source filtering: Disabled, Flow control: Enabled
Device flags : Present Running
Interface flags: SNMP-Traps Internal: 0x4000
CoS queues : 4 supported, 4 maximum usable queues
Current address: 00:05:85:dc:cc:db, Hardware address: 00:05:85:dc:cc:db Last flapped : 2007-06-29 20:37:17 HKT (1w2d 00:31 ago) Input rate : 280 bps (0 pps) Output rate : 1280 bps (1 pps) Active alarms : None Active defects : None
第13页 共86页
Logical interface ge-0/0/1.0 (Index 83) (SNMP ifIndex 71)
Flags: SNMP-Traps 0x4000 VLAN-Tag [ 0x8100.33 ] Encapsulation: ENET2 Input packets : 0 Output packets: 0 Protocol inet, MTU: 1500 Flags: None lab@EX4200>
而在配置下show命令是显示相关的配置,比如show interface则是显示interface部分的配置:
lab@EX4200# show interfaces ge-0/0/1 { unit 0 {
family ethernet-switching vlan members 10 ; family inet; } }
[edit] lab@EX4200#
因此说用户模式和配置模式下的show命令是不同的,如果要在配置模式下运行用户模式命令,则需要在命令前面加一个run
lab@EX4200# run show interfaces
Physical interface: ge-0/0/1, Enabled, Physical link is Up Interface index: 142, SNMP ifIndex: 31
Link-level type: Ethernet, MTU: 1518, Speed: 100mbps, Loopback: Disabled, Source filtering: Disabled, Flow control: Enabled
第14页 共86页
Device flags : Present Running
Interface flags: SNMP-Traps Internal: 0x4000
CoS queues : 4 supported, 4 maximum usable queues
Current address: 00:05:85:dc:cc:db, Hardware address: 00:05:85:dc:cc:db Last flapped : 2007-06-29 20:37:17 HKT (1w2d 00:36 ago) Input rate : 792 bps (0 pps) Output rate : 672 bps (0 pps) Active alarms : None Active defects : None
Logical interface ge-0/0/1.0 (Index 83) (SNMP ifIndex 71)
Flags: SNMP-Traps 0x4000 VLAN-Tag [ 0x8100.33 ] Encapsulation: ENET2 Input packets : 0 Output packets: 0 Protocol inet, MTU: 1500 Flags: None
[edit] lab@EX4200#
lab@EX4200# run ping 172.27.69.8
PING 172.27.69.8 (172.27.69.8): 56 data bytes
64 bytes from 172.27.69.8: icmp_seq=0 ttl=64 time=5.118 ms 64 bytes from 172.27.69.8: icmp_seq=1 ttl=64 time=7.949 ms 64 bytes from 172.27.69.8: icmp_seq=2 ttl=64 time=7.018 ms ^C
--- 172.27.69.8 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max/stddev = 5.118/6.695/7.949/1.178 ms [edit] lab@EX4200#
第15页 共86页