Koozali.org: home of the SME Server

DynDns - Keeping it up to date

Anonymous

DynDns - Keeping it up to date
« on: April 28, 2004, 12:38:10 PM »
Ok with SME ships an option to update DynDns. This is used when your isp is assigning you a dynamic ip address, and you want to have a 'static' domain name tied to it to enable running of servers etc. It seems that this script is run at server startup and it all seems to work fine. My question is this;

Is there some util I can install on teh SME server that will detect if my connection to the internet fails, and if it does, then when it comes back up will contact dyndns and update my dynamic dns name?

As I'm sure you can appreciate, my external ADSL modem disconnects more often than I intend to restart the server!

Any ideas will be gratefully received! :)

Thanks,

Phil

PhilV

DynDns - Keeping it up to date
« Reply #1 on: April 28, 2004, 05:47:13 PM »
Sorry, 'twas me that posted the start of this thread, didn't realise I wasn't logged in tho!

Phil

Offline raem

  • *
  • 3,972
  • +4/-0
Re: DynDns - Keeping it up to date
« Reply #2 on: April 28, 2004, 08:56:18 PM »
Dear Phil

As I understand it the DynDNS feature is applicable to accounts and domains hosted at www.dyndns.org.
If you have a Dynamic DNS setup there, then your sme server will update the IP each time your server reconnects (not just at startup) and you get a new IP from your regular ISP (the IP then gets changed automatically at dyndns.org site).

As far as I know it should be doing what you want it to, but only for the Primary domain hosted on the sme server.

Regs
Ray
...

Offline azche24

  • *
  • 163
  • +0/-0
    • http://az-law.de
DynDns - Keeping it up to date
« Reply #3 on: April 28, 2004, 09:28:54 PM »
Hi there,

you can configure e-smith to use almost every dynamic dns-service. For instance i am using a german provider called dnsteam (www.dnsteam.de)

I changes the dyndns.org script in /sbin/e-smith/dynamic-dns to look like this:

#!/bin/sh
# DNS-Update @ DNSTEAM

#------------------------------------------------------------
# Custom dynamic DNS update handler.
#------------------------------------------------------------

IPADDR=$1
USERID=$2
PASSWD=$3
DOMAIN=$4

#------------------------------------------------------------
# Your handler starts here.
#------------------------------------------------------------

lynx -cookies -source- "http://dnsteam.de/dyndnsupdate.php?login=$USERID&password=$PASSWD&domain=$DOMAIN" -dump
#------------------------------------------------------------
# Your handler ends here.
#------------------------------------------------------------

exit 0

Then i fill in the proper codes in configuration menu (account name, password) and select dyndns.org as my dynamic-dns service.

A reboot and every time the IP changes, the e-smith will send a request and actualize the primary domain-account at my dns provider.

Sometimes you have to fumble with the codes. You can also put them in in clear text:

lynx -cookies -source -dump "http://dnsteam.de/dyndnsupdate.php?login=$YOURLOGIN&password=$YOURPASSWORD&domain=$DOMAIN"

Just ask your Provider, how the account must be updated. Have Fun   :-)

Alex
Alexander Ziemann, Berlin - DE

PhilV

DynDns - Keeping it up to date
« Reply #4 on: April 29, 2004, 12:45:23 AM »
Yes, I am with DynDns.org, and the server does seem to update it correctly on a reboot. I don't think it does it on a disconnect / reconnect situation tho. I am using an external modem, would this affect it. How does SME know when a disconnect / reconnect has taken place? Does it monitor the external IP address for changes?

Thanks,

Phil

Offline crazybob

  • *****
  • 894
  • +0/-0
    • Stalzer R&D
DynDns - Keeping it up to date
« Reply #5 on: April 29, 2004, 06:37:54 AM »
I was running into a sililar problem with dyndns.org not getting properly updated. I found the following in the forums last year.

a) Set your dyndns server to dyndns.org in the config and enter your username and password etc. (I assume you have already done this).

b) Log in as root and "cd /sbin/e-smith/dynamic-dns"

c) backup your dyndns.org script "cp -p dyndns.org dyndns.org.bak"

d) edit the dyndns.org script, replace the $DOMAIN in the wget command with your domain name (ie. diatechnik.dyndns.org).

