If you have access to ping you might be okay. Depending on the version you have installed you can replicate traceroute manually by setting the TTL (time to live) of the ICMP packets. This is exactly what traceroute does.

The command:
ping -t 1 www.google.com 1

Does a ping with the TTL set to 1 (the -t option). The 1 following the host is the number of times to attempt to connect. So this sends out one packet with the TTL set to 1. The first host that this hits decrements the TTL and checks that it is > 0. If the TTL is not > 0 then it sends an ICMP packet back to the sender telling it that the it is undeliverable since there were too many hops. Next you send another packet with a TTL of 2 and see which host refused it. Keep doing this until you hit the target (or send some maximum number of packets to prevent looping forever) and you will have some path through the network.

My output on Solaris 2.7 looks like:

ICMP Time exceeded in transit from pos5-0-2488m.cr1.snv3.GBLX.net (64. +211.147.14) for icmp from bbsun (216.91.233.128) to www-su.GOOGLE.com (64.208.32. +100) no answer from google.lb.google.com

And on Linux 2.2:

PING google.lb.google.com (64.208.32.100) from 208.176.85.42 : 56(84) +bytes of data. From 208.176.85.41: Time to live exceeded --- google.lb.google.com ping statistics --- 1 packets transmitted, 0 packets received, +1 errors, 100% packet loss

So you will have to parse the response for your machine (also the arguments are different).

Unfortunately the Net::Ping module does not support setting the TTL. But if it did you would need to be root to send ICMP packets. And if you have root access you may as well compile traceroute for that machine :-)

-ben


In reply to Re: traceroute without shell by Anonymous Monk
in thread traceroute without shell by stefan k

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.