http://www.perlmonks.org?node_id=240371


in reply to Re: Unexpected results from ping
in thread Unexpected results from ping

By default Net::Ping uses a different method of determining a host's status (TCP echo) than the 'ping' utility (ICMP echo) because doing ICMP echo on unix systems requires root privileges to open a so-called "raw socket".

It does not take root privileges to create an ICMP echo request... you can test it yourself by logging in as a non-root user and playing with the "ping" program. Maybe you have confused this with putting the network card in promiscuous mode which is required for programs like tcpdump?

Update You know, xmath I never noticed that ping was setuid to root, so that, indeed, was a poor example. *Smiles*

Update 2 Ok, so I went back through all my crafted packet code, and I can not find a single example of being able to craft an ICMP packet without being root. With that said, it does indeed seem that xmath was correct.

Replies are listed 'Best First'.
Re: Re: Re: Unexpected results from ping
by xmath (Hermit) on Mar 04, 2003 at 15:19 UTC
    you can test it yourself by logging in as a non-root user and playing with the "ping" program

    The "ping" utility is always setuid root:

    [Quoose:~] xmath% ls -l `which ping` -r-sr-xr-x 1 root wheel 24920 Dec 23 15:17 /sbin/ping

    That's why normal users can use it. :-)

    Update: it seems that lately raw sockets are no longer needed for ICMP on some platforms (Darwin / Mac OS X); but on most (Linux etc) they still are