Active Topics

 


Reply
Thread Tools
Posts: 729 | Thanked: 155 times | Joined on Dec 2009
#1
Before I post it as a bug report I want to ask other people if they experience the same.
I want to update my DynDNS account everytime the used network interface changes. I created a script in /etc/network/if-up.d/dyndns like this (first idea from http://talk.maemo.org/showthread.php?t=34898&page=2):
Code:
#!/bin/sh
cd /home/user/apps/
if ifconfig | grep gprs0 > /dev/null
 then
	while [ -z "$(ifconfig gprs0 | grep inet)" ] 
	 do
		echo "$(date) - No IP yet for gprs0" >> /home/user/apps/dyndns.log
		sleep 2
	 done
	python ipcheck.py -v -i gprs0 USER PASSWORD DynDNSHOST >> /home/user/apps/dyndns.log
 else
	if ifconfig | grep wlan0 > /dev/null
	 then
		while [ -z "$(ifconfig wlan0 | grep inet)" ] 
		 do
		echo "$(date) - No IP yet for wlan0" >> /home/user/apps/dyndns.log
			sleep 2
		 done
		python ipcheck.py -v -i wlan0 -r checkip.dyndns.org:8245 USER PASSWORD DynDNSHOST >> /home/user/apps/dyndns.log
	 else
		echo "Update failed, no specified interface found!" >> /home/user/apps/dyndns.log
	fi
fi
echo " " >> /home/user/apps/dyndns.log
Together with the /home/user/apps/ipcheck.py from http://ipcheck.sourceforge.net/ I should have the current IP for my DynDNS Host all the time up to date. I tested it but it only works sometimes. I cannot figure out when (or if) this script will not be executed even if there is a change in the network interface but I can see in the log file that not all my network interface changes are tracked.
It would be really nice if someone could confirm this.
Thanks in advance.

PS: You don't have to use DynDNS for this, you can also test it with
Code:
#!/bin/sh
cd /home/user/apps/
if ifconfig | grep gprs0 > /dev/null
 then
	while [ -z "$(ifconfig gprs0 | grep inet)" ] 
	 do
		echo "$(date) - No IP yet for gprs0" >> /home/user/apps/dyndns.log
		sleep 2
	 done
	echo "$(date) - gprs0 up >> /home/user/apps/dyndns.log
 else
	if ifconfig | grep wlan0 > /dev/null
	 then
		while [ -z "$(ifconfig wlan0 | grep inet)" ] 
		 do
		echo "$(date) - No IP yet for wlan0" >> /home/user/apps/dyndns.log
			sleep 2
		 done
		echo "$(date) - wlan0 up >> /home/user/apps/dyndns.log
	 else
		echo "Update failed, no specified interface found!" >> /home/user/apps/dyndns.log
	fi
fi
echo " " >> /home/user/apps/dyndns.log
 
Posts: 27 | Thanked: 21 times | Joined on Jan 2010
#2
Originally Posted by DaSilva View Post
I tested it but it only works sometimes. I cannot figure out when (or if) this script will not be executed even if there is a change in the network interface but I can see in the log file that not all my network interface changes are tracked.
It would be really nice if someone could confirm this.
Thanks in advance.
I have been running a similar script since I got my N900 and I have yet to experience this problem. I did have a few thoughts when I created the script though:

1. If on wifi and the dhcp server for whatever reason decide to issue a new IP address it might fail (it would have to be a seriously buggy dhcp server - but was just a remote possibility)

2. I reckon the same could happen on 3G/GPRS - although to the best of my knowledge those run PPP and I can't remember PPP having any provision to change IP address while running. So I reckon this cannot actually happen.

I think we're both using the same ipcheck.py script, so I doubt it's a network timeout issue. B'sides - except from the fact that I do in fact get a public IP address my GPRS/3G provider must be the worst rubbish in the world so if my internet doesn't time out - none will

Sorry - I know this wasn't particularly helpful.
 
Posts: 729 | Thanked: 155 times | Joined on Dec 2009
#3
Can you show me your scripts please?
 
Posts: 27 | Thanked: 21 times | Joined on Jan 2010
#4
Originally Posted by DaSilva View Post
Can you show me your scripts please?
Well - almost embarrassed to do so I mean - it's not exactly pretty and as mentioned in another thread I mostly did it to play with maemo package building - anyway - the /etc/network/if-up.d script looks like this:

Code:
#!/bin/sh
#
# $Id: ipcheck 994 2010-01-18 14:58:51Z lth $
#
# 
. /etc/ipcheckrc
. /home/user/.ipcheckrc || true

if [ -z $DYNDNS_HOSTNAME ]; then
        exit 0
fi

if [ ! -f /opt/ipcheck/ipcheck.dat ]; then
        MAKEDAT=--makedat
fi

cd /opt/ipcheck
./ipcheck.py $MAKEDAT -l -r checkip.dyndns.org:8245 $DYNDNS_USER $DYNDNS_PASSWORD $DYNDNS_HOSTNAME
The DYNDNS_whatever variables just declared in the configuration file.

And I have yet to see this one fail.
 

The Following User Says Thank You to lbthomsen For This Useful Post:
Posts: 58 | Thanked: 7 times | Joined on Nov 2009 @ Hilversum
#5
This happens to me too, sometimes the host is not updated... :|
 
Posts: 27 | Thanked: 21 times | Joined on Jan 2010
#6
Originally Posted by sardaukar View Post
This happens to me too, sometimes the host is not updated... :|
Interesting. Well - I haven't really tested it thoroughly so it is possible that it has missed an update here and there. Perhaps I just never noticed it.
 
Reply


 
Forum Jump


All times are GMT. The time now is 15:17.