示例:跟踪全局路由协议操作
此示例显示如何列出和查看启用全局路由追踪操作时创建的文件。
要求
您必须拥有 查看权限 。
概述
要配置全局路由协议追踪,请包含 traceoptions
层级的 [edit routing-options]
语句:
traceoptions { file filename <files number> <size size> <world-readable | no-world-readable>; flag flag <disable>; }
语句中的 traceoptions flag
标记是标识符。使用 命令配置标志时,可能已设置的任何 set
标志均不会修改。在下面的示例中,设置 计时器 追踪标志对已配置的任务 标志没有影响 。使用 delete
命令删除特定标志。
[edit routing-options traceoptions]
user@host# show
flag task;
user@host# set traceoptions flag timer
user@host# show
flag task;
flag timer;
user@host# delete traceoptions flag task
user@host# show
flag timer;
此示例展示如何配置和查看跟踪路由表中的更改的跟踪文件。这些步骤可进行调整,以应用到支持跟踪操作的任何Junos OS层次结构级别的追踪操作。
要查看支持追踪操作的结构级别列表,请在配置模式下 help apropos traceoptions
输入 命令。
配置
CLI快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以匹配网络配置,然后将命令复制并粘贴到 层次结构级别的 CLI 中。 [edit]
set routing-options traceoptions file routing-table-changes set routing-options traceoptions file size 10m set routing-options traceoptions file files 10 set routing-options traceoptions flag route set routing-options static route 1.1.1.2/32 next-hop 10.0.45.6
配置跟踪操作
逐步过程
以下示例要求您在配置层次结构中导航各个级别。有关导航指南CLI,请参阅 CLI 用户指南 中的 在配置模式下Junos OS CLI 编辑器。
要配置跟踪操作,请执行以下操作:
配置跟踪操作。
[edit routing-options traceoptions] user@host# set file routing-table-changes user@host# set file size 10m user@host# set file files 10 user@host# set flag route
配置静态路由,导致路由表发生变化。
[edit routing-options static] user@host# set route 1.1.1.2/32 next-hop 10.0.45.6
如果完成设备配置,请提交配置。
[edit] user@host# commit
查看跟踪文件
逐步过程
要查看跟踪文件,需要:
在操作模式下,列出系统的日志文件。
user@host> file list /var/log /var/log: ... routing-table-changes ...
查看路由表更改 文件 的内容。
user@host> file show /var/log/routing-table-changes Dec 15 11:09:29 trace_on: Tracing to "/var/log/routing-table-changes" started Dec 15 11:09:29.496507 Dec 15 11:09:29.496507 Tracing flags enabled: route Dec 15 11:09:29.496507 Dec 15 11:09:29.533203 inet_routerid_notify: Router ID: 192.168.4.1 Dec 15 11:09:29.533334 inet_routerid_notify: No Router ID assigned Dec 15 11:09:29.533381 inet_routerid_notify: No Router ID assigned Dec 15 11:09:29.533420 inet_routerid_notify: No Router ID assigned Dec 15 11:09:29.534915 inet_routerid_notify: Router ID: 192.168.4.1 Dec 15 11:09:29.542934 inet_routerid_notify: No Router ID assigned Dec 15 11:09:29.549253 inet_routerid_notify: No Router ID assigned Dec 15 11:09:29.556878 inet_routerid_notify: No Router ID assigned Dec 15 11:09:29.582990 rt_static_reinit: examined 3 static nexthops, 0 unreferenced Dec 15 11:09:29.589920 Dec 15 11:09:29.589920 task_reconfigure reinitializing done ...
过滤日志文件的输出。
user@host> file show /var/log/routing-table-changes | match 1.1.1.2 Dec 15 11:15:30.780314 ADD 1.1.1.2/32 nhid 0 gw 10.0.45.6 Static pref 5/0 metric at-0/2/0.0 <ctive Int Ext> Dec 15 11:15:30.782276 KRT Request: send len 216 v104 seq 0 ADD route/user af 2 table 0 infot 0 addr 1.1.1.2 nhop-type unicast nhindex 663
使用可选匹配条件运行 命令,
monitor start
实时查看追踪操作。user@host> monitor start routing-table-changes | match 1.1.1.2 Aug 10 19:21:40.773467 BGP RECV 0.0.0.0/0 Aug 10 19:21:40.773685 bgp_rcv_nlri: 0.0.0.0/0 Aug 10 19:21:40.773778 bgp_rcv_nlri: 0.0.0.0/0 belongs to meshgroup Aug 10 19:21:40.773832 bgp_rcv_nlri: 0.0.0.0/0 qualified bnp->ribact 0x0 l2afcb 0x0
停用静态路由。
user@host# deactivate routing-options static route 1.1.1.2/32 user@host# commit
*** routing-table-changes *** Dec 15 11:42:59.355557 CHANGE 1.1.1.2/32 nhid 663 gw 10.0.45.6 Static pref 5/0 metric at-0/2/0.0 <Delete Int Ext> Dec 15 11:42:59.426887 KRT Request: send len 216 v104 seq 0 DELETE route/user af 2 table 0 infot 0 addr 1.1.1.2 nhop-type discard filtidx 0 Dec 15 11:42:59.427366 RELEASE 1.1.1.2/32 nhid 663 gw 10.0.45.6 Static pref 5/0 metric at-0/2/0.0 <Release Delete Int Ext>
按
monitor
Enter 并键入 monitor stop,停止 命令。[Enter] user@host> monitor stop
完成故障排除后,可以考虑停用跟踪日志记录,以避免对系统资源产生任何不必要的影响。
当配置停用时,它会显示在具有非活动标记 的配置 中。
[edit routing-options] user@host# deactivate traceoptions user@host# commit
[edit routing-options] user@host# show inactive: traceoptions { file routing-table-changes size 10m files 10; flag route; } static { inactive: route 1.1.1.2/32 next-hop 10.0.45.6; }
要重新激活追踪操作,请使用 activate configuration-mode 语句。
[edit routing-options] user@host# activate traceoptions user@host# commit
结果
在配置模式下,输入 命令以确认 show routing-options
您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以更正配置。
user@host# show routing-options traceoptions { file routing-table-changes size 10m files 10; flag route; } static { route 1.1.1.2/32 next-hop 10.0.45.6; }