From: "Mauricio Fernández" Date: 2003-01-27T07:53:05+09:00 Subject: Re: Getting the dynamic IP address of a dialup interface (ppp0) On Mon, Jan 27, 2003 at 07:37:38AM +0900, Eric Hodel wrote: > Mauricio Fern?ndez (batsman.geo@yahoo.com) wrote: > > > > > I need to get the dynamic IP address of the ppp0 interface > > (point-to-point) under Linux. I cannot do a reverse DNS > > lookup since the associated name is dynamic too (something like > > user-bla-bla-IP-.someisp.com), and I would prefer to avoid parsing > > `/sbin/ifconfig` since > > a) I don't know how reliable it would be (and it's ugly anyway) > > b) I cannot get sample output to work on since I have no access to the > > remote machine (I was planning on somebody installing my script that) > > > > [Context: I'm binding a socket to that interface and sending the IP and > > port info w/ UDP to another computer (server) behind a firewall that then > > connects to the client. This is all required because of quite draconian > > firewalling rules (my machine is behind _THREE_ different firewalls, > > ouch!)] > > ifconfig should be virtually the same everywhere, so parsing should be > something like this: (works on FreeBSD) > http://segment7.net/ruby-code/snippits/get_ip.rb Great! I have been reading ifconfig's (net-tools's) sources, and apparently that info is taken from /proc/net/ (under Linux at least) and using ioctl, and I guess parsing is more portable than trying ioctl magic... -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com Computers are like air conditioners. Both stop working, if you open windows. -- Adam Heath