e) save and exit the editing program) restart networking "service network restart"

f) Check the system log to see if your update succeeded. One other thing, make sure you have set diatechnik.dyndns.org as a virtual domain or your machine will not accept any traffic for it.

This does work. I have it on 4 or 5 servers

bob
If you think you know whats going on, you obviously have no idea whats going on!

PhilV

DynDns - Keeping it up to date
« Reply #6 on: April 29, 2004, 12:18:29 PM »
Cheers BOB!

PhilV

DynDns - Keeping it up to date
« Reply #7 on: April 30, 2004, 08:43:12 PM »
My problem is not that dyndns.org isn't being updated at server boot, becasue it is.

My problem is that it isn't being updated afer a modem disconnect / reconnect operation. I don't know how the dyndns script is working, is something supposed to detect the disconnect/reconnect and then run the script?

Is there a utility I can use to do this if the native one doesn't do it?

Offline crazybob

  • *****
  • 894
  • +0/-0
    • Stalzer R&D
DynDns - Keeping it up to date
« Reply #8 on: May 01, 2004, 04:40:48 AM »
Phillv,

The patch I gave you sould do what you are looking for. I am using it on servers that chaange ip's for what ever reason, and it does keep track and update dyndns.

Good luck

Bob
If you think you know whats going on, you obviously have no idea whats going on!

PhilV

DynDns - Keeping it up to date
« Reply #9 on: May 04, 2004, 02:32:48 PM »
Doesn't seem to work for me BOB.

Whether I make that change or not, my dyndns.org name IS correctly updated to my new IP address at boot up.

However once the server is up and running, if my modem disconnects and reconnects, either the server isn't noticing that it's external ip has changed, or else it is noticing but failing to update dyndns with the new ip.

How can I check if it is trying to contact dyndns or not after an external IP change?

Phil

bobk

DynDns - Keeping it up to date
« Reply #10 on: May 05, 2004, 01:35:11 AM »
PhilV,

The problem you are having is most likely because the script 'refresh-ddns' only runs at boot-time and then weekly after that. Try moving it from  /etc/cron.weekly to /etc/cron.hourly. Then the longest your IP will be out of snyc will be an hour instead of a week.

You could also try using DDCLIENT

PhilV

DynDns - Keeping it up to date
« Reply #11 on: May 05, 2004, 07:23:46 PM »
Thx bobk,

Will look into it when i get home, (cause i can't ssh to it from work, cos the bloomin' ip has changed again!)

I will have a go at moving the script, and I will look into this DDCLIENT.

Many thanks,

Phil

PhilV

DynDns - Keeping it up to date
« Reply #12 on: May 05, 2004, 08:30:30 PM »
My only worry with this is that if my IP hasn't changed when the script tries to update it.

I believe dyndns.org will BLOCK the dynamic name, if too many updates are recieved without the IP address changing. Does the script, (or DDCLIENT), actually check your current external IP address against the one that it reported to dyndns last to see if they are different before issuing an update?

Thx,

Phil

Offline genzil

  • ***
  • 51
  • +0/-0
    • http://www.tuxx.org.uk
DynDns - Keeping it up to date
« Reply #13 on: May 06, 2004, 12:49:54 AM »
PhilV, you can try the folllowing.

Change to a directory of your chosing.
Open a new file. ie vi update.sh
Enter in the following code (change words that start with a % to your values)
Code: [Select]
#!/bin/bash

curr_ip=wget -q -O- http://www.whatismyip.com/ | grep "Your IP is " - | cut -d" " -f4

old_ip=cat ip.tmp

logger -t dyndns.org "Stored IP : $old_ip"
logger -t dyndns.org "Current IP: $curr_ip"

if [ "$old_ip" = "$curr_ip" ]; then
logger -t dyndns.org "Action: no update"
else
logger -t dyndns.org  "Action: update"
/sbin/e-smith/dynamic-dns/dyndns.org $curr_ip %username %password %domain
echo $curr_ip > ip.tmp
logger -t dyndns.org  "Status: updated"
fi


Make the file executable: chmod 700 update.sh
Add a line to the cron to run at intervals. I would suggest that you run it no frequent that every 15 minutes or you may find your self blocked from that server.

