Koozali.org: home of the SME Server

Poll

Did you find this topic intersting?

Yes
1 (100%)
No
0 (0%)

Total Members Voted: 1

Voting closed: October 19, 2006, 11:39:15 PM

DynDNS: SME 7.0 with 2 domains behind a Firewall/Router

Offline elorenz

  • ***
  • 41
  • +0/-0
DynDNS: SME 7.0 with 2 domains behind a Firewall/Router
« on: September 19, 2006, 11:39:15 PM »
Hi all,
I have an SME 7.0 (server only) behind a Firewall/Router. I have two domains on this server and use zoneedit as my DynDNS service because I use private domain names.
The update-dns action script can't handle this situation as it won't know what the external IP address is.
I have rewriten the update-dns action script as follows:
Code: [Select]

#!/usr/bin/perl -w

#----------------------------------------------------------------------
# copyright (C) 1999-2005 Mitel Networks Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
#
# Technical support for this program is available from Mitel Networks
# Please visit our web site www.mitel.com/sme/ for details.
#----------------------------------------------------------------------

package esmith;

use strict;
use Errno;
use esmith::ConfigDB;

my $c = esmith::ConfigDB->open_ro or die "Couldn't open config db";

#------------------------------------------------------------
# If using Dynamic DNS service, notify them of new IP address.
#------------------------------------------------------------

my $event = $ARGV [0];

my $DynDNS = $c->get('DynDNS');
exit 0 unless $DynDNS;

my $status = $DynDNS->prop('status') || "disabled";
my $service  = $DynDNS->prop('Service') || 'off';
my $account  = $DynDNS->prop('Account');
my $password  = $DynDNS->prop('Password');

my $domain  = $c->get('DomainName')->value;

exit 0 unless ($status eq "enabled" && $service ne "off");

# my $ipaddress = $c->get('ExternalIP') or die "Can't get External IP address";
# The previuos line was replaced for the following
# to accomodate for the use of DynDNS on a server-only setup with external
# gateway to the Internet.
# Author: Ernesto Lorenz
# Date: 17/09/2006

my @result = split /:/ , `lynx --dump http://checkip.dyndns.org`;
my $ipaddress = $result[1];

exec ("/sbin/e-smith/dynamic-dns/$service", $ipaddress, $account, $password, $domain);


Is this code interesting to the comunity? If so, where do I post this for it's inclusion in the next SME release?
Regards,

Ernesto Lorenz
............

Offline raem

  • *
  • 3,972
  • +4/-0
Re: DynDNS: SME 7.0 with 2 domains behind a Firewall/Router
« Reply #1 on: September 20, 2006, 12:57:28 AM »
elorenz

> where do I post this for it's inclusion in the next SME release?


I would say the bugtracker is the place.
Either create a bug for sme7 or sme7 Future ie NFR (New Feature Request), and attach your code. The developers will jump in if it is of interest to them, which it likely will be. After all, they are "code junkies".

You may also be told that you are approaching this the wrong way & adding unnecessary complexity. It could be said that it's better to just configure your server using say an existing supported dyndns service/domain and point your real domains to the dyndns domain (CName entries).
That way only one dynamic DNS service needs to be updated.
...

Offline imcintyre

  • *
  • 609
  • +0/-0
DynDNS: SME 7.0 with 2 domains behind a Firewall/Router
« Reply #2 on: September 27, 2006, 03:47:03 AM »
Ernesto;

I think I private mailed you about this script but they have turned off the private mail and I cannot retrieve your message. I read it once but could not do anything with it at the time.

Anyways. I am trying to run SME 7 as server and firewall and also trying to use zone edit. My knowledge of scripts approaches zero but I am trying to solve my problem and learn.

How can I use your script with my problem.

Thx in advance for your help.

Ian

Offline elorenz

  • ***
  • 41
  • +0/-0
DynDNS: SME 7.0 with 2 domains behind a Firewall/Router
« Reply #3 on: October 16, 2006, 10:30:36 PM »
Ian,

In your case it´s much simpler. You need to go to the configuration console via
Code: [Select]
/sbin/e-smith/console
Make shure you select the custom DynDNS option.
Next you need to create a script file named custom in /sbin/e-smith/dynamic-dns with the following content:
Code: [Select]

#!/bin/sh
# Description: Put your description here

#------------------------------------------------------------
# ZoneEdit dynamic DNS update handler.
#------------------------------------------------------------


#IPADDR=`lynx --dump http://checkip.dyndns.org | awk '{print $4}'`
#This was moved to the action: update-dns on 17/09/2006 by E.Lorenz

IPADDR=$1
USERID=$2
PASSWD=$3
DOMAIN=$4
logfile=/tmp/dyndns.log

# This script will set your zone root and a wildcard A-record.
# Thus, if your domain is mydomain.org, www.mydomain.org
# will resolve as well.


wget -O $logfile \
--http-user="$USERID" \
--http-passwd="$PASSWD" \
http://dynamic.zoneedit.com/auth/dynamic.html?host="$DOMAIN",*."$DOMAIN"&dnsto="$IPADDR"


RESULT=`cat $logfile`

case "$RESULT" in
        *200*)
            logger -t zoneedit.com "Update succeeded. Domain=$DOMAIN" ;;
        *201*)
            logger -t zoneedit.com "No records need updating. Domain=$DOMAIN" ;;
        *701*)
            logger -t zoneedit.com "DOMAIN is not set up in this account. Domain=$DOMAIN" ;;
        *702*)
            logger -t zoneedit.com "Update failed. Domain=$DOMAIN" ;;
        *703*)
            logger -t zoneedit.com "One of either parameters 'DOMAINs' or 'host' are required." ;;
        *704*)
            logger -t zoneedit.com "DOMAIN must be a valid 'dotted' internet name. Domain=$DOMAIN" ;;
        *705*)
            logger -t zoneedit.com "DOMAIN cannot be empty. Domain=$DOMAIN" ;;
        *706*)
            logger -t zoneedit.com "Too frequent updates for the same host, adjust client settings. Domain=$DOMAIN" ;;
        *707*)
            logger -t zoneedit.com "Duplicate updates for the same host/ip, adjust client settings. Domain=$DOMAIN" ;;
        *)
            logger -t zoneedit.com "Unknown response $RESULT. Status was $?";;
esac



exit 0

Thi should be all that´s needed in your case.
I´m still trying to work out a solution for multiple hosts - domain-names.
I hope this helps.
Regards,
Ernesto
............

Offline imcintyre

  • *
  • 609
  • +0/-0
DynDNS: SME 7.0 with 2 domains behind a Firewall/Router
« Reply #4 on: October 19, 2006, 10:41:08 PM »
elorenzo;

I logged in as root and configured the custom option on the console. I think I had done that before.

Again, still logged in as root, I typed the /sbin/e-smith/dynamic-dns and I got the reply;
-bash: /sbin/e-smith/dynamic-dns: is a directory

This does not seem right. I suppose I have to create the script file and import it using Filezilla into the directory. Forgive my total ignorance but how do I create a script file, or could you put me in touch with a resource?

Thx in advance

Offline imcintyre

  • *
  • 609
  • +0/-0
DynDNS: SME 7.0 with 2 domains behind a Firewall/Router
« Reply #5 on: October 19, 2006, 10:42:13 PM »
elorenz;
forgive my spelling
Ian

Offline elorenz

  • ***
  • 41
  • +0/-0
DynDNS: SME 7.0 with 2 domains behind a Firewall/Router
« Reply #6 on: October 20, 2006, 12:08:40 AM »
Hi Ian,
Plese excuse me, I didn't realize you're a Linux novice.
What I would like to suggest is you use putty on a Windows PC to log in to your SME box; this way you can take advantage of the copy-paste functionality in Windows.
If you need instructions on how to get putty and how to use it on your Windows PC let me know.
Once you're there I can walk you through the steps necesary to get DynDNS working for zoneedit.
Regards,
Ernesto
............

Offline imcintyre

  • *
  • 609
  • +0/-0
DynDNS: SME 7.0 with 2 domains behind a Firewall/Router
« Reply #7 on: October 20, 2006, 04:12:16 PM »
I have putty and can log on as either root or admin and I can use filezilla to put files into sme. I have already loaded the cron function to sme using filezilla. I will have to confess my total linux ingnorance. If you could help it would be appreciated.

