How to simulate traceroute using ping?
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.
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.