找回密码
 注册
Simdroid-非首页
查看: 34|回复: 1

[基础知识] JUNOS配置导航(转)

[复制链接]
发表于 2009-5-26 08:55:59 | 显示全部楼层 |阅读模式 来自 河南三门峡
JUNOS配置文件采用良好的层级结构;一旦您对这个结构以及结构内的各个级别有所了解,便能轻松进行文件导航并准确找到您希望查看或更改的内容,不用在您不感兴趣的内容上费力气。
  首先登录路由器:
  Juniper5 (ttyd0)
  login: jeff
  Password:
  --- JUNOS 8.5R1.13 built 2007-11-14 17:54:24 UTC
  [email=jeff@Juniper5]jeff@Juniper5[/email]>
  系统提示将显示用户名(jeff)和路由器名称(Juniper5)。路由器现在处于运行模式,您可以在这里执行多个运行任务,如显示路由器状态和数据库、通过ping命令分析路由器故障、路由跟踪、远程登录和ssh及重启系统程序等用于监控系统和排除系统故障的大多数命令。JUNOS的运行模式对应IOS的用户执行模式,实际上,两个模式的提示符都是"大于号" (>)。
  与IOS一样,当您没有记清命令字符串中的下一个语句或者只希望查看您可用的选项时,问号(?)将是您的主要信息工具。我可以使用问号来查看运行模式中的所有命令。
  [email=jeff@Juniper5]jeff@Juniper5[/email]> ?
  Possible completions:
  clear Clear information in the system
  configure Manipulate software configuration information
  diagnose Invoke diagnose |
  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
  为了更改配置,我通过输入configure命令进入配置模式:
  [email=jeff@Juniper5]jeff@Juniper5[/email]> configure
  Entering configuration mode
  [edit]
  [email=jeff@Juniper5]jeff@Juniper5[/email]#
  JUNOS的配置模式对应IOS的特权执行或“打开”模式。请注意,此时的提示符已从>变成#,与您在IOS中输入enable命令的结果完全相同。
  JUNOS配置模式的另一个典型特征是在紧邻提示的上方显示一个[edit]窗口。您可在配置层级结构中导航以便只查看或更改您感兴趣的文件内容;这个窗口能够明确告诉您所在位置。如果窗口中只显示[edit],说明您位于层级结构的顶端。例如,如果您在这个级别键入不带任何修饰语的show,JUNOS将显示整个配置。
  与show命令一起使用问号,您将能够看到配置层级结构顶部的几个层次:
  [edit]
  [email=jeff@Juniper5]jeff@Juniper5[/email]# show ?
  Possible completions:
  <[Enter]> Execute this command
  > access Network access configuration
  > accounting-options Accounting data configuration
  > applications Define applications by protocol characteristics
  + apply-groups Groups from which to inherit configuration data
  > chassis Chassis configuration
  > class-of-service Class-of-service configuration
  > event-options Event processing configuration
  > firewall Define a firewall configuration
  > forwarding-options Configure options to control packet forwarding
  > groups Configuration groups
  > interfaces Interface configuration
  > policy-options Routing policy option configuration
  > protocols Routing protocol configuration
  > routing-instances Routing instance configuration
  > routing-options Protocol-independent routing option configuration
  > security Security configuration
  > services Service PIC applications settings
  > snmp Simple Network Management Protocol configuration
  > system System parameters
  | Pipe through a command
  与这个列表一同提供的标签准确指明了级别分配情况。例如,所有接口都在interfaces级别配置、所有协议都在protocols级别配置、所有的路由策略都在policy-options级别配置。
  顶部的几个级别下面是多个子级别。例如,在protocols下面,您可看到BGP、OSPFv2、OSPFv3、MPLS、RSVP等子级别。在每个子级别的下面,您都将看到协议特定的亚子级别。例如在OSPF下面,您将看到area配置级别,然后在每个area级别下面,您都将看到属于这个区域的Interface级别。随后我将举例说明。
  配置的层级结构允许您重点查看感兴趣的配置片断。例如,假设您只希望查看配置的BGP片断,运行show protocols bgp将为您显示整个的BGP配置:
  [edit]
  [email=jeffr@Juniper5]jeffr@Juniper5[/email]# show protocols bgp
  local-address 192.168.50.10;
  local-as 65503;
  group CustomerX {
  export XPolicy;
  peer-as 65510;
  neighbor 192.168.1.1 {
  authentication-key "$-Ud2aji.5z6qm"; ## SECRET-DATA
  }
  neighbor 192.168.1.5 {
  authentication-key "$JiZHmzF/t0I69ev"; ## SECRET-DATA
  }
  neighbor 192.168.1.10 {
  authentication-key "$mPF/u0Icrv1Rbs"; ## SECRET-DATA
  }
  }
  group CustomerY {
  neighbor 192.168.10.20;
  neighbor 192.168.10.30;
  neighbor 192.168.10.40;
  }
  group CustomerZ {
  neighbor 192.168.20.100;
  }
  在这个配置信息中,您可以看到发起所有BGP TCP会话的本地地址(192.168.50.10)、本地AS编码65503和三个对等组:CustomerX、 CustomerY和CustomerZ。CustomerX使用被我称为XPolicy的出站(输出)路由策略;由于这个对等组使用的AS编码(65510)有别于本地AS编码,因此,我们得知这些对等是EBGP对等。这个对等组下面配置了三个临点,均已使用各自的密码通过了验证。对等组CustomerY也带三个临点,对等组CustomerZ带一个临点,因为它们均未使用单独的AS编码并且没有配置验证密码,因此属于IBGP对等。
  假设您对整个BGP配置不感兴趣,只对对等组Customer X下面的临点192.168.1.5的配置感兴趣。我可以使用求show命令要求JUNOS只突出显示配置文件的这个片断:
  [edit]
  [email=jeff@Juniper5]jeff@Juniper5[/email]# show protocols bgp group CustomerX neighbor 192.168.1.5
  authentication-key "$JiZHmzF/t0I69ev"; ## SECRET-DATA
  当然,如果您运行在配置模式中并且不满足于简单地查看配置片断,而是希望做出改变,只需在配置模式中使用问号,即可看到您希望执行的不同操作:
  [edit]
  [email=jeff@Juniper5]jeff@Juniper5[/email]# ?
  Possible completions:
  <[Enter]> Execute this command
  activate Remove the inactive tag from a statement
  annotate Annotate the statement with a comment
  commit Commit current set of changes
  copy Copy a statement
  deactivate Add the inactive tag to a statement
  delete Delete a data element
  edit Edit a sub-element
  exit Exit from this level
  help Provide help information
  insert Insert a new ordered data element
  load Load configuration from ASCII file
  quit Quit from this level
  rename Rename a statement
  replace Replace character string in configuration
  rollback Roll back to previous committed configuration
  run Run an operational-mode command
  save Save configuration to ASCII file
  set Set a parameter
  show Show a parameter
  status Show users currently editing configuration
  top Exit to top level of configuration
  up Exit one level of configuration
  wildcard Wildcard operations
  在下文以及以后的全部文章中,我们都将讨论这个列表中包含的操作信息。
  如果希望向配置中添加某些元素,请使用set命令。例如,我们希望向OSPF area 5中添加接口fe-0/0/0,可使用set按从上到下的顺序规定层级结构中的每个级别,直到希望添加接口的area 5为止:
  [edit]
  [email=jeff@Juniper5]jeff@Juniper5[/email]# set protocols ospf area 5 interface fe-0/0/0
  顺便说一下,如果OSPF没有被打开或者area 5不存在,执行set命令除了打开协议并创建area 5外,还将向area中添加接口。
  另一种方法是首先沿层级结构向下移动直到发现您希望配置的级别为止,然后使用edit命令做出更改:
  [edit]
  [email=jeff@Juniper5]jeff@Juniper5[/email]# edit protocols ospf area 5
  [edit protocols ospf area 0.0.0.5]
  [email=jeff@Juniper5]jeff@Juniper5[/email]# set interface fe-0/0/1
  请注意,输入edit protocols ospf area 5命令后,提示窗口的内容将发生变化,显示我在层级结构中所处的位置–以便始终了解自己的位置。然后,我使用set命令在这个级别添加fe-0/0/1接口。此时我无需要求系统显示整个层级结构,因此已到达了需要执行更改操作的层次。
  这两种方法都允许您通过最便利的方法管理配置。如果您只是希望向配置中添加一两个语句,通常应选择的做法是从顶部开始向下移动,直到发现相应的层次为止。如果您希望大幅度更改特殊层次,通常应该首先使用edit命令找到这个层次,然后直接实施变化,无需通过每个命令显示整条路径。
  运行edit命令能够带您进入希望操作的特定级别,运行up命令允许您沿着层级结构向上移动一个级别。例如,假设我们现在的位置是OSPF area 5,并希望向上转移到整个OSPF级别:
  [edit protocols ospf area 0.0.0.5]
  [email=jeff@Juniper5]jeff@Juniper5[/email]# up
  [edit protocols ospf]
  [email=jeff@Juniper5]jeff@Juniper5[/email]# show
  area 0.0.0.5 {
  interface fe-0/0/0.0;
  interface fe-0/0/1.0;
  }
  发布up命令后,您将看到提示窗口的消息发生了变化,告诉您现在所处的级别。无论您在任何级别运行show命令,系统都将显示这个级别以下的全部配置语句– 在这个例子中显示的是整个OSPF配置。
  如果您希望从任何级别返回层级结构的顶部,请运行top命令:
  [edit protocols ospf]
  [email=jeff@Juniper5]jeff@Juniper5[/email]# top
  [edit]
  [email=jeff@Juniper5]jeff@Juniper5[/email]#
  在这个例子中,您也可通过两次运行up命令从现有级别返回顶部:[edit protocols ospf] => up => [edit protocols] => up => [edit]。 联合使用edit、up和top命令,您可快速移动到配置文件中的任何位置执行高效操作。
  除set命令外,您还可以使用另外几个重要命令来更改配置。由于篇幅有限我在此不进行演示,只能提供简短说明:
  · Delete命令的作用与set命令正好相反,它将把语句从配置中删除。
  · Replace命令用于通过一个语句替换另一个语句。
  · Insert命令用于向顺序排列的元素中添加语句(如过滤器列表),但不能像set命令那样在结尾处添加语句。
  · Deactivate命令用于去活语句,但不能将语句从配置中删除。这个命令允许您非常轻松地临时“关闭”您希望在最后重新打开的语句。
  · Activate命令用于激活不活动的语句。
  · Annotate命令用于向语句中添加命令;对于轻松解释大规模的复杂配置文件非常有用。
  JUNOS与IOS在运行方面的另一个主要区别在于:不同于IOS,如果您将新语句输入到JUNOS配置中,它不会立刻在路由器上开始运行。您可随意进行修改并检查所做修改,只有当您明确指示路由器接受它们时,新语句才能开始运行。
发表于 2009-5-26 09:51:02 | 显示全部楼层 来自 河南三门峡
Simdroid开发平台
可随意进行修改并检查所做修改哈!谢谢楼主分享了。
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-5-29 19:12 , Processed in 0.039015 second(s), 14 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表