打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
traceroute命令详解

traceroute命令详解

默认分类 2010-04-06 16:50:33 阅读921 评论0   字号: 订阅

定义:

互联网中,信息的传送是通过网中许多段的传输介质和设备(路由器,交换机,服务器,网关等等)从一端到达另一端。每一个连接在Internet上的设备,如主机、路由器、接入服务器等一般情况下都会有一个独立的IP地址。通过Traceroute我们可以知道信息从你的计算机到互联网另一端的主机是走的什么路径。当然每次数据包由某一同样的出发点(source)到达某一同样的目的地(destination)走的路径可能会不一样,但基本上来说大部分时候所走的路由是相同的。UNIX系统中,我们称之为Traceroute,MS Windows中为Tracert。 Traceroute通过发送小的数据包到目的设备直到其返回,来测量其需要多长时间。一条路径上的每个设备Traceroute要测3次。输出结果中包括每次测试的时间(ms)和设备的名称(如有的话)及其IP地址。

在大多数情况下,作为网络工程技术人员或者系统管理员会在UNIX主机系统下,直接执行命令行:

  Traceroute hostname

  而在Windows系统下是执行Tracert的命令:

  Tracert hostname

  比如在北京地区使用windows NT 主机(已经与北京163建立了点对点的连接后)

  使用NT系统中的Tracert命令:(用户可用:开始->运行,输入"command" 调出command窗口使用此命令)traceroute [-46dFITUnrAV] [-f first_ttl] [-g gate,...]
        [-i device] [-m max_ttl] [-p port] [-s src_addr]
        [-q nqueries] [-N squeries] [-t tos]
        [-l flow_label] [-w waittime] [-z sendwait]
        host [packetlen]
traceroute6  [options]
tracert  [options]
tcptraceroute  [options]

说明:
       traceroute  tracks  the route packets take across an IP network on their way to a given host. It utilizes
       the IP protocol’s time to live (TTL) field and attempts to elicit an  ICMP  TIME_EXCEEDED  response  from
       each gateway along the path to the host.

       traceroute6 = traceroute -6
       tracert = traceroute -I
       tcptraceroute = traceroute -T -p 80

选项说明:

      唯一所必须的参数host是目的主机的名字或 IP 地址。在这个参数之后可以选择跟上探测包的大小[packetlen](默认是40)。改变包的大小并使用 -F 参数 可以用于获得个别网络跳的 MTU 信息。(探测包大小的参数对于TCP探测来说无用)。

其余的选项 :

       --help 打印帮助信息,并退出。

       -4, -6 显示地指定使用IPv4或IPv6 traceroute。默认情况下,traceroute会解析给定的主机名,并自动选择合适的协议。如果解析主机名既得到了IPv4的地址,又得到了IPv6的地址,traceroute会使用IPv4。

       -I     使用ICMP ECHO进行探测。

       -T    使用TCP SYN进行探测。

       -U     使用UDP报文进行探测(默认情况)。对于无特权用户来说,只允许使用UDP报文进行探测。

       -d     允许进行socket级别的调试(当Linux kernel支持它的时候)Enable socket level debugging (when the Linux kernel supports it)

       -F     将“不要分段Don't Fragment”位置位。这将告诉中间路由器不要将该包分段(当路由器发现该探测包对于网络中MTU来说太大的时候)

       -f <first_ttl>   
               设置第一个检测数据包的存活数值TTL的大小。默认是1 。

       -g <gateway>   
               告诉traceroute为发出的packet增加IP源路由选项,以此告诉网络在路由该packet时需要通过指定的网关。不是十分有用,大多数的路由器因为安全方面的考虑将源路由设置为失效。

       -i <interface>
               指定traceroute发送包时经过的端口。默认的端口是依照路由表选定的。

       -m <max_ttl>
               指定traceroute将要探测的最大跳数(最大的生存时间)。默认值为30。

       -N <squeries>
               指定同时发送的探测包数目。同时发送几个探测包可以适当地加快traceroute的速度。默认值为15。注意:有些路由器和主机会使用ICMP速率限制,在这种情况下,指定同时发送大量的探测包会导致一些响应丢失。

       -n     显示的时候无需将IP地址和主机名相对应。直接使用IP地址而非主机名称。

       -p <port>
               使用UDP的跟踪,基础的traceroute会使用指定的目的端口(每个探测包的目的端口号会递增)。
               使用ICMP跟踪,指定初始的icmp序列号(每个探测包递增)。
               使用TCP跟踪,指定要连接的端口号(常数)

       -t <tos>
               对于IPv4,设置服务类型(Type of Service,TOS)及优先值。有用的数值有16(低延迟)和8(高吞吐量)。注意在使用某些TOS优先值时,你必须是超级用户。
              对于IPv6,设置流量控制值。

       -w <waittime>
               设置对探测包响应的等待时间(秒),默认值是5秒。

       -q <nqueries>
               设置每一跳的探测包数量。默认是3 。

       -r     忽略普通的路由表,直接发送到所在网络(attacked network)的远端主机上。如果该主机不是直接附在网络(directly-attached network)中,会返回一个错误。该选项可用于ping一个本地主机,而该主机所经过的端口没有路由。

-s <source_addr>
       设置本地主机发出数据包的地址。注意你必须选择某一端口的地址,这个地址就是发出数据包的端口所使用的。

-z <sendwait>
       探测包之间最小的时间间隔(默认值为0)。如果该值大于10,则它指定的为毫秒,否则,它指定的为秒(允许使用浮点数)。当某些路由器对ICMP报文实行速率限制时有用。

-A     在路由注册中查找AS path,并将结果直接打印在相应的地址后面

-V     打印出版本并退出。

       This program attempts to trace the route an IP packet would follow to some internet host by  launching  a
       probe  packets  with  a  small ttl (time to live) then listening for an ICMP "time exceeded" reply from a
       gateway.  We start our probes with a ttl of one and increase by one until we get an ICMP  "port  unreach-
       able"  (or  TCP reset), which means we got to "host", or hit a max (which defaults to 30 hops). Three (by
       default) probes are sent at each ttl setting and a line is printed showing the ttl, address of the  gate-
       way and round trip time of each probe.  If the probe answers come from different gateways, the address of
       each responding system will be printed.  If there is no response within a 5.0 (default) seconds, a "*" is
       printed for that probe.

       We  don’t want the destination host to process the UDP probe packets so the destination port is set to an
       unlikely value (you can change it with the -p flag). There is no such problem for ICMP or TCP  tracerout-
       ing (for TCP we close sessions immediately after connect).

       After  the  time  some  additional  annotation  can  be printed: !H, !N, or !P (host, network or protocol
       unreachable), !S (source route failed), !F (fragmentation  needed),  !X  (communication  administratively
       prohibited),  !V  (host precedence violation), !C (precedence cutoff in effect), or !<num> (ICMP unreach-
       able code <num>).  If almost all the probes result in some kind of unreachable, traceroute will  give  up
       and exit.

SEE ALSO
       ping(8), ping6(8), tracepath(8), netstat(8).

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
每天一个linux命令(55):traceroute命令
traceroute命令的用法实例分享
网络中经常接触的Ping 一次性教你弄懂如何检测三层网络
协议森林06 瑞士军刀 (ICMP协议)
Tracert命令详解
试试这个命令,比ping还好用
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服