LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Getting Dynamic IP (https://www.linuxquestions.org/questions/linux-networking-3/getting-dynamic-ip-240662/)

eponymous 10-09-2004 02:23 PM

Getting Dynamic IP
 
Hi, i have a router which my computer connects to, and if i restart the router the ip adress changes, as my isp gives me a dynamic ip. My computer is running mandrake 10.1 and i was wondering if there is a way to allow my ip adress to be viewed, like, is there a prog that will capture my ip adress and upload it to a txt file in an ftp server or something similar?
thanks.

tuxq 10-09-2004 03:20 PM

Re: Getting Dynamic IP
 
Quote:

Originally posted by eponymous
Hi, i have a router which my computer connects to, and if i restart the router the ip adress changes, as my isp gives me a dynamic ip. My computer is running mandrake 10.1 and i was wondering if there is a way to allow my ip adress to be viewed, like, is there a prog that will capture my ip adress and upload it to a txt file in an ftp server or something similar?
thanks.

Which IP do you mean? Your internal (the one assigned to your computer by your router) or external (the one assigned to you by your ISP)?

I'll answer this like you mean external...

Some routers (d-link, linksys...) offer IP submissing to Dynamic Hosting places such as DynDns.org (which is free) so you can pick from their domains and make a hostname with it.
They have domains like ath.cx, mine.nu ... for example, you could use eponymous.ath.cx or eponymous.mine.nu.

There are some bash scripts, perl scripts, whatever that could be made to do this for you if your router doesn't support this... Or you could just go to www.whatismyip.com

utopicdog 10-09-2004 03:24 PM

you alter the debug level in the config script for the isp conection program, and also tell it where to dump the information - usually its /var/log/something.
however it shouldnt be necessary as your connection program has the option 'dynamic'. if you have ipresend enabled it all sorts itself out itself

gvec 10-09-2004 03:26 PM

i am unclear on why you would want a txt file with your ip located on an ftp server somewhere but if you are just wanting to be able to get to your system from the Internet even if your IP changes i would recommend a free DNS (there are several available). i am currently using no-ip (www.no-ip.com). they have a linux client and a free offering. i use it for the sole purpose of being able to ssh to my box from the Internet. the no-ip client is configurable, you can choose how often it checks to see if your IP has changed and update the free domain name to the new dynamicIP. i have been using the no-ip client for nearly a year now without interruption of service.

if you are looking to have your IP uploaded to an ftp site somewhere i am sure you can write a script that will use a free site that provides your IP (such as whatismyip.com) save the returned page and then read the file for your IP (usually found between <title></title>) which can be grep/awk-ed to another file which is then uploaded to an ftp site (or you can just push the saved html file with your IP to the ftp server) that you can get to from the Internet. once you have a working script you could then add it run however often you wanted. although, i would still recommend a free DNS service if you are wanting your IP so you can connect to/through your router, i dont like to re-invent the wheel anymore than i have to ;) so a free DNS with linux client works just fine for me.

hope this helps...

eponymous 10-09-2004 04:56 PM

thanks guys :)

gvec 10-09-2004 06:08 PM

i became curious about pulling down the IP with a script and then uploading it to an ftp server somewhere
here is what i came up with:
Code:

#!/bin/bash
wget http://whatismyip.com/index.aspx
cat index.aspx | grep TITLE | awk '{print $4}' > currentIP
rm -f index.aspx
ftp << FTPSTRING
prompt off
open yourFTPserver
cd /path/to/where/you/want/file/uploaded
put currentIP
bye
FTPSTRING

NOTE: if used, you may want to use absolute paths. i just ran it manually from /tmp where i wrote it.


for this to work you will need to add the appropriate ftp login credentials to ~/.netrc
you should be able to have multiple lines in ~/.netrc
example:
Code:

default login anonymous password no@email.com
machine yourFTPserver login yourlogin password yourpassword


This was written and tested on SLES9.
I tested it on both an anon and non-anon ftp server with success on each.


All times are GMT -5. The time now is 01:06 PM.