Dynamic DNS

From Hack Sphere Labs Wiki
Jump to: navigation, search

afraid.org inadyn debian

aptitude install inadyn

First nano -w /etc/inadyn.conf

#config
update_period_sec 600 # Check for a new IP every 600 seconds
username bla
password bla
forced_update_period 320000
dyndns_system default@freedns.afraid.org
alias your.hosthere.org
background
syslog

Then

nano -w /etc/init.d/inadyn
#!/bin/bash
case "$1" in
    start)
	if [ -f /tmp/inadyn.pid ]; then
		PID=$(cat /tmp/inadyn.pid)
		kill -0 ${PID} &>/dev/null
		if [ $? = 0 ]; then
			echo "Inadyn is already running."
		else
			/usr/sbin/inadyn
			pidof inadyn > /tmp/inadyn.pid
			PID=$(cat /tmp/inadyn.pid)
			kill -0 ${PID} &>/dev/null
			if [ $? = 0 ]; then
				echo "Inadyn started succesfully."
			else
				echo "Error starting Inadyn"
			fi
		fi
	else
		/usr/sbin/inadyn
		pidof inadyn > /tmp/inadyn.pid
		PID=$(cat /tmp/inadyn.pid)
		kill -0 ${PID} &>/dev/null
		if [ $? = 0 ]; then
			echo "Inadyn started succesfully."
		else
			echo "Error starting Inadyn"
		fi
        fi
        ;;
    stop)
	if [ -f /tmp/inadyn.pid ];then
		PID=$(cat /tmp/inadyn.pid)
		kill -0 ${PID} &>/dev/null
		if [ $? = 0 ]; then
			/bin/kill ${PID}
			kill -0 ${PID} &>/dev/null
			if [ $? = 1 ]; then
				echo "Inadyn stopped succesfully."
			else
				echo "Error stopping Inadyn"
			fi
		else
			echo "Inadyn is already stopped."
		fi
	else
		echo "Inadyn is already stopped."
	fi
        ;;
    reload|restart)
        $0 stop
        $0 start
        ;;
    *)
        echo "Usage: $0 start|stop|restart|reload"
        exit 1
esac
exit 0

Then

chmod +x /etc/init.d/inadyn
ln -s /etc/init.d/inadyn /etc/rc2.d/S03inadyn
ln -s /etc/init.d/inadyn /etc/rc0.d/K03inadyn

Notes