欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

Linux traceroute命令使用详解

程序员文章站 2022-05-12 18:19:15
traceroute我们可以知道信息从你的计算机到互联网另一端的主机是走的什么路径。当然每次数据包由某一同样的出发点(source)到达某一同样的目的地(destination)走的路...

traceroute我们可以知道信息从你的计算机到互联网另一端的主机是走的什么路径。当然每次数据包由某一同样的出发点(source)到达某一同样的目的地(destination)走的路径可能会不一样,但基本上来说大部分时候所走的路由是相同的。

常见命令参数

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
 -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'
 -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)
 -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

常见命令展示

多命令使用

traceroute -n -m 5 -q 4 -w 3 www.baidu.com

Linux traceroute命令使用详解

说明: -n 显示ip地址,不查主机名, -m 设置跳数

-q 4每个网关发送4个数据包 -w 把对外发探测包的等待响应时间设置为3秒

探测包使用的基本udp端口设置6888

traceroute -p 6888 www.baidu.com

绕过正常的路由表,直接发送到网络相连的主机

traceroute -r www.baidu.com

Linux traceroute命令使用详解

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。