Koozali.org: home of the SME Server

Obsolete Releases => SME Server 9.x => Topic started by: purzel on June 22, 2015, 07:47:09 PM

Title: custom DynDNS not working? [SOLVED]
Post by: purzel on June 22, 2015, 07:47:09 PM
Hi all!

After hours of "goggle-ing" without success: This is my first post in this forum - hope I'm right here....

While installing SME Server 9 I selected "custom" for DynDNS because my provider (SPDNS.DE) wasn't listed. I entered correct data and proceeded with installation. When the installation was finished, I noticed that it's not working, there was an error message in /var/log/messages:
Can't exec "/sbin/e-smith/dynamic-dns/custom": No such file or directory at /etc/e-smith/events/ipchange/S85update-dns line 52.

OK, I created an own script based on dyndns.org in the same directory, made it executable and tried to run:
/etc/e-smith/events/ipchange/S85update-dns
It worked, my dynamic DNS entry was successful updated. Hooray!

But I was pleased too early. It only works when I run S85update-dns manually. It's neither be run automatically when getting a new IP from my ISP nor when rebooting (!). In /var/log/messages I can read:
Running event handler: /etc/e-smith/events/ipchange/S85update-dns
S85update-dns=action|Event|ip-change|Action|S85update-dns|Start| 14379949 282796|End|14379949 563611|Elapsed|0.280815


Is this an error? It looks for me that the event is triggered and the Perl-Script is executed - but not correctly.

Please help!

Thanks in advance,
Matthias
Title: Re: custom DynDNS not working?
Post by: guest22 on June 22, 2015, 10:25:00 PM
Hi and welcome,

obviously you are encouraged to learn the basics of SME Server and its db and templating system. The manual would be a good start. That would learn you that you can not consider any template fragment (e.g. 10thispart) as a script by itself, but that it is a part of a templating system.

Having said that, the issue you have with 'can't exec "/sbin/e-smith/dynamic-dns/custom" is the one to concentrate on. Maybe you have hit a bug, and if so, it should be reported to the bug tracker.

Thanks,
guest
Title: Re: custom DynDNS not working?
Post by: CharlieBrady on June 23, 2015, 08:13:33 PM
Is this an error? It looks for me that the event is triggered and the Perl-Script is executed - but not correctly.

See what happens if you type:

env - /etc/e-smith/events/ipchange/S85update-dns

Perhaps if you post your custom script somewhere people can spot an error or test it out.
Title: Re: custom DynDNS not working?
Post by: purzel on June 23, 2015, 10:26:14 PM
Hi!

Quote
See what happens if you type:

env - /etc/e-smith/events/ip-change/S85update-dns
Nothing (viewable) happend, but my script worked: I got a nochg reply from the server.

I've UNinstalled ddclient - and it SEEMS to work now, at least when rebooting.
Now I have to wait for a pppoe-"redial" because of forced disconnection from my ISP. This usually happens after 24 hours of connection time.
Maybe ddclient "blocked" the execution of  /etc/e-smith/events/ip-change/S85update-dns in some way?

Here's my custom script (/sbin/e-smith/dynamic-dns/custom) if needed by somebody:
Code: [Select]
#!/bin/sh
# Description: www.spdns.de (free service, german)

#------------------------------------------------------
# spdns.de dynamic DNS update handler / client
#------------------------------------------------------

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

wget -q -O /tmp/dyndns.log \
--user-agent="SPDNS update client for Linux" \
http://$USERID:$PASSWD@update.spdns.de/nic/update?\
hostname=$USERID\&myip=$IPADDR

