Koozali.org: home of the SME Server

dynamic dns service

Offline jmarcosm

  • ***
  • 59
  • +0/-0
dynamic dns service
« on: April 16, 2006, 03:41:25 AM »
Hi to all,

I have installed sme7rc1. In the option dinamic client my option was the custon. I use zoneedit.  I already type my zonedit user accunt and my password @ the "configure this server" console option.
Should I have to do another thing to make this work?

Thanks in advance

Marcos Migliorini
...

Offline Agent86

  • *****
  • 592
  • +0/-0
    • http://www.iclbiz.com
Edited
« Reply #1 on: April 16, 2006, 04:45:51 AM »
Edited

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: dynamic dns service
« Reply #2 on: April 16, 2006, 04:54:35 AM »
Quote from: "jmarcosm"

I have installed sme7rc1. In the option dinamic client my option was the custon.


The "custom" choice requires you to write your own script, in /sbin/e-smith/dynamic-dns/custom.

Offline judgej

  • *
  • 375
  • +0/-0
Re: dynamic dns service
« Reply #3 on: June 27, 2006, 12:28:31 AM »
Quote from: "CharlieBrady"
Quote from: "jmarcosm"

I have installed sme7rc1. In the option dinamic client my option was the custon.


The "custom" choice requires you to write your own script, in /sbin/e-smith/dynamic-dns/custom.


Perhaps something like this would fit the bill ('custom' script):

Code: [Select]

#!/bin/bash

#------------------------------------------------------------
# zoneedit dynamic DNS update handler.
# Based loosely on scripts found at
# http://www.hughesjr.com/content/view/17/2/Site_News
# Author: Jason Judge
#------------------------------------------------------------

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

# Full Path to executables
# this is correct for most RedHat distros
IFCONFIG=/sbin/ifconfig
AWK=/bin/awk
GREP=/bin/grep
DIG=/usr/bin/dig
LYNX=/usr/bin/lynx
ECHO=/bin/echo

# Primary DNS listed
PRIMARY_DNS="ns5.zoneedit.com"

# Date for Logs
DATE="date +'%x %X %Z - '"

# Get the Domain Name's 'A'-record IP Address
DOMAIN_IP="$DIG @$PRIMARY_DNS $DOMAIN | grep $DOMAIN | grep -v DiG | grep -v ";"$DOMAIN | awk '$4 == "A" {print $5}'"

# If there is an error, log it and exit the script
# otherwise, continue with the updates

if [ "$DOMAIN_IP"x == x ]
then
    $ECHO "$DATE Error doing lookup!"
    exit 1
else
    # Update is required - update domains
    if [ "$IPADDR" == "$DOMAIN_IP" ]
    then
        $ECHO "$DATE" External IP "$IPADDR" matches Domain IP "$DOMAIN_IP" - no action required.
        exit 0
    else
        $ECHO "$DATE" Updating "$DOMAIN" from "$DOMAIN_IP" to "$IPADDR"
        COMMAND="$LYNX -source -auth=$USERID:$PASSWD http://dynamic.zoneedit.com/auth/dynamic.html?host=$DOMAIN&dnsto=$IPADDR"
        $COMMAND
    fi
fi


I'm just testing this now on a new server...
-- Jason

Offline elorenz

  • ***
  • 41
  • +0/-0
dynamic dns service
« Reply #4 on: September 08, 2006, 06:21:07 PM »
Hi all,
Here is another example of an update script that also works if you are behind a Firewall/Router and are using multiple domains:

#!/bin/sh
#------------------------------------------------------------
# ZoneEdit dynamic DNS update handler.
#------------------------------------------------------------


IPADDR=lynx --dump http://checkip.dyndns.org | awk '{print $4}'
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

Enjoy,

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

Happy

dynamic dns service
« Reply #5 on: September 12, 2006, 03:53:20 AM »
I am trying to do the same thing for dyndns.
I found a script and have edited it to suit my needs. (ps I'm working in server only mode and am behind a router with one virtual host)
Running SME server 7.0 (after upgrading from 7.0rc3)
the dyndns.org script doesn't do anything it seems...

Unfortunately the
Code: [Select]
LOOKUP=host ${DYNHOST[$i]} | cut -d ' ' -f4
line to lookup the external ip address mapped to the server sometimes picks up my local lan ip address.

I would like to change this command to lookup the dyndns nameserver for that host instead. However I have been unable to find a nameserver for dyndns.org or the command I would need to look it up.
I am assuming the 'dig' command mentioned in the script earlier in this thread would work.
After this I plan on adding it as a cron job using the cron-sme addon.

can anyone help me with the snippet above?

I've also got a workaround for those people who don't want to use checkip.dyndns.org to determine their ip address.
This logs into the router to check it directly. Unfortunately it also prevents anyone else from logging in for the next 5 minutes on my router (Billion 743GE)

Code: [Select]
MYIP=/usr/bin/lynx -auth username:password -dump http://billion743geRouterIPAddress/status.html/ | grep 'IP Address ' | tail -n1 | tr -d [a-z] | tr -d [A-Z] | tr -d ' '

Actually, I looked at it a bit and found my isp's primary DNS server.
Then I entered that value in like so:


Code: [Select]

LOOKUP=host ${DYNHOST[$i]} $PRIMDNS | cut -d ' ' -f4 | tail -n1
where PRIMDNS is an ip address set at the beginning.

anything wrong with my reasoning for this?


Code: [Select]

#!/bin/sh

# dyndns update script
# Copyright (c) 2001 by Nicholas Borko
#
# This script will update dyndns records for a ppp connection. It only does
# simple updates and does not handle MX records, offline mode, or any kind
# of syntax checking on what you supply it. However, it *will* query the
# dyndns name servers to see if you actually need to do an update, which
# means you can run it in a cron job with no problems. Just remember: I'm
# not responsible for your stupidity or dyndns abuse.
#
# This program requires host, perl and lynx to do the dirty work. You *must*
# configure the options below to make this work. Once the defaults are set,
# you can specify the host name and wildcard option through the environment
# variables DYNDNS and DYNWILD, e.g.
#
#    $ DYNHOST=myhost.homeip.net DNSWILD=ON update-dyndns
# -or-
#    % env DYNHOST=anotherhost.dnsalias.com update-dns
#
# 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.

# Unless you absolutely *require* a proxy, don't use one with dyndns
unset http_proxy
# Set the username and password for the dyndns account
USERNAME=userName
PASSWORD=passWord

# Set the system being used to either static or dynamic DNS
SYSTEM=dyndns
#SYSTEM=statdns

# Set the hostname for the record to change
DYNHOST[0]=mydomain0.ath.cx


DYNHOST[1]=mydomain1.ath.cx
# Set whether to wildcard the DNS entry, i.e. *.$DYNHOST
#WILDCARD=OFF
WILDCARD=ON

############################################
## DO NOT EDIT ANYTHING BEYOND THIS POINT ##
############################################

if [ -z "$DNSWILD"]; then
        DNSWILD="$WILDCARD"
fi

MYIP=/usr/bin/lynx -dump http://checkip.dyndns.org/ | cut -d ' ' -f7 | tail -n2 | head -n1
for ((i=0;i<${#DYNHOST[*]};i++)); do

if [ -z "$DYNDNS" ]; then
        DYNDNS="${DYNHOST[$i]}"
fi

#echo ${DYNHOST[$i]}
LOOKUP=host ${DYNHOST[$i]} | cut -d ' ' -f4

# Do the work
if [ "$LOOKUP" = "$MYIP" ]; then
        echo "No change in DNS entry."
else
echo "Do authentication here"
#echo lynx -auth=${USERNAME}:${PASSWORD} -source "http://members.dyndns.org:8245/nic/update?system=${SYSTEM}&hostname=${DYNDNS}&myip=${MYIP}&wildcard=${DNSWILD}"
fi
done

Offline imcintyre

  • *
  • 609
  • +0/-0
Help with Scripts
« Reply #6 on: September 19, 2006, 01:23:45 AM »
These zone edit scripts might help me but I don't know what to do with them, i.e. how do I get them into the operating system.

I know this is pretty basic but that's the way it is, so if anyone can help with the implementation, I would appreciate it greatly.

thx in advance

Happy

dynamic dns service
« Reply #7 on: September 19, 2006, 07:13:00 AM »
I don't know where they moved the user  contribs too since the web site update.
But search for the sme-server cron addon.

It lets run automated scripts whenever you choose.

I've placed my custom dyndns.org script in a 'bin' directory in the admin accounts user filespace.

than I configured sme-server cron addon to run that script every hour.

works like a dream.

you'l probably have to search the forums for "sme cron" or something like that.

Offline imcintyre

  • *
  • 609
  • +0/-0
dynamic dns service
« Reply #8 on: September 19, 2006, 07:02:53 PM »
don't know where they moved the user contribs too since the web site update.
But search for the sme-server cron addon.

It lets run automated scripts whenever you choose.

I've placed my custom dyndns.org script in a 'bin' directory in the admin accounts user filespace.

than I configured sme-server cron addon to run that script every hour.

works like a dream.

you'l probably have to search the forums for "sme cron" or something like that.

Sounds good but I am very new to linux;
I take it from reading this that if I can get out of sme server and into the basic program running in the background, I will be able to add the script to the program and good things will happen. I have never tried to get into the background program. How about some hints/direction. Pls and Thx.

Happy

dynamic dns service
« Reply #9 on: September 20, 2006, 01:23:04 AM »
Step 1: Go to the server manager.
Step 2: go to the remote access panel
Step 3: Ensure that root/admin have at least network access to ssh.
Step 4: Download putty.exe from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
If the site is down (as it was when I just tested it) then google for putty
Step 5: Using putty set the login type to 'ssh', the username to 'root' and the password to whatever your root password is. Make sure you enter in the local network address for sme-server
Step 6: Find sme-server crontab (or whatever the contrib is called) and using an ftp program (I recommend Filezilla) upload it to the admin home directory.
Step 7: in the putty ssh window type cd /home/e-smith/files/users/admin/home/
Step 8: in the putty window type rpm -Uvh NAME_OF_DOWNLOADED_FILE.rpm
Step 9: The easiest way to do this step is to restart your computer. There is a command to gracefully restart the services you need after installing the server addon but I can't remember it. You could do a search for 'restart httpd gracefully' in these forums, see what comes up.
Step 10: in the /home/e-smith/files/users/admin/home/ directory type
mkdir bin
Step 11: type cd bin
Step 12: type vi custom.dns
Step 13: press the letter i
Step 14: Using control-C copy the appropriate script written below onto the windows clipboard.
Step 15: In the putty window press the left and right mouse buttons simultaneously.
Step 16: Press escape in the putty window
Step 17: Type :w
Step 18: Type :q
Step 19: in the putty command prompt again type chmod +x custom.dns (makes the application executable)
Step 20: Attempt to run the application (type ./custom.dns) , make sure it works, etc This I can't really help you with because it depends on your password settings.
Step 21: If all is good you can now close all these windows, go into the sme-server window, find the cron-tab and add a new item.
Set the duration to however long you want and for the script path type
/home/e-smith/files/users/admin/home/bin/custom.dns

Step 22: check your admin email address to ensure you received cron messages with the output from your custom.dns script in the body. If all goes well then congratulations.


Word of warning. I would suggest reading up a bit on vi commands in case you need to do some editing.
here are the basics.
to insert text type i
to finish inserting text press escape
to forward delete a character press x
to save type :w
to quit type :q

I don't think I really should be giving these directions, especially to someone who hasn't used linux before. But you never learn if you don't try.
ps. be careful with your root access. Do not type rm unless you know what you are doing!

Offline imcintyre

  • *
  • 609
  • +0/-0
dynamic dns service
« Reply #10 on: September 20, 2006, 02:42:04 AM »
Thx.

I am cognizant that I might blow everything up but this is a hobby, not a job. Usually I get a book but there was nothing I could find on SME or Centos.

I will give it a whirl and post any successes/failures.

Offline imcintyre

  • *
  • 609
  • +0/-0
dynamic dns service
« Reply #11 on: September 20, 2006, 03:26:33 AM »
Well so far...

I made it to step 6 ok. I have putty, filezilla (I've used before) and something called sme-crontab_manager1.2-1.noarch.rpm

I open up filezilla and type in
Address: 192.168.1.etc
User: admin
Password: "adminpassword"

I get the error message unable to connect. What gives?

When I use filezilla to upload in the windows world, I first need to create a user on the host and shared directories etc. and then I can have access, which I can't do here, how to proceed?

Thanks in advance for your help.

Happy

dynamic dns service
« Reply #12 on: September 20, 2006, 06:13:27 AM »
make sure you connect with putty using ssh (port 22), not telnet.
and also make sure in the server manager you have enabled 'root' login.

the username should be 'root' not 'admin'
I don't know what root password you specified but it is probably the same as your admin password.

and again.
use port 22 (ssh)

as for connecting with filezilla.
there is also a setting in the server-manager to enable ftp access on local networks.
make sure your network is in the local network list.
should be something like
network: 192.168.1.0
netmask: 255.255.255.0

Note the crontab manager in the image below.
It should be the result of following the steps above

server-manager screen should look like this:

Offline imcintyre

  • *
  • 609
  • +0/-0
dynamic dns service
« Reply #13 on: September 20, 2006, 12:26:42 PM »
It's funny, but when I woke at 5:30 the FTP access is the first thing I thought of. Anyways I did that and was able to ftp into the server.

If I ftp in as the admin, using port 21, I get a listing of directories that are
ibays, a shortcut to prmary, samba, server resources, and users. I went into users/admin/home and put the files "sme-crontab***" into it

Time to go for a run. I will take this up later this evening.

Thx for your help.

Happy

dynamic dns service
« Reply #14 on: September 20, 2006, 01:30:59 PM »
No problem.
Good luck.
I am not responsible for any damage done, both directly or indirectly, through following my instructions or misinterpreting them  :roll:

Sorry, couldn't help myself there.

but yeah, be careful with vi, it's easy to stuff things up with it.

And make sure you don't spam your dynamic dns service with the script, otherwise they may terminate your account.
Mine checks to see if the nameserver ip matches with my current ip before attempting to make a change.

yeah
good luck and enjoy your run!