[Linux] traceroute 路由跟踪指令用例

       traceroute是用来跟踪数据包到达网络主机所经过的路由工具。在Linux系统中,称之为traceroute,在Windows中称为tracert。

一条路径上的每个设备traceroute要测3次。输出结果中包含每次测试的时间(ms)和设备的名称及其IP。

       1、命令格式:traceroute [参数] [主机]

       2、常用命令参数:

                -n  直接使用IP地址而非主机名称

                -m 设置数据包的最大存活数TTL的大小

                -p  设置UDP传输协议的通信端口

                -q  设置探测包的个数

       3、使用实例

    命令:traceroute www.baidu.com

1 [root@CentOS-7 shu]# traceroute www.baidu.com
2 traceroute to www.baidu.com (14.215.177.39), 30 hops max, 60 byte packets
3  1  10.18.242.125 (10.18.242.125)  4.081 ms  3.981 ms  4.666 ms
4  2  192.168.253.22 (192.168.253.22)  3.174 ms  3.788 ms  3.738 ms
5  3  192.168.253.5 (192.168.253.5)  27.642 ms  27.620 ms  27.581 ms
6  4  * * *

      命令:traceroute -m 10 www.baidu.com       跳数设置

 1 [root@CentOS-7 shu]# traceroute -m 10 www.baidu.com
 2 traceroute to www.baidu.com (14.215.177.39), 10 hops max, 60 byte packets
 3  1  10.18.242.125 (10.18.242.125)  6.263 ms  6.133 ms  6.187 ms
 4  2  192.168.253.22 (192.168.253.22)  3.555 ms  3.454 ms  4.203 ms
 5  3  192.168.253.5 (192.168.253.5)  22.571 ms  23.238 ms  23.737 ms
 6  4  * * *
 7  5  * * *
 8  6  * * *
 9  7  * * *
10  8  * * *
11  9  * * *
12 10  * * *
13 [root@CentOS-7 shu]#

                 命令:traceroute -n 132.121.86.3  显示IP地址,不查主机名

1 [opan@op1 ~]$ sudo ssh 132.121.88.181
2 [root@nagios ~]# traceroute -n 132.121.86.3
3 traceroute to 132.121.86.3 (132.121.86.3), 30 hops max, 60 byte packets
4  1  132.121.88.254  14.634 ms  14.056 ms  13.639 ms
5  2  * * *
6  3  * * *
7  4  * * *

                  命令:traceroute -p 6888 www.baidu.com 探测包使用基本UDP端口设置6888

1 [root@CentOS-7 shu]# traceroute -p 6888 www.baidu.com
2 traceroute to www.baidu.com (14.215.177.39), 30 hops max, 60 byte packets
3  1  10.18.242.125 (10.18.242.125)  6.660 ms  7.026 ms  7.904 ms
4  2  192.168.253.22 (192.168.253.22)  3.838 ms  3.789 ms  3.735 ms
5  3  192.168.253.5 (192.168.253.5)  2.282 ms  2.915 ms  3.570 ms
6  4  * * *

                 命令:traceroute -q 4 www.baidu.com  探测包的个数设置为4

1 [root@CentOS-7 shu]# traceroute -q 4 www.baidu.com
2 traceroute to www.baidu.com (14.215.177.39), 30 hops max, 60 byte packets
3  1  10.18.242.125 (10.18.242.125)  5.458 ms  6.021 ms  7.104 ms  7.015 ms
4  2  192.168.253.22 (192.168.253.22)  4.377 ms  4.332 ms  4.272 ms  4.202 ms
5  3  192.168.253.5 (192.168.253.5)  2.150 ms  2.100 ms  2.043 ms  2.527 ms
6  4  * * * *

       windows之tracert:

 1 C:\Users\Administrator>tracert www.58.com
 2 
 3 Tracing route to www.58.com [221.187.111.30]
 4 over a maximum of 30 hops:
 5 
 6   1     1 ms     1 ms     1 ms  10.58.156.1
 7   2     1 ms    <1 ms    <1 ms  10.10.10.1
 8   3     1 ms     1 ms     1 ms  211.103.193.129
 9   4     2 ms     2 ms     2 ms  10.255.109.129
10   5     1 ms     1 ms     3 ms  124.205.98.205
11   6     2 ms     2 ms     2 ms  124.205.98.253
12   7     2 ms     6 ms     1 ms  202.99.1.125
13   8     5 ms     6 ms     5 ms  118.186.0.113
14   9   207 ms     *        *     118.186.0.106
15  10     8 ms     6 ms    11 ms  124.238.226.201
16  11     6 ms     7 ms     6 ms  219.148.19.177
17  12    12 ms    12 ms    16 ms  219.148.18.117
18  13    14 ms    17 ms    16 ms  219.148.19.125
19  14    13 ms    13 ms    12 ms  202.97.80.113
20  15     *        *        *     Request timed out.
21  16    12 ms    12 ms    17 ms  bj141-147-82.bjtelecom.net [219.141.147.82]
22  17    13 ms    13 ms    12 ms  202.97.48.2
23  18     *        *        *     Request timed out.
24  19    14 ms    14 ms    12 ms  221.187.224.85
25  20    15 ms    13 ms    12 ms  221.187.104.2
26  21     *        *        *     Request timed out.
27  22    15 ms    17 ms    18 ms  221.187.111.30
28 
29 Trace complete.

 

posted @ 2017-10-10 15:48  那年花开月正圆  阅读(4596)  评论(0编辑  收藏  举报