Bash中的IP跟踪命令

时间:2020-01-09 10:44:11  来源:igfitidea点击:

问题描述:bash中的ip trace命令是什么?
如何在Linux/UNIX bash shell提示符中跟踪IP地址?

解决方法:您可以在bash中使用以下任何命令来跟踪IP地址和其他内容:a] traceroute跟踪通过IP网络到达给定主机的路由数据包。
它利用IP协议的生存时间(TTL)字段并尝试从每个网关到主机的路径引发ICMP TIME_EXCEEDED响应。

  • tracepath跟踪到目的地的路径,沿着该路径发现MTU。
    它使用UDP端口端口或者某些随机端口。
    它类似于traceroute,仅不需要上级用户特权。
    选项-c使tracepath使用返回地址而不是回复类型(拒绝连接)来确定何时停止。

traceroute命令示例

要跟踪IP路由器,请执行:

$ traceroute {IP-address}
$ traceroute 192.54.2.5
$ traceroute google.com

输出示例:

1  sl1-dallas.simplyguide.org (10.16.48.97)  0.539 ms  0.740 ms  0.727 ms
2  po102.dar01.dal01.dallas-datacenter.com (66.228.118.177)  0.713 ms  0.705 ms  0.900 ms
3  po1.cer02.dal01.dallas-datacenter.com (66.228.118.204)  1.125 ms  1.115 ms  1.102 ms
4  xe-7-4.r02.dllstx09.us.bb.gin.ntt.net (157.238.224.69)  168.721 ms  168.716 ms  168.704 ms
5  4.68.63.221 (4.68.63.221)  1.748 ms te-10-1-0.edge2.Dallas3.level3.net (4.68.63.225)  1.722 ms  1.940 ms
6  ge-1-3-0-79.bbr2.Dallas1.Level3.net (4.68.19.66)  1.928 ms ge-1-3-0-79.bbr1.Dallas1.Level3.net (4.68.19.65)  1.055 ms ge-6-1-0-99.bbr1.Dallas1.Level3.net (4.68.19.193)  1.053 ms
7  as-1-0.bbr1.Atlanta1.Level3.net (209.247.9.101)  21.007 ms ae-0-0.bbr2.Atlanta1.Level3.net (64.159.1.46)  21.242 ms as-1-0.bbr1.Atlanta1.Level3.net (209.247.9.101)  21.235 ms
8  ae-21-52.car1.Atlanta1.Level3.net (4.68.103.34)  21.696 ms ae-11-51.car1.Atlanta1.Level3.net (4.68.103.2)  21.691 ms ae-21-52.car1.Atlanta1.Level3.net (4.68.103.34)  21.907 ms
9  GOOGLE-INC.car1.Atlanta1.Level3.net (4.78.209.194)  21.897 ms  22.126 ms  22.097 ms
10  209.85.254.243 (209.85.254.243)  22.576 ms  188.966 ms 209.85.254.241 (209.85.254.241)  22.549 ms
11  209.85.253.145 (209.85.253.145)  22.180 ms 209.85.253.133 (209.85.253.133)  30.700 ms 209.85.253.137 (209.85.253.137)  30.647 ms
12  yx-in-f100.google.com (74.125.45.100)  22.369 ms  22.295 ms  22.278 ms

tracert等效于traceroute -I

要运行Windows等效的tracert命令,请执行:

$ traceroute -I google.com

跟踪路径示例

执行命令,如下所示:

$ tracepath {ip-address}
$ tracepath google.com