RESULT=`cat /tmp/dyndns.log`
case "$RESULT" in
        good*)
            logger -t spdns.de "Update at $IPADDR succeeded." ;;
        nochg*)
            logger -t spdns.de "IP Address $IPADDR already in database." ;;
        notfqdn*)
            logger -t spdns.de \
                "$DOMAIN is not a Fully-Qualified Domain Name." ;;
        !yours*)
            logger -t spdns.de "$DOMAIN does not belong to you." ;;
        badauth*)
            logger -t spdns.de "Bad username or password $USERID:$PASSWD." ;;
        abuse*)
            logger -t spdns.de \
            "$DOMAIN is blocked for abuse; contact support@securepoint.de" \
            "to unblock." ;;
        numhost*)
            logger -t spdns.de "Too many or too few hosts found." ;;
        invalidip*)
            logger -t spdns.de "Invalid IP Adress submitted.";;
        *)
            logger -t spdns.de "Unknown response $RESULT. Status was $?";;
esac

exit 0

I will keep you informed...

Title: Re: custom DynDNS not working?
Post by: CharlieBrady on June 23, 2015, 11:39:19 PM
Use of the temporary file is not secure. I'd suggest that you use:

RESULT=$(wget -q -O - ...)

You will also have problems if your username or password contains spaces or metacharacters. Use double quotes around your http://... command argument.

Title: Re: custom DynDNS not working?
Post by: purzel on June 24, 2015, 05:02:18 PM
Use of the temporary file is not secure. I'd suggest that you use:

RESULT=$(wget -q -O - ...)

A good hint, thanks - I will do so.

But then I suggest to do the same in /sbin/e-smith/dynamic-dns/dyndns.org originally supplied by the installation ;-)
... even though ... dyndns.org isn't free of charge anymore :-(

Quote
You will also have problems if your username or password contains spaces or metacharacters. Use double quotes around your http://... command argument.

It's not enough to put "$USERID:$PASSWD" into double quotes like done in /sbin/e-smith/dynamic-dns/dyndns.org?
Title: Re: custom DynDNS not working?
Post by: CharlieBrady on June 24, 2015, 07:16:21 PM
It's not enough to put "$USERID:$PASSWD" into double quotes like done in /sbin/e-smith/dynamic-dns/dyndns.org?

That would be equivalent.
Title: Re: custom DynDNS not working?
Post by: purzel on June 25, 2015, 06:38:57 AM
Quote
Now I have to wait for a pppoe-"redial" because of forced disconnection from my ISP. This usually happens after 24 hours of connection time.
It worked yesterday evening.
Now I have double quotes around my variables and no temporary file anymore. Let's see if it remains working...
Title: Re: custom DynDNS not working? [SOLVED]
Post by: purzel on June 26, 2015, 05:13:57 PM
It works. The devil may know what was wrong.

The updated version of my script:

Code: [Select]
#!/bin/sh
# Description: www.spdns.de (free service)

#------------------------------------------------------------
# spdns.de dynamic DNS update handler.
#------------------------------------------------------------

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

RESULT=$(wget -q -O /tmp/dyndns.log \
--user-agent="SPDNS update client for Linux" \
http://"$USERID:$PASSWD"@update.spdns.de/nic/update?\
hostname="$USERID"\&myip="$IPADDR")

case "$RESULT" in
        good*)
            logger -t spdns.de "Update at $IPADDR succeeded." ;;
        nochg*)
            logger -t spdns.de "IP Address $IPADDR already in database." ;;
        notfqdn*)
            logger -t spdns.de \
                "$DOMAIN is not a Fully-Qualified Domain Name." ;;
        !yours*)
            logger -t spdns.de "$DOMAIN does not belong to you." ;;
        badauth*)
            logger -t spdns.de "Bad username or password $USERID:$PASSWD." ;;
        abuse*)
            logger -t spdns.de \
            "$DOMAIN is blocked for abuse; contact support@securepoint.de" \
            "to unblock." ;;
        numhost*)
            logger -t spdns.de "Too many or too few hosts found." ;;
        invalidip*)
            logger -t spdns.de "Invalid IP Adress submitted.";;
        *)
            logger -t spdns.de "Unknown response $RESULT. Status was $?";;
esac

exit 0
Title: Re: custom DynDNS not working? [SOLVED]
Post by: Stefano on June 26, 2015, 05:21:37 PM
please, create an account in bugzilla and post there your code and as much details as you can give about this provider, creating a NFR.. in this way maybe we can add this provider to the available list

thank you in advance