How to simulate traceroute using ping?

5,229

There is a way to do this.

In Linux or Cygwin:

for i in {1..30}; do ping -t $i -c 1 google.com; done | grep "Time to live exceeded"

In Windows:

for /l %i in (1,1,30) do @ping -i %i -n 1 google.com | find "TTL expired"

Sample output from an Amazon EC2 VPS:

From 100.64.16.93 icmp_seq=1 Time to live exceeded
From 205.251.232.220 icmp_seq=1 Time to live exceeded
From 205.251.232.202 icmp_seq=1 Time to live exceeded
From 205.251.232.75 icmp_seq=1 Time to live exceeded
From 205.251.225.181 icmp_seq=1 Time to live exceeded
From 72.14.219.251 icmp_seq=1 Time to live exceeded
From 209.85.249.32 icmp_seq=1 Time to live exceeded
From 216.239.51.159 icmp_seq=1 Time to live exceeded

Ping isn't allowed for that instance, that's why it times out.

Share:
5,229

Related videos on Youtube

Kabachok
Author by

Kabachok

Updated on September 18, 2022

Comments

  • Kabachok
    Kabachok over 1 year

    I am learning computer networks and looking for a way to simulate traceroute using the ping command. I think it has something to do with ttl, but I don't know how to develop that further.

    • slhck
      slhck almost 9 years
      Can you elaborate on what exactly you mean by "simulating" a traceroute with ping? Do you have a specific assignment given?
  • td512
    td512 almost 9 years
    No probs, enjoy
  • td512
    td512 almost 9 years
    nothing, but I hardly use windows anymore, so I defaulted to the linux command line
  • td512
    td512 almost 9 years
    @Karan, oh, I didn't know that I needed the @ :D you taught me something new. No, I defaulted because I couldn't think of the windows version. feel free to update the answer if you think it's appropriate. :P
  • Karan
    Karan almost 9 years
    Done. :) (filler)
  • td512
    td512 almost 9 years
    @Karan Thank you. I think Windows is a necessary evil for games, otherwise, it's linux on an SSD :P
  • Karan
    Karan almost 9 years
    Both have pros and cons and I use whatever suits the job at hand best. It's not a religious debate for me like it is for some. :)