Chinaunix首页 | 论坛 | 博客
  • 博客访问: 19882183
  • 博文数量: 679
  • 博客积分: 10495
  • 博客等级: 上将
  • 技术积分: 9308
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-18 10:51
文章分类

全部博文(679)

文章存档

2012年(5)

2011年(38)

2010年(86)

2009年(145)

2008年(170)

2007年(165)

2006年(89)

分类: 网络与安全

2008-03-13 09:12:03

§14.4           TRACEROUTE

     Windows版本:

Tracert

通过递增生存时间 (TTL)”字段的值将“Internet 控制消息协议 (ICMP) 回响请求消息发送给目标可确定到达目标的路径。所显示的路径是源主机与目标主机间的路径中的路由器的近侧路由器接口列表。近侧接口是距离路径中的发送主机最近的路由器的接口。

    该诊断工具通过更改生存时间 (TTL)”的值向目标发送“ICMP 回响请求消息来确定到达目标的路径。要求路径上的每个路由器在转发数据包之前至少将 IP 数据包中的 TTL 递减 1。这样,TTL 就成为最大链路计数器。数据包上的 TTL 到达 0 时,路由器应该将“ICMP 已超时的消息发送回源计算机。Tracert 发送 TTL 1 的第一条回响请求消息,并在随后的每次发送过程将 TTL 递增 1,直到目标响应或跃点达到最大值,从而确定路径。默认情况下跃点最大值是 30,可使用 -h 参数指定。检查中间路由器返回的“ICMP 超时消息与目标返回的回响答复消息可确定路径。但是,某些路由器不会为使用到期 TTL 值的数据包返回已超时消息,而且有些路由器对于 tracert 命令不可见。在这种情况下,将为该跃点显示一行星号 (*)

    要跟踪路径并为路径中的每个路由器和链路提供网络延迟和数据包丢失信息,请使用 pathping 命令。

只有当网际协议 (TCP/IP) 协议在 网络连接中安装为网络适配器属性的组件时,该命令才可用。

举例:

    tracert corp7.microsoft.com

    tracert -d corp7.microsoft.com

    tracert -j 10.12.0.1 10.29.3.1 10.1.44.1 corp7.microsoft.com

 

详细参数参见windows帮助

 

     Linux版本:

It starts by sending an IP packet (either ICMP or User Datagram Protocol—UDP) to its specified destination, but it sets the TTL field to 1. The packet "expires" at the first hop, and that router tells us that the packet expired using an ICMP message, which allows us to identify where that first hop is. Now we send another IP packet off to the destination, but this time the TTL field is set to 2. The packet will expire at the second hop, and that router will notify us once again. By continually incrementing the TTL until we reach the destination, we can discover which routers are standing in between our host and our destination.

 

     图形版本:

Windows

Linux:VisualRoute and McAfee Visual Trace and

图形版本依赖whois数据库,未必精确

 

 

Table 14-3: Traceroute Options

Option

Explanation

-g > (Unix)
-j > (Windows)

Specifies a loose source-routing list for the packet to follow.

-i >

Specifies the network interface to use when choosing a source IP address to route from (for hosts with more than one network interface).

-I

Uses ICMP instead of UDP for the traceroute. By default, traceroute sends UDP packets to ports that normally don't have anything listening on them, so that the destination host will respond with an ICMP PORT_ UNREACHABLE message when the packet reaches its destination.

-m > (Unix)
-h > (Windows)

Sets the maximum number of hops to take before reaching the destination. If traceroute doesn't reach the destination in hops number of hops, it gives up. The default is 30.

-n (Unix)
-d (Windows)

Does not resolve IP addresses. Usually makes your traceroute a lot faster, but obviously you give up obtaining useful location-based information from the hostnames.

-p >

If we're using UDP traceroute and the destination actually has someone listening on or around the default UDP port (which is 33434), we can specify a different port here.

-w (Unix and Windows)

Sets how long traceroute should wait for a response from an intermediate hop.

 

# traceroute 10.50.44.252

traceroute to 10.50.44.252 (10.50.44.252), 30 hops max, 46 byte packets

 1  10.50.48.1 (10.50.48.1)  0.377 ms  0.343 ms  0.352 ms

 2  192.168.0.101 (192.168.0.101)  0.274 ms  0.195 ms  0.191 ms

 3  192.168.0.86 (192.168.0.86)  0.415 ms  0.321 ms  0.329 ms

 4  10.50.44.252 (10.50.44.252)  0.130 ms  0.103 ms  0.100 ms

 

每个节点有3个响应时间。可能中间有*但不影响trace,一般为该点不回送ICMP报文。有可能是防火墙阻挡或者ICMP "time exceeded"太短。

错误信息:

Table 14-4: Traceroute Hop Information

Flag

Description

!H

ICMP host unreachable

!N

ICMP network unreachable

!P

ICMP protocol unreachable

!S

Source route failed

!F

Fragmentation needed

!X

Communication administratively prohibited

!#

ICMP unreachable code #

使用-v可以查看详细的错误信息。

# traceroute -v 222.91.95.226

traceroute to 222.91.95.226 (222.91.95.226), 30 hops max, 46 byte packets

 1  10.50.48.1 (10.50.48.1) 36 bytes to 10.50.48.16  0.343 ms  0.353 ms  0.336 ms

 2  192.168.0.101 (192.168.0.101) 36 bytes to 10.50.48.16  0.242 ms  0.193 ms  0.197 ms

 3  172.19.109.57 (172.19.109.57) 36 bytes to 10.50.48.16  0.257 ms  0.250 ms  0.242 ms

 4  * 172.19.109.57 (172.19.109.57) 36 bytes to 10.50.48.16  0.306 ms !X *

 5  172.19.109.57 (172.19.109.57) 36 bytes to 10.50.48.16  0.293 ms !X *  0.480 ms !X

 

    只有防火墙和入侵检测系统能阻挡外部traceroutesTraceroute优先使用UDP协议,而不是ICMP(Uses ICMP instead of UDP for the traceroute. By default, traceroute sends UDP packets to ports that normally don't have anything listening on them, so that the destination host will respond with an ICMP PORT_ UNREACHABLE message when the packet reaches its destination.)

Linux上把/proc/sys/net/ipv4/icmp_echo_ignore_all设置为1,无法ping通,但是traceroute可以跟踪的。

阅读(8330) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2008-03-13 09:12:44

上一篇:http://blog.chinaunix.net/u/21908/showart.php?id=494956