[(really) OT] find IP address of a pppd

Paul Fenwick pjf at perltraining.com.au
Wed Oct 15 17:29:23 BST 2008

G'day Dirk / London.pm,

Dirk Koopman wrote:

> I want to be able to do this from within the program controlling the
> pppds, preferably without calling any helper programs (eg ifconfig or

This is a short continuation of my previous mail...

If you're not even happy to call ifconfig when you've been told the
interface that has changed, then it looks like you can do an ioctl(int
fileno,  magic SIOCGIFADDR, struct ifreq *you_get_your_data_back_here) on a
socket that has been opened on the ppp interface in question.  At least,
that's how ifconfig gets to the address and other info.

Actually doing this is left as an exercise to the reader.  I just ripped the
relevant system calls out of strace. ;)



Paul Fenwick <pjf at perltraining.com.au> | http://perltraining.com.au/
Director of Training                   | Ph:  +61 3 9354 6001
Perl Training Australia                | Fax: +61 3 9354 2681

More information about the london.pm mailing list