traceroute

发布时间: 更新时间: 总字数:1776 阅读时间:4m 作者: 分享 复制网址

traceroute 指令让你追踪网络数据包的路由途径

安装

yum install traceroute -y

Help

traceroute --help
Usage:
  traceroute [ -46dFITnreAUDV ] [ -f first_ttl ] [ -g gate,... ] [ -i device ] [ -m max_ttl ] [ -N squeries ] [ -p port ] [ -t tos ] [ -l flow_label ] [ -w waittime ] [ -q nqueries ] [ -s src_addr ] [ -z sendwait ] [ --fwmark=num ] host [ packetlen ]
Options:
  -4                          Use IPv4
  -6                          Use IPv6
  -d  --debug                 Enable socket level debugging
  -F  --dont-fragment         Do not fragment packets
  -f first_ttl  --first=first_ttl
                              Start from the first_ttl hop (instead from 1)
  -g gate,...  --gateway=gate,...
                              Route packets through the specified gateway
                              (maximum 8 for IPv4 and 127 for IPv6)
  -I  --icmp                  Use ICMP ECHO for tracerouting
  -T  --tcp                   Use TCP SYN for tracerouting (default port is 80)
  -i device  --interface=device
                              Specify a network interface to operate with
  -m max_ttl  --max-hops=max_ttl
                              Set the max number of hops (max TTL to be
                              reached). Default is 30
  -N squeries  --sim-queries=squeries
                              Set the number of probes to be tried
                              simultaneously (default is 16)
  -n                          Do not resolve IP addresses to their domain names
  -p port  --port=port        Set the destination port to use. It is either
                              initial udp port value for "default" method
                              (incremented by each probe, default is 33434), or
                              initial seq for "icmp" (incremented as well,
                              default from 1), or some constant destination
                              port for other methods (with default of 80 for
                              "tcp", 53 for "udp", etc.)
  -t tos  --tos=tos           Set the TOS (IPv4 type of service) or TC (IPv6
                              traffic class) value for outgoing packets
  -l flow_label  --flowlabel=flow_label
                              Use specified flow_label for IPv6 packets
  -w waittime  --wait=waittime
                              Set the number of seconds to wait for response to
                              a probe (default is 5.0). Non-integer (float
                              point) values allowed too
  -q nqueries  --queries=nqueries
                              Set the number of probes per each hop. Default is
                              3
  -r                          Bypass the normal routing and send directly to a
                              host on an attached network
  -s src_addr  --source=src_addr
                              Use source src_addr for outgoing packets
  -z sendwait  --sendwait=sendwait
                              Minimal time interval between probes (default 0).
                              If the value is more than 10, then it specifies a
                              number in milliseconds, else it is a number of
                              seconds (float point values allowed too)
  -e  --extensions            Show ICMP extensions (if present), including MPLS
  -A  --as-path-lookups       Perform AS path lookups in routing registries and
                              print results directly after the corresponding
                              addresses
  -M name  --module=name      Use specified module (either builtin or external)
                              for traceroute operations. Most methods have
                              their shortcuts (`-I' means `-M icmp' etc.)
  -O OPTS,...  --options=OPTS,...
                              Use module-specific option OPTS for the
                              traceroute module. Several OPTS allowed,
                              separated by comma. If OPTS is "help", print info
                              about available options
  --sport=num                 Use source port num for outgoing packets. Implies
                              `-N 1'
  --fwmark=num                Set firewall mark for outgoing packets
  -U  --udp                   Use UDP to particular port for tracerouting
                              (instead of increasing the port per each probe),
                              default port is 53
  -UL                         Use UDPLITE for tracerouting (default dest port
                              is 53)
  -D  --dccp                  Use DCCP Request for tracerouting (default port
                              is 33434)
  -P prot  --protocol=prot    Use raw packet of protocol prot for tracerouting
  --mtu                       Discover MTU along the path being traced. Implies
                              `-F -N 1'
  --back                      Guess the number of hops in the backward path and
                              print if it differs
  -V  --version               Print version info and exit
  --help                      Read this help and exit

Arguments:
+     host          The host to traceroute to
      packetlen     The full packet length (default is the length of an IP
                    header plus 40). Can be ignored or increased to a minimal
                    allowed value
  • -d 使用Socket层级的排错功能
  • -f 设置第一个检测数据包的存活数值TTL的大小
  • -F 设置勿离断位
  • -g 设置来源路由网关,最多可设置8个
  • -i 使用指定的网络界面送出数据包
  • -I 使用ICMP回应取代UDP资料信息
  • -m 设置检测数据包的最大存活数值TTL的大小
  • -n 直接使用IP地址而非主机名称
  • -p 设置UDP传输协议的通信端口
  • -r 忽略普通的Routing Table,直接将数据包送到远端主机上
  • -s 设置本地主机送出数据包的IP地址
  • -t 设置检测数据包的TOS数值
  • -v 详细显示指令的执行过程
  • -w 设置等待远端主机回报的时间
  • -x 开启或关闭数据包的正确性检验

Use

  • 简单方式
# traceroute www.xiexianbin.cn
traceroute to www.xiexianbin.cn (180.163.121.221), 30 hops max, 60 byte packets
 1  * * *
 2  11.219.4.77 (11.219.4.77)  6.011 ms 11.219.4.5 (11.219.4.5)  6.361 ms 11.219.5.77 (11.219.5.77)  6.350 ms
 3  11.219.4.134 (11.219.4.134)  5.810 ms 11.219.5.126 (11.219.5.126)  4.684 ms 11.219.5.134 (11.219.5.134)  5.921 ms
 4  10.54.188.218 (10.54.188.218)  0.688 ms  0.676 ms 10.54.160.117 (10.54.160.117)  0.344 ms
 5  116.251.127.18 (116.251.127.18)  1.028 ms 103.52.86.90 (103.52.86.90)  0.814 ms 116.251.127.70 (116.251.127.70)  1.298 ms
 6  103.41.143.110 (103.41.143.110)  0.926 ms 116.251.113.45 (116.251.113.45)  2.695 ms 116.251.113.37 (116.251.113.37)  1.193 ms
 7  150.138.130.113 (150.138.130.113)  2331.626 ms 150.138.132.129 (150.138.132.129)  1375.378 ms 150.138.132.153 (150.138.132.153)  589.550 ms
 8  150.138.128.73 (150.138.128.73)  2.208 ms 150.138.131.209 (150.138.131.209)  1.938 ms 150.138.128.169 (150.138.128.169)  5.754 ms
 9  202.97.99.189 (202.97.99.189)  21.751 ms  22.153 ms  22.556 ms
10  101.95.88.73 (101.95.88.73)  14.375 ms 61.152.25.201 (61.152.25.201)  18.768 ms 61.152.25.189 (61.152.25.189)  23.792 ms
...
30  * * *
  • 跳数设置
# traceroute -m 10 www.xiexianbin.cn
traceroute to www.xiexianbin.cn (180.163.121.221), 10 hops max, 60 byte packets
 1  * * *
 2  11.219.5.5 (11.219.5.5)  4.600 ms 11.219.5.77 (11.219.5.77)  4.999 ms 11.219.5.5 (11.219.5.5)  4.790 ms
 3  11.219.4.126 (11.219.4.126)  3.146 ms 11.219.4.62 (11.219.4.62)  4.630 ms 11.219.5.62 (11.219.5.62)  4.773 ms
 4  10.54.188.178 (10.54.188.178)  2.815 ms 10.54.143.241 (10.54.143.241)  0.349 ms 10.54.160.33 (10.54.160.33)  0.351 ms
 5  103.41.143.129 (103.41.143.129)  1.063 ms 103.52.86.86 (103.52.86.86)  1.059 ms 116.251.117.202 (116.251.117.202)  0.723 ms
 6  103.41.143.110 (103.41.143.110)  1.064 ms 116.251.113.45 (116.251.113.45)  1.261 ms 116.251.113.73 (116.251.113.73)  1.267 ms
 7  * * *
 8  150.138.131.205 (150.138.131.205)  7.159 ms 150.138.128.37 (150.138.128.37)  1.573 ms 150.138.128.69 (150.138.128.69)  6.831 ms
 9  202.97.99.165 (202.97.99.165)  19.861 ms 202.97.99.181 (202.97.99.181)  17.838 ms 202.97.99.169 (202.97.99.169)  18.757 ms
10  61.152.25.169 (61.152.25.169)  18.707 ms 61.152.25.133 (61.152.25.133)  13.529 ms 101.95.88.113 (101.95.88.113)  19.273 ms
  • 显示IP地址 不查主机名
# traceroute -n www.xiexianbin.cn
traceroute to www.xiexianbin.cn (180.163.121.221), 30 hops max, 60 byte packets
 1  * * *
 2  11.219.5.5  3.757 ms 11.219.4.5  5.124 ms 11.219.4.77  5.438 ms
 3  11.219.5.126  4.321 ms 11.219.5.134  3.504 ms 11.219.4.126  3.457 ms
 4  10.54.143.197  11.083 ms 10.54.188.218  0.390 ms  0.393 ms
 5  103.41.143.65  1.531 ms 116.251.127.6  1.204 ms 103.41.143.145  1.034 ms
 6  103.41.143.54  1.058 ms 103.41.143.46  1.534 ms 103.41.143.118  1.277 ms
 7  * * *
 8  150.138.128.121  8.566 ms  8.913 ms 150.138.131.129  6.304 ms
 9  202.97.99.185  21.787 ms * 202.97.99.173  20.006 ms
10  61.152.25.141  17.220 ms 61.152.25.41  21.755 ms 61.152.24.129  20.994 ms
...
30  * * *
  • 探测包使用的基本UDP端口6888
# traceroute -p 6888 www.xiexianbin.cn
traceroute to www.xiexianbin.cn (180.163.121.221), 30 hops max, 60 byte packets
 1  * * *
 2  11.219.4.5 (11.219.4.5)  16.448 ms 11.219.5.77 (11.219.5.77)  4.623 ms  4.691 ms
 3  11.219.5.126 (11.219.5.126)  4.497 ms 11.219.5.134 (11.219.5.134)  3.957 ms 11.219.5.54 (11.219.5.54)  3.764 ms
 4  10.54.160.69 (10.54.160.69)  9.847 ms 10.54.160.17 (10.54.160.17)  7.680 ms 10.54.160.53 (10.54.160.53)  9.796 ms
 5  116.251.127.46 (116.251.127.46)  1.094 ms 103.52.86.106 (103.52.86.106)  1.388 ms 103.52.86.122 (103.52.86.122)  0.545 ms
 6  116.251.113.53 (116.251.113.53)  1.070 ms 103.41.143.46 (103.41.143.46)  1.624 ms 103.41.143.54 (103.41.143.54)  1.243 ms
 7  150.138.130.113 (150.138.130.113)  3320.393 ms * 150.138.132.105 (150.138.132.105)  1.113 ms
 8  150.138.128.133 (150.138.128.133)  5.710 ms 150.138.128.213 (150.138.128.213)  1.328 ms 150.138.131.209 (150.138.131.209)  2.062 ms
 9  202.97.99.169 (202.97.99.169)  18.740 ms 202.97.99.177 (202.97.99.177)  29.296 ms 202.97.99.185 (202.97.99.185)  21.390 ms
10  61.152.24.113 (61.152.24.113)  17.388 ms 61.152.24.233 (61.152.24.233)  19.707 ms *
11  124.74.166.34 (124.74.166.34)  82.140 ms 101.95.207.102 (101.95.207.102)  74.709 ms 101.95.207.254 (101.95.207.254)  28.502 ms
...
30  * * *
  • 把探测包的个数设置为值4
# traceroute -q 4 www.xiexianbin.cn
traceroute to www.xiexianbin.cn (180.163.121.221), 30 hops max, 60 byte packets
 1  * * * *
 2  11.219.4.77 (11.219.4.77)  4.635 ms 11.219.4.5 (11.219.4.5)  4.143 ms  4.339 ms 11.219.5.77 (11.219.5.77)  3.982 ms
 3  * 11.219.4.54 (11.219.4.54)  2.970 ms 11.219.4.134 (11.219.4.134)  2.975 ms 11.219.5.62 (11.219.5.62)  5.175 ms
 4  10.54.188.202 (10.54.188.202)  0.613 ms 10.54.160.81 (10.54.160.81)  5.799 ms 10.54.143.237 (10.54.143.237)  5.765 ms 10.54.160.17 (10.54.160.17)  5.756 ms
 5  116.251.117.206 (116.251.117.206)  0.809 ms 116.251.114.106 (116.251.114.106)  0.756 ms 103.52.86.58 (103.52.86.58)  2.185 ms 116.251.127.46 (116.251.127.46)  1.300 ms
 6  103.41.143.122 (103.41.143.122)  1.158 ms 116.251.113.53 (116.251.113.53)  0.890 ms 103.41.143.114 (103.41.143.114)  1.278 ms 103.41.143.50 (103.41.143.50)  5.374 ms
 7  150.138.132.153 (150.138.132.153)  1.956 ms * 150.138.130.129 (150.138.130.129)  610.716 ms *
 8  150.138.128.213 (150.138.128.213)  1.455 ms 150.138.128.177 (150.138.128.177)  5.697 ms 150.138.128.141 (150.138.128.141)  1.369 ms 150.138.128.189 (150.138.128.189)  1.846 ms
 9  202.97.99.177 (202.97.99.177)  21.370 ms 202.97.108.1 (202.97.108.1)  28.361 ms 202.97.99.185 (202.97.99.185)  21.543 ms 202.97.99.161 (202.97.99.161)  14.726 ms
10  61.152.24.145 (61.152.24.145)  20.593 ms 61.152.24.113 (61.152.24.113)  17.494 ms 101.95.88.101 (101.95.88.101)  28.710 ms 61.152.24.241 (61.152.24.241)  18.861 ms
...
30  * * * *
  • 绕过正常的路由表,直接发送到网络相连的主机
# traceroute -r www.xiexianbin.cn
traceroute to www.xiexianbin.cn
  • 把对外发探测包的等待响应时间设置为3秒
# traceroute -w 3 www.xiexianbin.cn
traceroute to www.xiexianbin.cn (180.163.121.221), 30 hops max, 60 byte packets
 1  * * *
 2  11.219.5.77 (11.219.5.77)  5.809 ms 11.219.4.5 (11.219.4.5)  7.448 ms  7.513 ms
 3  11.219.5.126 (11.219.5.126)  6.224 ms 11.219.5.134 (11.219.5.134)  3.274 ms 11.219.4.126 (11.219.4.126)  7.971 ms
 4  10.54.160.81 (10.54.160.81)  6.745 ms 11.219.68.34 (11.219.68.34)  0.634 ms 10.54.160.125 (10.54.160.125)  0.387 ms
 5  103.52.86.62 (103.52.86.62)  1.303 ms 103.52.86.118 (103.52.86.118)  0.523 ms 103.41.143.69 (103.41.143.69)  1.970 ms
 6  116.251.113.57 (116.251.113.57)  5.903 ms 116.251.113.221 (116.251.113.221)  1.184 ms 116.251.113.73 (116.251.113.73)  2.846 ms
 7  150.138.132.157 (150.138.132.157)  1.234 ms 150.138.130.133 (150.138.130.133)  549.912 ms 150.138.130.125 (150.138.130.125)  549.608 ms
 8  150.138.128.169 (150.138.128.169)  5.826 ms 150.138.131.201 (150.138.131.201)  1.435 ms 150.138.128.125 (150.138.128.125)  1.710 ms
 9  202.97.99.181 (202.97.99.181)  30.609 ms 202.97.108.1 (202.97.108.1)  23.109 ms 202.97.99.185 (202.97.99.185)  21.938 ms
10  101.95.88.125 (101.95.88.125)  16.952 ms 61.152.25.185 (61.152.25.185)  19.580 ms 61.152.24.125 (61.152.24.125)  25.712 ms
11  101.95.207.102 (101.95.207.102)  78.753 ms  79.335 ms 101.95.207.254 (101.95.207.254)  79.462 ms
...
13  * * *
最新评论
加载中...
Home Archives Categories Tags Statistics