At your chosen interval it will get the ip address of your modem, compare this against a stored value and if they are the same do nothing, if they are not the same it will update.

The script needs to be run as root to access the /sbin/e-smith/dynamic-dns/dyndns.org program, if you want to update more than one domain (such as I do) then you just create a new line fore each domain.  Make sure that only root or your yourself can read the file as it stores your password in plain text!

If want further help then shout and I'll see what I can do, but please read the documentation on editing files and the crontab before asking me about them. Just a warning that unless you already have a file called ip.tmp it will give an error the first time is run (cat: ip.tmp: No such file or directory), ignore this.

Disclaimer: I have not fully tested this but I believe it should work. Don't blame me if it breaks some thing.
Smile :-)......

bobk

DynDns - Keeping it up to date
« Reply #14 on: May 06, 2004, 01:16:26 AM »
Quote from: "PhilV"
My only worry with this is that if my IP hasn't changed when the script tries to update it.

I believe dyndns.org will BLOCK the dynamic name, if too many updates are recieved without the IP address changing. Does the script, (or DDCLIENT), actually check your current external IP address against the one that it reported to dyndns last to see if they are different before issuing an update?

Thx,

Phil


DDCLIENT has several configurable ways to check for IP changes, including from a website as mentioned by genzil in the post above. Down load the latest 'ddclient.tar.gz' file. Unpack it and look at through the README and comments in the sample scripts. It shouldn't take you long to figure out how you want it to work with your system.

Then down load the latest RPM. Install it, and edit the files to suite your system.

Anonymous

DynDns - Keeping it up to date
« Reply #15 on: May 07, 2004, 10:23:46 PM »
Quote from: "genzil"
PhilV, you can try the folllowing.

Change to a directory of your chosing.
Open a new file. ie vi update.sh
Enter in the following code (change words that start with a % to your values)
Code: [Select]
#!/bin/bash

curr_ip=wget -q -O- http://www.whatismyip.com/ | grep "Your IP is " - | cut -d" " -f4

old_ip=cat ip.tmp

logger -t dyndns.org "Stored IP : $old_ip"
logger -t dyndns.org "Current IP: $curr_ip"

if [ "$old_ip" = "$curr_ip" ]; then
logger -t dyndns.org "Action: no update"
else
logger -t dyndns.org  "Action: update"
/sbin/e-smith/dynamic-dns/dyndns.org $curr_ip %username %password %domain
echo $curr_ip > ip.tmp
logger -t dyndns.org  "Status: updated"
fi



Hmm, had a go at this, but at the point where we are trying to get curr_ip and old_ip, rather than execute the instructions in the single quotes, it seems to just place that text into the variable. i.e.

$old_ip ends up containing:

cat ip.tmp

I can tell this by looking in my /var/log/messages

Any ideas how to fix this?

Thx,

Phil

PhilV

DynDns - Keeping it up to date
« Reply #16 on: May 08, 2004, 12:59:19 AM »
I'm not sure what is happening here!

I have made a test file, with just a few lines in it:
(I have put some basic text into a file called ip.tmp just for testing purposes)

Code: [Select]
#!/bin/sh
#file called mytest
BOB='cat ip.tmp'
$BOB
logger -t dyndns.org "TRIAL: $BOB"


If at the terminal i type:
Code: [Select]
# ./mytest

I get a response at the command line of:

Code: [Select]
This is the contents of the ip.tmp file

But in my /var/log/messages file I get:

Code: [Select]
dyndns.org: TRIAL: cat ip.tmp

Any ideas?

PhilV

DynDns - Keeping it up to date
« Reply #17 on: May 08, 2004, 01:08:56 AM »
ARGHHH!!!

Now I see the problem!

Have to be VERY careful to make sure I use  not '

Oh well, now to try again!

Offline nigeltodd

  • ****
  • 82
  • +0/-0
    • http://nigelt.dyndns.org
DynDNS & DDCLient
« Reply #18 on: May 10, 2004, 02:49:48 PM »
DDClient will also letu use the NIC interface to ur cable or dsl modem. That way if the link fails, it will reset every time! however, I also have a problem getting DDCLient to work properly for a virtual domain. ANy ideas?
smoke-free since June 24th, 2004............