Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
Due to network maintenance being performed by our provider, LQ will be down starting at 05:01 AM UTC. The exact duration of the downtime isn't currently known. We apologize for the inconvenience.
|
 |
12-29-2006, 11:38 AM
|
#1
|
|
Member
Registered: Dec 2004
Location: Georgetown, DE
Distribution: Gentoo (Kernel-2.6.18-gentoo-r5, customized :))
Posts: 101
Rep:
|
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
|
|
|
|
12-30-2006, 04:33 AM
|
#2
|
|
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:
|
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.
|
|
|
|
12-30-2006, 05:39 AM
|
#3
|
|
Member
Registered: Aug 2003
Distribution: Debian, Ubuntu
Posts: 188
Rep:
|
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.
|
|
|
|
12-30-2006, 05:46 AM
|
#4
|
|
LQ Newbie
Registered: Jan 2004
Location: South Coast of England
Distribution: Solaris 7,10,11 Suse 9.3,10 WinXP
Posts: 24
Rep:
|
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.
|
|
|
|
12-30-2006, 09:45 AM
|
#5
|
|
Member
Registered: Dec 2004
Location: Georgetown, DE
Distribution: Gentoo (Kernel-2.6.18-gentoo-r5, customized :))
Posts: 101
Original Poster
Rep:
|
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
|
|
|
|
12-30-2006, 03:26 PM
|
#6
|
|
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:
|
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?
|
|
|
|
12-30-2006, 04:36 PM
|
#7
|
|
LQ Newbie
Registered: Jan 2004
Location: South Coast of England
Distribution: Solaris 7,10,11 Suse 9.3,10 WinXP
Posts: 24
Rep:
|
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...
|
|
|
|
12-30-2006, 10:33 PM
|
#8
|
|
Member
Registered: Dec 2004
Location: Georgetown, DE
Distribution: Gentoo (Kernel-2.6.18-gentoo-r5, customized :))
Posts: 101
Original Poster
Rep:
|
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!
|
|
|
|
01-08-2007, 06:36 AM
|
#9
|
|
Member
Registered: Dec 2004
Location: Georgetown, DE
Distribution: Gentoo (Kernel-2.6.18-gentoo-r5, customized :))
Posts: 101
Original Poster
Rep:
|
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?!
|
|
|
|
01-09-2007, 12:34 PM
|
#10
|
|
Senior Member
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
|
You lost track of your threads, you want to be here
.
Yet another reason not to double post.
|
|
|
|
01-09-2007, 07:06 PM
|
#11
|
|
Member
Registered: Dec 2004
Location: Georgetown, DE
Distribution: Gentoo (Kernel-2.6.18-gentoo-r5, customized :))
Posts: 101
Original Poster
Rep:
|
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?
|
|
|
|
01-09-2007, 09:18 PM
|
#12
|
|
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:
|
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.
|
|
|
|
01-10-2007, 06:34 AM
|
#13
|
|
Member
Registered: Dec 2004
Location: Georgetown, DE
Distribution: Gentoo (Kernel-2.6.18-gentoo-r5, customized :))
Posts: 101
Original Poster
Rep:
|
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
|
|
|
|
01-01-2010, 02:03 AM
|
#14
|
|
LQ Newbie
Registered: Dec 2009
Posts: 15
Rep:
|
Quote:
Originally Posted by ojnab
#!/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.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
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 07:21 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|