LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 12-29-2006, 11:38 AM   #1
shortname
Member
 
Registered: Dec 2004
Location: Georgetown, DE
Distribution: Gentoo (Kernel-2.6.18-gentoo-r5, customized :))
Posts: 101

Rep: Reputation: 15
Alternative to Dynamic DNS?


In the past I have had a lot of trouble with DDNS services and client software (both provided by my linksys router and through ddclient). I was thinking the easiest solution would be to simply have the computer I need to work on e-mail me its IP address every so often. Is there a small program or script that does this? Better yet, is there one that would e-mail me only when the IP address changes?

Another benefit (as I see it) of this approach would be that this machine wouldn't be sitting on the web quite so wide open as it would with a DDNS address. I am the only one that needs access to this machine remotely anyway.

Thanks much,

Jeremy
 
Old 12-30-2006, 04:33 AM   #2
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 69
The only ways for a machine behind NAT to know it's external IP are to a) contact an external site that will respond with the IP that it receieved the connection from and parse that output or b) connect to the admin interface of the NAT device and download the page that contains the WAN IP address, then parse the output.

I used wget to do the latter at one point by sending the authentication headers to my Linksys firewall and downloading the status page that contained the WAN IP address. More recently I wrote a script to SSH to connect to one of my machines that has a static IP address and use a false username to attempt login. This causes an error message in my authlog with the IP address that attempted the connection (so I know what IP the remote host is coming from).

If you're able to use DDNS I would do it. Just because you have a DNS name associated with your IP doesn't make it any more likely to be attacked than it already is. Most attack scanners just go for ranges of IP addresses know to belong to certain ISPs any way, so not having a DNS record wouldn't make any difference. It's a lot more convenient to be able to do the name-to-IP resolution via DNS than always needing to have access to wherever the IP reports are being sent to.
 
Old 12-30-2006, 05:39 AM   #3
Clemente
Member
 
Registered: Aug 2003
Distribution: Debian, Ubuntu
Posts: 188

Rep: Reputation: 30
Post

Hi,
Quote:
More recently I wrote a script to SSH to connect to one of my machines that has a static IP address and use a false username to attempt login. This causes an error message in my authlog with the IP address that attempted the connection (so I know what IP the remote host is coming from).
Similar strategy, but easier (IMHO) and without "breaking attempt" would be to write a little php or perl script (should be less than 10 lines) that checks a given secret and mails the ip adress if positive. Something like:
PHP Code:
if ($_REQUEST['secrettocheck'] == "youmaypass") {
    
mail "my@email.org""ip address"$_SERVER['REMOTE_ADDR']);

Code may be incorrect, writing unchecked
Adding the functionality to mail only if the address really changed should be easy. Your home server can access this site with "links -dump url/to/your/script.php. If your script gives some html output, you can do exit code checking.
Greets,
Clemente

Last edited by Clemente; 12-30-2006 at 05:41 AM.
 
Old 12-30-2006, 05:46 AM   #4
ojnab
LQ Newbie
 
Registered: Jan 2004
Location: South Coast of England
Distribution: Solaris 7,10,11 Suse 9.3,10 WinXP
Posts: 24

Rep: Reputation: 15
I concur with chort

Its a real pain writing scripts to do this for you as you need an external machine to be able to know your public IP address.

I had to resort to scripts to find my DHCP provided VPN address at work. I setup a special username on my office desktop SunBlade-1000 which anyone could rsh to, but the login shell was replaced with a script which did a who am i to get the ip address and then editted my hosts file with another setuid script. This didn't interfere with the IT depts DNS, and allowed me to rsh from my office SunBlade-1000 to my home Ultra-10. Until I got the error handling right I'd occasionally trash my /etc/hosts file.

In a nutshell, if you've got access to DDNS, use it.
 
Old 12-30-2006, 09:45 AM   #5
shortname
Member
 
Registered: Dec 2004
Location: Georgetown, DE
Distribution: Gentoo (Kernel-2.6.18-gentoo-r5, customized :))
Posts: 101

