[[email protected] ~]# traceroute www.baidu.com traceroute to www.baidu.com (61.135.169.125), 30 hops max, 40 byte packets 1 192.168.74.2 (192.168.74.2) 2.606 ms 2.771 ms 2.950 ms 2 211.151.56.57 (211.151.56.57) 0.596 ms 0.598 ms 0.591 ms 3 211.151.227.206 (211.151.227.206) 0.546 ms 0.544 ms 0.538 ms 4 210.77.139.145 (210.77.139.145) 0.710 ms 0.748 ms 0.801 ms 5 202.106.42.101 (202.106.42.101) 6.759 ms 6.945 ms 7.107 ms 6 61.148.154.97 (61.148.154.97) 718.908 ms * bt-228-025.bta.net.cn (202.106.228.25) 5.177 ms 7 124.65.58.213 (124.65.58.213) 4.343 ms 4.336 ms 4.367 ms 8 202.106.35.190 (202.106.35.190) 1.795 ms 61.148.156.138 (61.148.156.138) 1.899 ms 1.951 ms 9 * * * 30 * * * [[email protected] ~]#
[[email protected] ~]# traceroute -m 10 www.baidu.com traceroute to www.baidu.com (61.135.169.105), 10 hops max, 40 byte packets 1 192.168.74.2 (192.168.74.2) 1.534 ms 1.775 ms 1.961 ms 2 211.151.56.1 (211.151.56.1) 0.508 ms 0.514 ms 0.507 ms 3 211.151.227.206 (211.151.227.206) 0.571 ms 0.558 ms 0.550 ms 4 210.77.139.145 (210.77.139.145) 0.708 ms 0.729 ms 0.785 ms 5 202.106.42.101 (202.106.42.101) 7.978 ms 8.155 ms 8.311 ms 6 bt-228-037.bta.net.cn (202.106.228.37) 772.460 ms bt-228-025.bta.net.cn (202.106.228.25) 2.152 ms 61.148.154.97 (61.148.154.97) 772.107 ms 7 124.65.58.221 (124.65.58.221) 4.875 ms 61.148.146.29 (61.148.146.29) 2.124 ms 124.65.58.221 (124.65.58.221) 4.854 ms 8 123.126.6.198 (123.126.6.198) 2.944 ms 61.148.156.6 (61.148.156.6) 3.505 ms 123.126.6.198 (123.126.6.198) 2.885 ms 9 * * * 10 * * * [[email protected] ~]#
说明:
实例3:显示IP地址,不查主机名
命令:
traceroute -n www.baidu.com
输出:
[[email protected] ~]# traceroute -n www.baidu.com traceroute to www.baidu.com (61.135.169.125), 30 hops max, 40 byte packets 1 211.151.74.2 5.430 ms 5.636 ms 5.802 ms 2 211.151.56.57 0.627 ms 0.625 ms 0.617 ms 3 211.151.227.206 0.575 ms 0.584 ms 0.576 ms 4 210.77.139.145 0.703 ms 0.754 ms 0.806 ms 5 202.106.42.101 23.683 ms 23.869 ms 23.998 ms 6 202.106.228.37 247.101 ms * * 7 61.148.146.29 5.256 ms 124.65.58.213 4.386 ms 4.373 ms 8 202.106.35.190 1.610 ms 61.148.156.138 1.786 ms 61.148.3.34 2.089 ms 9 * * * 30 * * * [[email protected] ~]# traceroute www.baidu.com traceroute to www.baidu.com (61.135.169.125), 30 hops max, 40 byte packets 1 211.151.74.2 (211.151.74.2) 4.671 ms 4.865 ms 5.055 ms 2 211.151.56.57 (211.151.56.57) 0.619 ms 0.618 ms 0.612 ms 3 211.151.227.206 (211.151.227.206) 0.620 ms 0.642 ms 0.636 ms 4 210.77.139.145 (210.77.139.145) 0.720 ms 0.772 ms 0.816 ms 5 202.106.42.101 (202.106.42.101) 7.667 ms 7.910 ms 8.012 ms 6 bt-228-025.bta.net.cn (202.106.228.25) 2.965 ms 2.440 ms 61.148.154.97 (61.148.154.97) 431.337 ms 7 124.65.58.213 (124.65.58.213) 5.134 ms 5.124 ms 5.044 ms 8 202.106.35.190 (202.106.35.190) 1.917 ms 2.052 ms 2.059 ms 9 * * * 30 * * * [[email protected] ~]#
说明:
实例4:探测包使用的基本UDP端口设置6888
命令:
traceroute -p 6888 www.baidu.com
输出:
[[email protected] ~]# traceroute -p 6888 www.baidu.com traceroute to www.baidu.com (220.181.111.147), 30 hops max, 40 byte packets 1 211.151.74.2 (211.151.74.2) 4.927 ms 5.121 ms 5.298 ms 2 211.151.56.1 (211.151.56.1) 0.500 ms 0.499 ms 0.509 ms 3 211.151.224.90 (211.151.224.90) 0.637 ms 0.631 ms 0.641 ms 4 * * * 5 220.181.70.98 (220.181.70.98) 5.050 ms 5.313 ms 5.596 ms 6 220.181.17.94 (220.181.17.94) 1.665 ms !X * * [[email protected] ~]#
说明:
实例5:把探测包的个数设置为值4
命令:
traceroute -q 4 www.baidu.com
输出:
[[email protected] ~]# traceroute -q 4 www.baidu.com traceroute to www.baidu.com (61.135.169.125), 30 hops max, 40 byte packets 1 211.151.74.2 (211.151.74.2) 40.633 ms 40.819 ms 41.004 ms 41.188 ms 2 211.151.56.57 (211.151.56.57) 0.637 ms 0.633 ms 0.627 ms 0.619 ms 3 211.151.227.206 (211.151.227.206) 0.505 ms 0.580 ms 0.571 ms 0.569 ms 4 210.77.139.145 (210.77.139.145) 0.753 ms 0.800 ms 0.853 ms 0.904 ms 5 202.106.42.101 (202.106.42.101) 7.449 ms 7.543 ms 7.738 ms 7.893 ms 6 61.148.154.97 (61.148.154.97) 316.817 ms bt-228-025.bta.net.cn (202.106.228.25) 3.695 ms 3.672 ms * 7 124.65.58.213 (124.65.58.213) 3.056 ms 2.993 ms 2.960 ms 61.148.146.29 (61.148.146.29) 2.837 ms 8 61.148.3.34 (61.148.3.34) 2.179 ms 2.295 ms 2.442 ms 202.106.35.190 (202.106.35.190) 7.136 ms 9 * * * * 30 * * * * [[email protected] ~]#
[[email protected] ~]# traceroute -w 3 www.baidu.com traceroute to www.baidu.com (61.135.169.105), 30 hops max, 40 byte packets 1 211.151.74.2 (211.151.74.2) 2.306 ms 2.469 ms 2.650 ms 2 211.151.56.1 (211.151.56.1) 0.621 ms 0.613 ms 0.603 ms 3 211.151.227.206 (211.151.227.206) 0.557 ms 0.560 ms 0.552 ms 4 210.77.139.145 (210.77.139.145) 0.708 ms 0.761 ms 0.817 ms 5 202.106.42.101 (202.106.42.101) 7.520 ms 7.774 ms 7.902 ms 6 bt-228-025.bta.net.cn (202.106.228.25) 2.890 ms 2.369 ms 61.148.154.97 (61.148.154.97) 471.961 ms 7 124.65.58.221 (124.65.58.221) 4.490 ms 4.483 ms 4.472 ms 8 123.126.6.198 (123.126.6.198) 2.948 ms 61.148.156.6 (61.148.156.6) 7.688 ms 7.756 ms 9 * * * 30 * * * [[email protected] ~]#
说明:
Traceroute的工作原理:
Traceroute最简单的基本用法是:traceroute hostname
Traceroute程序的设计是利用ICMP及IP header的TTL(Time To Live)栏位(field)。首先,traceroute送出一个TTL是1的IP datagram(其实,每次送出的为3个40字节的包,包括源地址,目的地址和包发出的时间标签)到目的地,当路径上的第一个路由器(router)收到这个datagram时,它将TTL减1。此时,TTL变为0了,所以该路由器会将此datagram丢掉,并送回一个「ICMP time exceeded」消息(包括发IP包的源地址,IP包的所有内容及路由器的IP地址),traceroute 收到这个消息后,便知道这个路由器存在于这个路径上,接着traceroute 再送出另一个TTL是2 的datagram,发现第2 个路由器...... traceroute 每次将送出的datagram的TTL 加1来发现另一个路由器,这个重复的动作一直持续到某个datagram 抵达目的地。当datagram到达目的地后,该主机并不会送回ICMP time exceeded消息,因为它已是目的地了,那么traceroute如何得知目的地到达了呢?
Traceroute在送出UDP datagrams到目的地时,它所选择送达的port number 是一个一般应用程序都不会用的号码(30000 以上),所以当此UDP datagram 到达目的地后该主机会送回一个「ICMP port unreachable」的消息,而当traceroute 收到这个消息时,便知道目的地已经到达了。所以traceroute 在Server端也是没有所谓的Daemon 程式。
C:\Users\Administrator>tracert www.58.com Tracing route to www.58.com [221.187.111.30] over a maximum of 30 hops: 1 1 ms 1 ms 1 ms 10.58.156.1 2 1 ms <1 ms <1 ms 10.10.10.1 3 1 ms 1 ms 1 ms 211.103.193.129 4 2 ms 2 ms 2 ms 10.255.109.129 5 1 ms 1 ms 3 ms 124.205.98.205 6 2 ms 2 ms 2 ms 124.205.98.253 7 2 ms 6 ms 1 ms 202.99.1.125 8 5 ms 6 ms 5 ms 118.186.0.113 9 207 ms * * 118.186.0.106 10 8 ms 6 ms 11 ms 124.238.226.201 11 6 ms 7 ms 6 ms 219.148.19.177 12 12 ms 12 ms 16 ms 219.148.18.117 13 14 ms 17 ms 16 ms 219.148.19.125 14 13 ms 13 ms 12 ms 202.97.80.113 15 * * * Request timed out. 16 12 ms 12 ms 17 ms bj141-147-82.bjtelecom.net [219.141.147.82] 17 13 ms 13 ms 12 ms 202.97.48.2 18 * * * Request timed out. 19 14 ms 14 ms 12 ms 221.187.224.85 20 15 ms 13 ms 12 ms 221.187.104.2 21 * * * Request timed out. 22 15 ms 17 ms 18 ms 221.187.111.30 Trace complete.