系统管理指南:IP 服务

使用 traceroute 命令显示路由信息

traceroute 命令将跟踪发往远程系统的 IP 包所经过的路由。有关 traceroute 的详细技术信息,请参见 traceroute(1M) 手册页。

可以使用 traceroute 命令查找所有的路由配置错误以及路由路径错误。如果无法到达特定的主机,则可以使用 traceroute 来查看发往远程主机的包所经由的路径以及可能出现故障的位置。

traceroute 命令还显示在通向目标主机的路径上每个网关的往返时间。此信息对于分析两个主机之间何处出现通信缓慢非常有用。

Procedure如何查找通向远程主机的路由

  1. 键入以下命令查找通向远程系统的路由:


    % traceroute destination-hostname
    

    使用用户帐户便可运行此 traceroute 命令形式。


示例 8–17 使用 traceroute 命令显示通向远程主机的路由

以下 traceroute 命令输出显示了包从本地系统 nearhost 到达远程系统 farhost 所经由的具有七个跃点的路径。此输出还显示包遍历每个跃点所用的时间。


istanbul% traceroute farhost.faraway.com
	traceroute to farhost.faraway.com (172.16.64.39), 30 hops max, 40 byte packets
	 1  frbldg7c-86 (172.16.86.1)  1.516 ms  1.283 ms  1.362 ms
	 2  bldg1a-001 (172.16.1.211)  2.277 ms  1.773 ms  2.186 ms
	 3  bldg4-bldg1 (172.16.4.42)  1.978 ms  1.986 ms  13.996 ms
	 4  bldg6-bldg4 (172.16.4.49)  2.655 ms  3.042 ms  2.344 ms
	 5  ferbldg11a-001 (172.16.1.236)  2.636 ms  3.432 ms  3.830 ms
	 6  frbldg12b-153 (172.16.153.72)  3.452 ms  3.146 ms  2.962 ms
	 7  sanfrancisco (172.16.64.39)  3.430 ms  3.312 ms  3.451 ms

Procedure如何跟踪所有路由

此过程使用 traceroute 命令的 -a 选项来跟踪所有路由。

  1. 在本地系统上键入以下命令:


    % traceroute -ahost-name
    

    使用用户帐户便可运行此 traceroute 命令形式。


示例 8–18 跟踪所有通向双栈主机的路由

此示例显示通向双栈主机的所有可能路由。


% traceroute -a v6host.remote.com
traceroute: Warning: Multiple interfaces found; using 2::56:a0:a8 @ eri0:2
traceroute to v6host (2001:db8:4a3b::102:a00:fe79:19b0),30 hops max, 60 byte packets
 1  v6-rout86 (2001:db8:4a3b:56:a00:fe1f:59a1)  35.534 ms  56.998 ms * 
 2  2001:db8::255:0:c0a8:717  32.659 ms  39.444 ms *
 3  farhost.faraway.COM (2001:db8:4a3b::103:a00:fe9a:ce7b)  401.518 ms  7.143 ms *
 4  distant.remote.com (2001:db8:4a3b::100:a00:fe7c:cf35)  113.034 ms  7.949 ms *
 5  v6host (2001:db8:4a3b::102:a00:fe79:19b0)  66.111 ms *  36.965 ms

traceroute to v6host.remote.com  (192.168.10.75),30 hops max,40 byte packets
 1  v6-rout86 (172.16.86.1)  4.360 ms  3.452 ms  3.479 ms
 2  flrmpj17u.here.COM (172.16.17.131)  4.062 ms  3.848 ms  3.505 ms
 3  farhost.farway.com (10.0.0.23)  4.773 ms *  4.294 ms
 4  distant.remote.com (192.168.10.104)  5.128 ms  5.362 ms *
 5  v6host  (192.168.15.85)  7.298 ms  5.444 ms *