Original Poster
Rep: Reputation: 15
Thank you all very much for your suggestions, but I have tried DDNS from dyndns.org as provided by two dfferent linksys routers in two different states (same model BEFSR41), ddclient set up under OpenSuSe 10.2, Gentoo 2006.1 and 2006.0, etc...with no luck! Perhaps there is some secret to setting it up properly? It just seems very finicky. As soon as I think I have it working, I go somewhere (perhaps only 40 miles, but an inconvenient distance no less) and it fails to update my IP address and I have no access to my machine. I was thinking it would at least be nice to have a dead simple script that mailed me the IP address every five minutes or so (so if I was locked out by DDNS I could log in and try and guess what the problem might be.

I don't know Perl or PHP and I have only a cursory knowledge of bash shellscripting, but I was thinking something along the lines of:

#!/bin/bash
5 * * * * wget checkip.dyndns.org (I can get my IP address from this page very easily) \
&& sendmail index.html my@mail.com (Can I use sendmail to send attachments? I've never used it before)

Sorry about the formatting. So basically I could just have a cron job that did this every x times (in this case every five minutes: perhaps a bit excessive)

Could anyone help me with a basic script like that?

Have any of you used ddclient? If so, how did you get it (and keep it) working? Perhaps I am missing something obvious. Is there a good way to get detailed debug output from a program like this? Perhaps something simple is wrong with the way I have set up /etc/ddclient.conf

Oh, and thanks for pointing out that DDNS is no security threat, I don't know a whole lot about networking, so I assumed having a DDNS name made a machine that much easier to find.

Thanks,

Jeremy
 
Old 12-30-2006, 03:26 PM   #6
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 69
I used DynDNS.org before and one of the automatic update scripts (it may have been ddclient, I don't remember). There wasn't any special "trick". I just followed the instructions in the installation documentation and it worked as described. Are you sure that you've read all the documentation that came with the software?
 
Old 12-30-2006, 04:36 PM   #7
ojnab
LQ Newbie
 
Registered: Jan 2004
Location: South Coast of England
Distribution: Solaris 7,10,11 Suse 9.3,10 WinXP
Posts: 24

Rep: Reputation: 15
A simple script

#!/bin/bash

wget -O ~/newip checkip.dyndns.org

cmp ~/newip ~/oldip >/dev/null || {
mv ~/newip ~/oldip
mailx -s "My IP changed" you@domain.com < ~/oldip
}

Then before you run it for the first time run

touch ~/oldip

Then set it to run as frequently as you like in your crontab. It will email you the output from wget whenever it changes (its not refined so it will email even if the format of the output changes not just the IP address).

Enjoy...
 
Old 12-30-2006, 10:33 PM   #8
shortname
Member
 
Registered: Dec 2004
Location: Georgetown, DE
Distribution: Gentoo (Kernel-2.6.18-gentoo-r5, customized :))
Posts: 101

Original Poster
Rep: Reputation: 15
Wow, thanks ojnab. I'll have to give that a shot. I've got to wait until I get an actual person to e-mail me the IP of the machine that needs this script though. :-/ This will save me loads of trouble once I get it going. Thanks!
 
Old 01-08-2007, 06:36 AM   #9
shortname
Member
 
Registered: Dec 2004
Location: Georgetown, DE
Distribution: Gentoo (Kernel-2.6.18-gentoo-r5, customized :))
Posts: 101

Original Poster
Rep: Reputation: 15
Wow. Is it possible for posts to be deleted? I could swear that a few of you guys were helping me find info on learning to shellscript yesterday, and I recall there being a few posts about efficient ways to find shellscripts in /etc/, and now they're gone! What's happened?!
 
Old 01-09-2007, 12:34 PM   #10
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 230Reputation: 230Reputation: 230
You lost track of your threads, you want to be here
.

Yet another reason not to double post.
 
Old 01-09-2007, 07:06 PM   #11
shortname
Member
 
Registered: Dec 2004
Location: Georgetown, DE
Distribution: Gentoo (Kernel-2.6.18-gentoo-r5, customized :))
Posts: 101

Original Poster
Rep: Reputation: 15
That's bizarre. I have no recollection of starting another thread by that name. I thought that thread was part of this one...Could a mod have done this?
 
Old 01-09-2007, 09:18 PM   #12
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 69
Quote:
Originally Posted by shortname
That's bizarre. I have no recollection of starting another thread by that name. I thought that thread was part of this one...Could a mod have done this?
Yes. New topic = new thread.
 
Old 01-10-2007, 06:34 AM   #13
shortname
Member
 
Registered: Dec 2004
Location: Georgetown, DE
Distribution: Gentoo (Kernel-2.6.18-gentoo-r5, customized :))
Posts: 101

Original Poster
Rep: Reputation: 15
Oh, ok then. It really was stupid of me to double post and then change topics. That has made things just as confusing for me as for everyone else!

Thanks,
Jeremy
 
Old 01-01-2010, 02:03 AM   #14
tontoOz
LQ Newbie
 
Registered: Dec 2009
Posts: 15

Rep: Reputation: 0
Quote:
Originally Posted by ojnab View Post
#!/bin/bash

wget -O ~/newip checkip.dyndns.org

cmp ~/newip ~/oldip >/dev/null || {
mv ~/newip ~/oldip
mailx -s "My IP changed" you@domain.com < ~/oldip
}

Then before you run it for the first time run

touch ~/oldip
I was going to suggest doing a 'ping -r 1 us.cnn.com' (or website of your choice) and then extracting the WAN IP address from the ping results, but the above looks quite elegant.

Last edited by tontoOz; 01-01-2010 at 03:05 AM.
 
Old 08-21-2013, 05:44 AM   #15
docesam
LQ Newbie
 
Registered: Jun 2003
Posts: 14

Rep: Reputation: 1
Red face here is a c# code that works 100%

i made a c# application that do just that ,source code attached below (please remove the trailing .txt from the file name) unzip the file and open the project. edit the function "SentTheEmail" to reflect your credential.
done
Attached Files
File Type: txt SendIP2.zip.txt (33.0 KB, 13 views)
 
  


Reply

Tags
ddns, dns, dynamic


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to dynamic DNS bondoq Linux - Networking 2 11-13-2006 07:58 AM
Dynamic IP - DNS? Terra Niux Linux - Newbie 9 12-06-2004 01:39 PM
Dynamic DNS sporkit Linux - Networking 3 04-28-2004 08:07 AM
Dynamic DNS pyfsapple Linux - Networking 7 05-08-2003 08:05 PM
dynamic DNS linowes Linux - Networking 8 02-21-2003 03:16 AM


All times are GMT -5. The time now is 10:09 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration