Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ddclient /etc/hosts update script
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
timeout
Tux's lil' helper
Tux's lil' helper


Joined: 09 Aug 2003
Posts: 75

PostPosted: Thu Jun 24, 2004 5:13 pm    Post subject: ddclient /etc/hosts update script Reply with quote

Following modification was tested with ADSL and Cable, if you are behind a router (ex. Dlink 614), please set use=web instead of use=if in your /etc/ddclient/ddclient.conf
Code:

#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /home/cvsroot/gentoo-x86/net-dns/ddclient/files/ddclient.rc6,v 1.3 2004/03/04 19:17:25 vapier Exp $
#define network interface
INTERFACE=eth0
#get current ip address
CURRENT_IP=`/sbin/ifconfig $INTERFACE | grep inet | cut -d ":" -f 2 | cut -d " " -f 1`
#get old ip address
REGISTERED_IP=`grep $HOSTNAME /etc/hosts | cut -f 1`

depend() {
   need net
}

checkconfig() {
   if [ ! -e /etc/ddclient/ddclient.conf ] ; then
      eerror "You need a /etc/ddclient/ddclient.conf file to run ddclient"
      eerror "There is a sample file in /etc/ddclient/"
      return 1
   fi

}

start() {
   checkconfig || return 1
   ebegin "Starting DDClient"
   start-stop-daemon --start --quiet --exec /usr/sbin/ddclient

   #update /etc/hosts, added by Jackey Yang, 043936y@acadiau.ca
   if [ $CURRENT_IP != $REGISTERED_IP ]; then
         einfo "IP adress has changed, updating /etc/hosts ...."
      sed -e "s/$REGISTERED_IP/$CURRENT_IP/g" /etc/hosts > /etc/hosts.new
        if [ -s /etc/hosts.new ] ; then
            einfo "$CURRENT_IP has been updated successfully"
            cp /etc/hosts /etc/hosts.bak
            mv /etc/hosts.new /etc/hosts
      einfo "Backup old /etc/hosts to /etc/hosts.bak."
         else
            eerror "/etc/hosts.new is empty, no update done."
            ewarn "Please modify /etc/hosts by yourself."
         fi
   else
         einfo "IP adress hasn't changed: no update needed."
   fi
   #end of update

   eend $?
}

stop() {
   ebegin "Stopping DDClient"
   start-stop-daemon --stop --quiet --pidfile /var/run/ddclient.pid
   eend $?
}

Back to top
View user's profile Send private message
guldan
Tux's lil' helper
Tux's lil' helper


Joined: 24 May 2004
Posts: 81

PostPosted: Thu Jul 08, 2004 6:39 pm    Post subject: Reply with quote

Using ddclient v3.6.2 behind a Zyxel 642R ADSL router (NAT'ed access) which is my eth network gateway, I use the below listed ddclient.conf file. First get ddclient with:
Code:
emerge ddclient

e.g. first do a
Code:
emerge -p ddclient

to see what ebuilds it will install

Ddclient comes with a default conf file "sample-etc_ddclient.conf" inside /etc/ddclient/, just rename it to "ddclient.conf" by

Code:
cp sample-etc_ddclient.conf ddclient.conf

This way you still have the "sample-etc_ddclient.conf" as a backup in your /etc/ddclient/ folder.

Now to the ddclient.conf:
    etc/ddclient/ddclient.conf
    ######################################################################
    ##
    ## Define default global variables with lines like:
    ## var=value [, var=value]*
    ## These values will be used for each following host unless overridden
    ## with a local variable definition.
    ##
    ## Define local variables for one or more hosts with:
    ## var=value [, var=value]* host.and.domain[,host2.and.domain...]
    ##
    ## Lines can be continued on the following line by ending the line
    ## with a \
    ##
    ######################################################################
    daemon=300 # check every 300 seconds
    syslog=yes # log update msgs to syslog
    mail=root # mail update msgs to root
    pid=/var/run/ddclient.pid # record PID in file.
    #
    ## To obtain an IP address from Web status page (using the proxy if defined)
    use=web, web=checkip.dyndns.org/, web-skip='IP Address' # found after IP Address
    #
    server=members.dyndns.org # default server

    login=***** # Your dyndns login
    password=***** # Your dyndny password
    #mx=mx.for.your.host # default MX
    #backupmx=yes|no # host is primary MX
    #wildcard=yes|no # add wildcard CNAME?

    ##
    ## dyndns.org dynamic addresses
    ##
    ## (supports variables: wildcard,mx,backupmx)
    ##
    server=members.dyndns.org, \
    protocol=dyndns2 \
    guldi.mine.nu #Your Dyndns domain name

If you have a custom account you need to set your custom date in the "dyndns.org custom addresses" section. Make sure to set:
    custom=yes


I started ddclient with:
Code:
rc-update add ddclient default


works like a charm.
Back to top
View user's profile Send private message
pinnockio
Apprentice
Apprentice


Joined: 08 Jun 2002
Posts: 162

PostPosted: Thu Feb 10, 2005 1:12 pm    Post subject: Reply with quote

Hello,


I've got 2 questions.

1. I use the DynDNS offerd domain name my-host.is-a-geek.org. Should I set the custom variable to "yes" or not?

2. I use the -fw switch to fetch the ip-adress from my modem/router/switch and set ddclient to run as a daemon every xyz minutes. Does this mean that ddclient will update my dns entry at DynDNS.org every xyz minutes or will it poll my modem/router/switch every xyz minutes and only update the entry at DynDNS.org when my IP has changed?

It is quite stupid I ask these questions here, but the documentation fails to do so. Thanx in advance for anybody who could help me!


Kind regards,


A belgian Gentoo user
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum