Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Documentation, Tips & Tricks
  • Search

[dyndns|statdns|custom] Without external program...

Unofficial documentation for various parts of Gentoo Linux. Note: This is not a support forum.
Post Reply
Advanced search
3 posts • Page 1 of 1
Author
Message
xanthax
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 91
Joined: Fri Apr 16, 2004 8:53 am
Location: Bi Nary State

[dyndns|statdns|custom] Without external program...

  • Quote

Post by xanthax » Sun Mar 19, 2006 10:21 am

I had a problem: Updating my dyndns without installing a bunch of strange software.....

I came up with a solution: Write a script that wont use a any extra programs that already i dont have.

EDIT: after som complains from a friend i rewrote the script to fit into "gentoo standard" better..

So here is the new script

Code: Select all

#!/bin/sh

# $1  file containing the following information
################################################
# Username Password Eth Dns Wildcard System    #
################################################

# Eth  		#[eth*] 			Ethernet device to use
# LIP  		#[NOT ENTERED BY USER]	 	Last IP
# CIP  		#[NOT ENTERED BY USER] 		Current IP
# Dns  		#[myhost.dyndns.org] 		Dynamic address
# Username  	#[Username] 			Dyndns username
# Password  	#[Password] 			Dyndns password
# Wildcard	#[ON|OFF|NOCHG]			Enable *.mydomain.dyndns.org
# MXHost	#[mailexchanger|NOCHG] 		MX server
# MXBackup	#[YES|NO|NOCHG]			Backup MX server
# System	#[dyndns|statdns|custom]	DNS provider

TmpRcode="/tmp/dyndns_rcode"
TmpConf="/tmp/dyndns_config"
IPLog="/tmp/dyndns_ip"

if ! [ -e $1 ] ; then
  echo "Specified config file does not exist."
  exit 1
fi

source $1

if [ -z $MXHost ] ;then
  MXHost="NOCHG"
fi

if [ -z $MXBackup ] ;then
  MXBackup="NOCHG"
fi

if [ -z $Wildcard ] ;then
  Wildcard="NOCHG"
fi

if [ -z $System ] ; then
  echo "system missing..."
  exit 1
fi

if [ -z $Eth ] ; then
  echo "eth missing..."
  exit 1
fi

if [ -z $Dns ] ; then
  echo "dns missing..."
  exit 1
fi

if [ -z $Username ] ; then
  echo "username missing..."
  exit 1
fi

if [ -z $Password ] ; then
  echo "password missing..."
  exit 1
fi

if ! [ -e $IPLog ] ; then
  touch $IPLog
fi

LIP=`cat $IPLog | grep $Dns= | cut -d "=" -f 2`

CIP=`/sbin/ifconfig $Eth | grep "inet addr" | cut -d ":" -f 2 | cut -d " " -f 1`

if [ "$CIP" != "$LIP" ] ; then

  wget -q --no-check-certificate -O $TmpRcode "https://$Username:$Password@members.dyndns.org/nic/update?system=$System&hostname=$Dns&myip=$CIP&wildcard=$Wildcard&mx=$MXHost&backmx=$MXBackup&offline=NO"

  RCODE=`cat $TmpRcode | grep " " | cut -d " " -f 1`

  if [ "$RCODE" = "badsys" ] ; then
    echo "################################################################################"
    echo "#Invalid service provider specified                                            #"
    echo "################################################################################"
    exit 1 
  fi

  if [ "$RCODE" = "!donator" ] ; then
    echo "################################################################################"
    echo "#PAY YOUR BILLS !!!!!!!!                                                       #"
    echo "################################################################################"
    exit 1 
  fi

  if [ "$RCODE" = "nochg" ] ; then
    echo "################################################################################"
    echo "#WARNING, Unneeded update of IP, repeting this might lead to a canceled account#"
    echo "################################################################################"
  fi

  if [ "$RCODE" = "badauth" ] ; then
    echo "################################################################################"
    echo "#Password or username is incorret                                              #"
    echo "################################################################################"
    exit 1 
  fi

  if [ "$RCODE" = "notfqdn" ] ; then
    echo "################################################################################"
    echo "#Not a qualified hostname                                                      #"
    echo "################################################################################"
    exit 1 
  fi

  if [ "$RCODE" = "nohost" ] ; then
    echo "################################################################################"
    echo "#No such hostname exists#"
    echo "################################################################################"
    exit 1 
  fi

  if [ "$RCODE" = "!yours" ] ; then
    echo "################################################################################"
    echo "#No such host in YOUR account                                                  #"
    echo "################################################################################"
    exit 1 
  fi

  if [ "$RCODE" = "numhost" ] ; then
    echo "################################################################################"
    echo "#To many or to few hosts specified                                             #"
    echo "################################################################################"
    exit 1 
 fi

  if [ "$RCODE" = "abuse" ] ; then
    echo "################################################################################"
    echo "#Your account is blocked because of update abuse                               #"
    echo "################################################################################"
    exit 1 
  fi

  if [ "$RCODE" = "dnserr" ] ; then
    echo "################################################################################"
    echo "#DNS error                                                                     #"
    echo "################################################################################"
    exit 1 
  fi

  if [ "$RCODE" = "911" ] ; then
    echo "################################################################################"
    echo "#Server problems, check your DNS providers homepage                            #"
    echo "################################################################################"
    exit 1 
  fi

  if [ "$RCODE" = "" ] ; then
    echo "################################################################################"
    echo "#No respons from server                                                        #"
    echo "################################################################################"
    exit 1 
  fi

  if [ -z $LIP ] ; then
    echo "$Dns=0.0.0.0" >> $IPLog
  fi

  cat $IPLog > $TmpConf
  sed -e s/^$Dns=.*/$Dns=$CIP/g $TmpConf > $IPLog

fi
Here is the new config file

Code: Select all

Dns=test.ath.cx
Eth=eth1
Username=test
Password=test
System=dyndns
Wildcard=ON
You execute by using:

Code: Select all

Bash# /PATH/SCRIPT /PATH/CONF
TIP:
And a little tip is to put these files somwhere safe and link to them from your dhcpcd execute script "<ConfigDir>/dhcpcd.exe".
Then you have created a permanently automatical update wich does not get your account blocked :D


EDIT:
********************************************************
Example of singel host: /etc/dhcpc/dhcpcd.exe

Code: Select all

/var/updatedns/updatedns /var/updatedns/test.ath.cx
If you have multiple dyndnses just create a con file for each and execute, like this.

Example of multiple hosts: /etc/dhcpc/dhcpcd.exe

Code: Select all

/var/updatedns/updatedns /var/updatedns/test.ath.cx
/var/updatedns/updatedns /var/updatedns/test.dyndns.org
********************************************************
Last edited by xanthax on Sun Mar 19, 2006 1:42 pm, edited 3 times in total.
God is only an imaginary friend for adults...
Top
pyxel
n00b
n00b
User avatar
Posts: 44
Joined: Fri Nov 04, 2005 5:09 pm
Location: Bratislava/brussels
Contact:
Contact pyxel
Website

  • Quote

Post by pyxel » Sun Mar 19, 2006 10:29 am

nice script
Top
xanthax
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 91
Joined: Fri Apr 16, 2004 8:53 am
Location: Bi Nary State

  • Quote

Post by xanthax » Sun Mar 19, 2006 1:44 pm

pyxel wrote:nice script
Thanks, im will fix output logging instead of printing on error too.
but not right now.....
God is only an imaginary friend for adults...
Top
Post Reply

3 posts • Page 1 of 1

Return to “Documentation, Tips & Tricks”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic