[(really) OT] find IP address of a pppd
macgyver at thedumbterminal.co.uk
Thu Oct 16 22:51:59 BST 2008
On Thursday 16 Oct 2008, Toby Corkindale wrote:
> On Wed, Oct 15, 2008 at 03:17:05PM +0100, Dirk Koopman wrote:
> > Before someone goes off on one, this is not an FAQ which involves reading
> > about if-up/if-down, you may assume that I have done that and understood
> > it.
> > I have a program (running only on linux 2.6 kernels) which controls one
> > *or* more instances of pppd. Any or all of those pppds could start or
> > stop at any time.
> > Given the process number of the pppd in question, I want to find out (or
> > be notified [this may be a dbus question]) the ip address assigned to the
> > pppd that has just been started.
> > If there is more than one pppd being started (which may happen
> > simultaneously - although that, at least, can be controlled), it is very
> > important to me that I get the IP address that pertains to the pppd that
> > is controlling it.
> > I want to be able to do this from within the program controlling the
> > pppds, preferably without calling any helper programs (eg ifconfig or
> > lsof) or doing any if-up/if-down magic from within pppd. I am presuming
> > that this involves poking around inside /proc and/or /sys.
> > What I can't seem to find is some pathway from the process id to either
> > the correct device name and then another to the ip(v4) address.
> /var/run/ppp*.pid will give you the mapping between process IDs of pppd and
> interfaces. (Path might vary between operating systems..)
> Getting from ppp1 to 192.168.66.6 or whatever could be done on Linux by
> parsing the output of `ip addr show dev ppp1`, but would vary on other OSs.
> There must be a CPAN module to do this generically?
works for me (tested with normal ethernet and loopback interfaces)
More information about the london.pm