Click to See Complete Forum and Search --> : How do I figure out my IP address???


cotfessi
01-13-2001, 10:11 PM
I'm running Mandrake v7.2 right now. I was reading through the "How I did it" section here on the forums about getting a true domain name with a dynamic IP(http://www.linuxnewbie.org/ubb/Forum12/HTML/000363.html)

The author explains how to set up an account on www.centralinfo.net (http://www.centralinfo.net) to handle a registered domain name. The last piece of the puzzle is getting neoupdate to update centralinfo.net with your dynamic IP - a perl script that determines the IP and sends it to centralinfo.net

This script gives me a few options to determine my IP. Nothing seems to work! Anyone know how I can determine my IP address using some sort of a Perl script?

this is what I've tried:

#!/usr/bin/perl

use CGI qw( :standard);

print "Content-type: text/html\n\n";
print "$ENV{REMOTE_ADDR}";

and this is what I get back:

Content-type: text/html

help?!?.......

gaxprels
01-13-2001, 10:18 PM
I know that you can execute shell commands through perl, just don't know how. Try using the "netstat" command piped into a script to filter the local ip. Hope this helps. http://www.linuxnewbie.org/ubb/smile.gif

Frymaster
01-13-2001, 10:33 PM
you can run the shell command:

ifconfig -a | grep inet | grep broadcast > /tmp/foo && awk '{print $2}' /tmp/foo && rm -r /tmp/foo

and it should dump yer ip on the screen... not the most efficient way in the world. btw, i wrote that on bsd (os x) so, it may need some tweaking...

Craig McPherson
01-13-2001, 10:37 PM
Just set up your network connection script to dump your IP address to a file, then have the Perl script read in that file.

You can dump your IP to a file like this:

ifconfig INTERFACENAME | grep inet | cut -b 21-36 > /var/tmp/ip.txt

cotfessi
01-14-2001, 12:34 AM
Thanks for all of the suggestions...

I actually found that one of the scripts that I needed to update my IP address was looking to "eth0" for the answer, but I'm on a ADSL line running PPPoE so I needed to point to "ppp0" now it works fine!