Back to home

Traceroute script

Files

traceroute.py (215 Bytes)

Wrote a small python script for traceroute:

import subprocess

target = input("Enter hostname or IP: ")

print("\nRunning traceroute...\n")

res = subprocess.run(
    ["tracert", target],
    capture_output=True,
    text=True
)

print(res.stdout)
The result:
Tracing route to google.com [2404:6800:4013:407::71]
over a maximum of 30 hops:

  1     2 ms     1 ms     1 ms  [IPv6 Address]
  2     5 ms     4 ms     4 ms  lo0.vb06.melbourne.asp.telstra.net [2001:8003:0:bdf:f0:3:6:0] 
  3     3 ms     3 ms     3 ms  ae10.win-ice301.melbourne.telstra.net [2001:8000:0:2040:101:12b:0:2] 
  4     5 ms     5 ms     5 ms  bundle-ether25.win-core30.melbourne.telstra.net [2001:8000:0:2040:101:12b:0:1] 
  5     *        5 ms     *     bundle-ether1.win-edge903.melbourne.telstra.net [2001:8000:0:2040:101:124:0:2] 
  6     *        *        *     Request timed out.
  7     5 ms     4 ms    13 ms  2404:6800:8242:c0::1 
  8     3 ms     4 ms     4 ms  2001:4860:0:1::46a6 
  9     6 ms     5 ms     5 ms  2001:4860:0:1::1816 
 10     *        *        *     Request timed out.
 11     *        *        *     Request timed out.
 12     *        *        *     Request timed out.
 13     *        *        *     Request timed out.
 14     *        *        *     Request timed out.
 15     *        *        *     Request timed out.
 16     4 ms     3 ms     4 ms  lcmelh-in-f113.1e100.net [2404:6800:4013:407::71] 

Trace complete.