IP address

jwinter1

Junior Member
Oct 2, 2000
9
0
0
Is there a way I can find out my IP address on my desktop at home from somewher else? My current situation is that I'm running Apache/PHP/Perl on my DHCP DSL connection. I'm looking for a way that I can find out that server's address remotely. Any ideas?
 

Ladi

Platinum Member
Apr 21, 2000
2,084
0
0
You may want to look into getting a dynamic dns service that will allow you to update a hostname automatically with your IP. Several such services include dyndns.org and dhs.org...much more has been posted about them in Networking, if you want to search...

~Ladi
 

Damaged

Diamond Member
Oct 11, 1999
3,020
0
0
Well, you can easily write a shell script to email you your IP every hour if you wanted. It could look something like this:

----------------------------------------------------------------

#!/bin/sh

PATH=/sbin:/bin:/usr/sbin:/usr/bin

extip=`/sbin/ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | sed -e's/.*://'`

#Print the result of the variable to a file as you can only redirect text into the body of a message with mutt (I'm probably missing something stupid here though).

printf $extip > /home/<your directory>/mydynip

/usr/bin/mutt -s &quot;Your Current IP&quot; <your email addy> < /home/<your directory/mydynip

rm -rf mydynip
----------------------------------------------------------------------

Then just make it a cron job that runs every hour. Make sure you substitue whatever your outside interface is appropriately otherwise you won't get the correct IP.

Also, I used mutt here as it's my preferred MUA. However, you could easily use mailx, Pine, Elm, or even sendmail directly if you're running that. The syntax will differ a bit though.

Finally notice that I've encased the ENTIRE statement after extip= in BACK ticks. Why? Because I want the result of that mess to be assigned to the variable. Make sure the file is executable and you're done.
 

Damaged

Diamond Member
Oct 11, 1999
3,020
0
0
/sbin/ifconfig eth0 | grep 'inet addr' | cut -f2 -d ':' | cut -f1 -d ' '

Use that instead. No need to call up awk and sed for this small operation. Sorry. That's a much system friendlier way to accomplish the same thing as my previous line.
 

pdo

Diamond Member
Feb 9, 2000
3,468
0
76
www.pauldophotography.com
I'm with Ladi on this one. Dynamic DNS is the way to go. Currently I'm using dyndns.org and the clients check for IP changes every 5-10(whatever you set it to) minutes if there's changes then it'll update DNS automatically.
 

jwinter1

Junior Member
Oct 2, 2000
9
0
0
Thanks for the rapid response. I've set up an account with dyndns.org and I have installed yiPost as the little client that updates the DNS settings at dyndns. So far, so good.
thanks again
 

BuckMaster

Diamond Member
Oct 9, 1999
3,260
0
0
What ever that is you have posted Damaged it sure looks cool :) If I had a clue on how to due it I would give it a shot! :D
 

vi edit

Elite Member
Super Moderator
Oct 28, 1999
62,484
8,345
126
&quot;Damaged, how is a shell script entered&quot;

*cough* Ahem *cough*
 

Damaged

Diamond Member
Oct 11, 1999
3,020
0
0
heh. vi_edit is giving you a hint. Though I personally don't use vi or any vi variant (e.g. ViM) any text editor will do. BTW I use jed, which is an emacs variant. Why? Because that's what I was taught. I really should learn to cope with vi though.

Finally make sure you don't forget the magic first line (#!/bin/sh) and make sure that the file is exectuable. BTW I learned to pronounce that first line as sh-bang. :) Have fun! Shell scripting is your easiest way to program, imho.