Also if you can suggest a good linux book for reference. The concepts are ok it is the syntax which I have not seen a good reference.

Offline elorenz

  • ***
  • 41
  • +0/-0
DynDNS: SME 7.0 with 2 domains behind a Firewall/Router
« Reply #8 on: October 20, 2006, 06:03:45 PM »
No problem Ian,

What you have to do is create a file named coustom on your PC and place the shell script code in my previous post into this file.
You then use Filezilla to move this file from your PC to the SME box under the following directory: /sbin/e-smith/dynamic-dns/
If you configured the DynDNS fucntion correctly with the console all should work fine.
From the command line you can run /etc/e-smith/events/actions/update-dns
The corresponding transaction log file will be placed under /tmp and is namesd dyndns.log

Let me know if this worked as explained.
Regards,
Ernesto
............

Offline imcintyre

  • *
  • 609
  • +0/-0
DynDNS: SME 7.0 with 2 domains behind a Firewall/Router
« Reply #9 on: October 20, 2006, 06:28:52 PM »
Ernesto;

When I create the file, should I use a text editor? What should the file type be?

I am at work now, I will try on the weekend and let you know.

Thx

Ian

Offline elorenz

  • ***
  • 41
  • +0/-0
DynDNS: SME 7.0 with 2 domains behind a Firewall/Router
« Reply #10 on: October 20, 2006, 06:48:33 PM »
Ian,
You can use any text editor of your choice (e.g. Wordpad).
You must not give the file a type, it should be named only "custom" or wahtever the service name is:
Log in as root with putty and execut this comand:
config show DynDNS
You should get something like this back:

DynDNS=service
    Account=YYYYY
    Password=xxxxxx
    Service=zoneedit
    status=enabled

The file name should be the same as the Service=??????

I wish you luck.

Ernesto

[/code]
............

Offline imcintyre

  • *
  • 609
  • +0/-0
DynDNS: SME 7.0 with 2 domains behind a Firewall/Router
« Reply #11 on: October 21, 2006, 09:27:06 PM »
Ernesto;

I am having a problem when it comes to using Filezilla to copy in the file I created.

When I log in as admin using the correct password and port 21, I cannot find the folder /sbin/e-smith.dynamic-dns/

If I try and log in as the root and use the same password as the admin, it won't log me in using port 21.  If I use port 22 it appears as though I get in but I cannot see the directory tree.

What gives?

Thx in advance for your help.

Ian

Offline elorenz

  • ***
  • 41
  • +0/-0
DynDNS: SME 7.0 with 2 domains behind a Firewall/Router
« Reply #12 on: October 21, 2006, 09:55:25 PM »
Ian,
To log in as root on port 22 (SSH) -- you shuoldn't use port 21 -- you first need to enable this via the server-manager web interface, under remote access, and then Secure Shell Settings: "allow public access" or "allow access only from local network" whichever your case is.
after this is taken care of you can use Filezilla to log in as root and navigate the file structure.

Good luck,

Ernesto
............

Offline imcintyre

  • *
  • 609
  • +0/-0
DynDNS: SME 7.0 with 2 domains behind a Firewall/Router
« Reply #13 on: October 22, 2006, 05:55:58 AM »
Ernesto;

This is what I had all along so it should work. Do you see anything wrong with this?

Secure Shell Settings
You can control Secure Shell access to your server. The public setting should only be enabled by experienced administrators for remote problem diagnosis and resolution. We recommend leaving this parameter set to "No Access" unless you have a specific reason to do otherwise.
Secure shell access    Allow over local network
Allow administrative command line access over secure shell    yes
Allow secure shell access using standard passwords    yes

FTP Settings
FTP Access Allow access from local networks

FTP Password Access Allow acces from local networks

Offline elorenz

  • ***
  • 41
  • +0/-0
DynDNS: SME 7.0 with 2 domains behind a Firewall/Router
« Reply #14 on: October 22, 2006, 08:06:06 PM »
Ian,
You won't be needing FTP access, thats old fashioned stuff  8) .
So turn off FTP access and leave ssh access as it is.
This done, try to connect with putty or filezilla using root login.
Let me know if you succeded in copying the script to the specified directory.
Regards,
Ernesto
............