#!/usr/bin/env python import sys from scapy.all import * def mytraceroute(target,maxttl): for x in range(maxttl): rsp = sr1(IP(dst=target, ttl=x)/ICMP(),verbose=0) if rsp.getlayer(ICMP).type==11 and rsp.getlayer(ICMP).code==0: print rsp.src mytraceroute("10.0.0.2",8)