V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
magic3584
V2EX  ›  计算机

请教一个计算机网络的问题,为什么 traceroute 看不到路由信息

  •  
  •   magic3584 · 2021-08-05 18:38:22 +08:00 · 1784 次点击
    这是一个创建于 966 天前的主题,其中的信息可能已经有所发展或是发生改变。

    起因

    公司里,A 电脑使用有线连接,本机使用 wifi 连接。本机 ping A 电脑能 ping 通,但是 traceroute 找不到路由信息

    相关截图

    1

    2

    疑问

    想请问各位大佬:

    为什么 traceroute 返回都是 * 并且看不到路由信息(如果能详细就最好了,我学习以后再来加深理解)

    感觉计算机网络还得再学一学。。。

    第 1 条附言  ·  2021-08-05 19:26:26 +08:00
    ➜  ~ traceroute -P TCP 172.16.107.38
    traceroute to 172.16.107.38 (172.16.107.38), 64 hops max, 64 byte packets
     1  * * *
     2  * * *
     3  * * *
     4  * * *
     5  * * *
     6  *^Z
    [10]  + 787 suspended  traceroute -P TCP 172.16.107.38
    ➜  ~ traceroute -P UDP 172.16.107.38
    traceroute to 172.16.107.38 (172.16.107.38), 64 hops max, 52 byte packets
     1  * * *
     2  172.16.107.38 (172.16.107.38)  25.092 ms  18.907 ms  5.527 ms
    ➜  ~ traceroute -P ICMP 172.16.107.38
    traceroute to 172.16.107.38 (172.16.107.38), 64 hops max, 72 byte packets
     1  * * *
     2  172.16.107.38 (172.16.107.38)  9.580 ms  4.589 ms  5.172 ms
    
    第 2 条附言  ·  2021-08-06 10:29:30 +08:00
                                                   My traceroute  [v0.94]
    MacBook-Pro.local (172.16.101.60) -> 172.16.107.38             2021-08-06T10:28:13+0800
    Keys:  Help   Display mode   Restart statistics   Order of fields   quit
                                                                                Packets               Pings
     Host                                    Loss%   Snt   Last   Avg  Best  Wrst StDev
     1. (waiting for reply)
     2. 172.16.107.38                        0.0%    51    6.1  43.8   3.4 350.9  82.5
    
    17 条回复    2021-08-06 10:30:03 +08:00
    learningman
        1
    learningman  
       2021-08-05 19:37:08 +08:00 via Android   ❤️ 1
    trackroute 的原理是发送 TTL 递增的 ICMP 包
    privil
        2
    privil  
       2021-08-05 19:40:10 +08:00   ❤️ 1
    可以用 mtr
    Tianao
        3
    Tianao  
       2021-08-05 19:47:29 +08:00 via iPhone   ❤️ 1
    有些路由器不返回 ICMP 报文告知源主机 TTL 过期。
    freelancher
        4
    freelancher  
       2021-08-05 22:29:20 +08:00
    二楼说的应该是正确的。
    weyou
        5
    weyou  
       2021-08-05 23:02:35 +08:00 via Android
    @learningman 并不是! traceroute 默认发送的是 UDP 包
    magic3584
        6
    magic3584  
    OP
       2021-08-05 23:08:45 +08:00
    @learningman #1

    @weyou #5

    大佬能否详细说说
    weyou
        7
    weyou  
       2021-08-05 23:11:18 +08:00 via Android   ❤️ 1
    显示*号就是这个节点没有任何回应呗,可能是防火墙挡掉了,可以换用不用的 probe 方式,比如-I 或者-T 试试

    From `man traceroute`:
    This program attempts to trace the route an IP packet would follow to some internet host by launching probe packets with a small ttl (time to live) then listening for an ICMP "time exceeded" reply from a gateway. We start our probes with a ttl of one and increase by one until we get an ICMP "port unreachable" (or TCP reset), which means we got to the "host", or hit a max (which defaults to 30 hops). Three probes (by default) are sent at each ttl setting and a line is printed showing the ttl, address of the gateway and round trip time of each probe. The address can be followed by addi‐ tional information when requested. If the probe answers come from different gateways, the address of each responding system will be printed. If there is no response within a certain timeout, an "*" (asterisk) is printed for that probe.
    magic3584
        8
    magic3584  
    OP
       2021-08-05 23:19:45 +08:00
    @Tianao #3
    用 TCP 和 UDP 也不返回吗?
    如果没收到 ICMP 报文或者 TTL 过期,就自动 TTL+1 发下一个报文吗?
    第一个图里为什么两次 traceroute 跳数不一致呢?
    magic3584
        9
    magic3584  
    OP
       2021-08-05 23:22:38 +08:00
    @weyou #7
    大佬麻烦看下上图里为什么跳数不一致呢?
    另附言里 3 种协议都试了,均无反应
    hahasong
        10
    hahasong  
       2021-08-06 00:02:52 +08:00   ❤️ 1
    这 Ping 它干啥,已知 AB 的 IP 和子网,分属不同的子网,能 ping 通说明两个子网相连,要通的话肯定第一跳是你的网关,最后一跳是 B 的网关
    Samuelcc
        11
    Samuelcc  
       2021-08-06 03:02:43 +08:00 via Android   ❤️ 1
    很多商业路由不会响应 traceroute,防止针对攻击。
    Tianao
        12
    Tianao  
       2021-08-06 08:09:53 +08:00 via iPhone
    @magic3584 #8 那就是源主机期望中间路由器返回一个 ICMP 目的不可达但路由器不一定返回,返不返回是可以配置的,与技术原理 /厂商实现没有必然关系。
    AllenHua
        13
    AllenHua  
       2021-08-06 08:41:23 +08:00 via iPhone
    Linux 下使用 traceroute 出现星号,一般原因是 linux 的 traceroute 默认使用 tcp 或 udp,强制使用 ICMP 就行了。https://hellodk.cn/post/19
    AllenHua
        14
    AllenHua  
       2021-08-06 09:07:26 +08:00   ❤️ 1
    ```
    # 大写的 I,指定 ICMP protocol
    $ traceroute -I example.com
    ```

    https://www.computerhope.com/unix/utracero.htm
    magic3584
        15
    magic3584  
    OP
       2021-08-06 10:14:37 +08:00
    @hahasong #10
    主要是刚又看了点网络的东西,就试着分析一下,结果跟我想的不太对。。。
    magic3584
        16
    magic3584  
    OP
       2021-08-06 10:15:44 +08:00
    @AllenHua #13
    附言里都使用了,结果差不多。。。
    magic3584
        17
    magic3584  
    OP
       2021-08-06 10:30:03 +08:00
    @privil #2
    已附言,看来结果都一样
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5240 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 09:17 · PVG 17:17 · LAX 02:17 · JFK 05:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.