On 1 Oct 2003 11:59:39 -0700, Eduardo <(E-Mail Removed)> wrote:
>
>
> How to find one's own interface IP address for sure? Short of sed'ing,
> awk'ing, etc. the output of 'ifconfig ppp0', can't I just look into
> /proc or somewhere else? Why not? or, How?
> TIA
That perl script seem a little like overkill for the job?
Take a look at /var/log/syslog (or perhaps the appriate log has a somewhat
different name on your distro...I'm running Debian) with a tail -100
and you'll see lines like this towards the end:
Oct 1 14:30:43 xxxxxx pppd[11794]: local IP address 63.xxx.xxx.xxx
Oct 1 14:30:43 xxxxxx pppd[11794]: remote IP address 63.xxx.xxx.xxx
(IP addresses and hostname altered above)
The first address is my present IP on the ppp0 interface and the second is
the present address of my ISP at the other end of the modem connection.
It is a simple matter to grep these out. Just put a function like this
in your .bashrc:
ga () {
grep 'local *IP' /var/log/syslog | tail -1 ;
}
That greps out all the lines with that regex in them, then displays the
last one, which would have your current IP address in it, as well as that
other useful informaion. If you want to get fancy, then:
ga () {
jj=`tail -1 /var/log/syslog | grep i'local *IP | sed -n 's/\(^.*address\
*\) \(.*$\)/\2/p'`
clear;
echo; echo; echo;
echo "Your Current IP Address is : $jj" ;
echo; echo; echo;
}
Now enter source .bashrc, and whenever you want to see your present local
IP, just enter ga.
--
Later, Alan C
You can find my email address at the website: contact.html
take control of your mailbox ----- elrav1 -----
http://tinyurl.com/l55a