DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2007-04-22 23:36:47

Bigfoot
Member
Registered: 2007-04-22
Posts: 5

FTP and dynamic IP

FTP and dynamic IP...not a good combination if you want to access your files from home. I know there are internet services like no-ip.com etc. to solve this problem, does anyone know such a service with the following properties:
* Reliable
* Free
* Offers a client that can be installed on dsm-g600
* The service should work in such a way that it does not rely on the local ip settings (since i have a gateway between the dsm-g600 and the internet).

Offline

 

#2 2007-04-23 04:54:50

Stampeed
Member
Registered: 2006-12-10
Posts: 13

Re: FTP and dynamic IP

for most people, i'd assume that the router itself should have a dynamic dns client, since that's the device most responsible for managing and redistributing your ip address.

i'm doubt you'll be able to find a DSM-G600 dynamic dns client, since each service would probably implement the service in different ways, and be very very unlikely they'd provide an open-source client, and possibly less likely to provide a specific DSM-G600 PowerPC architecture build.


My advice, look at your web-based router for Dynamic DNS settings, to try and configure it. Then use the router's Port-Forwarding settings to manually assign ports to your DSM.

Offline

 

#3 2007-04-23 10:11:04

sala
Member / Site Admin
From: Estonia
Registered: 2006-07-28
Posts: 731
Website

Re: FTP and dynamic IP

There's ez-ipupdate available at download section which supports wide range of ddns (dynamic dns) providers.
Download section also has edns client for everydns.net (free top level ddns provider).
I am not sure but I think that all these clients can just get ip address of any local interface for updating and not any remote gateway IP.


DSM-G600 - NetBSD hdd-boot - 80GB Samsung SP0802N
NSA-220 - Gentoo armv5tel 20110121 hdd-boot - 2x 2TB WD WD20EADS

Offline

 

#4 2007-04-23 20:02:11

Bigfoot
Member
Registered: 2007-04-22
Posts: 5

Re: FTP and dynamic IP

Stampeed, I'm not sure what you mean. It's not possible to install anything onto the router (unless I would modify the firmware), so it will have to run within the dsm. Port-forwarding is already configured and not a problem.

Sala, thanks for the tips about the clients. I will take a closer look later, there seems to be very little documentation so I suppose it will take some time (which I haven't got right now).

I was hoping that there was an existing client that would say every ten minutes or so send a "here-i-am"-message to the central server and then the server would use the ip-address from the received packets (which the router has replaced with the external ip-address).

Offline

 

#5 2007-04-24 03:05:41

Stampeed
Member
Registered: 2006-12-10
Posts: 13

Re: FTP and dynamic IP

Oh, well I hope those DNS tools work for you.

Since you do have what you're looking for, i'll just clarify what I meant to say, even though there's little point to it now.

What i meant to say is that there usually is a dynamic dns client already included on most routers. Thus you would not need a client to install on your DSM, as it already exists on your router.

You are right, it's not possible to install anything onto the router. I was making the assumption that the ddns client already existed on the router, as it seems to be a feature most new routers include.

It also makes the most sense for routers to be responsible to update the ddns service, since the WAN ip address is assigned to the router, and any LAN machines inside the network receive a DHCP ip address, and usually never bother with the WAN ip.

I believe that this is what sala meant when she said

sala wrote:

I am not sure but I think that all these clients can just get ip address of any local interface for updating and not any remote gateway IP.

She's saying that the DNS clients for the DSM will only ever see your internal DHCP ip address, and not be able to recognize your WAN ip.

Offline

 

#6 2007-04-24 09:04:43

sala
Member / Site Admin
From: Estonia
Registered: 2006-07-28
Posts: 731
Website

Re: FTP and dynamic IP

I don't want to be smartass here but actually to be very clear, it is possible to install software to some routers, for example wrt54g (or generic) if you have OpenWrt installed on it.

Also it is possible to get gateway/wan ip address using some "what's my ip services", for example http://ip.xservu.com/ And to go little further it is possible to extract the output and send it to some ddns client which is going to send it to dns server.

But it is all waste of time if you have a ddns client already inside of your router, just as Stampeed it pointed out smile


DSM-G600 - NetBSD hdd-boot - 80GB Samsung SP0802N
NSA-220 - Gentoo armv5tel 20110121 hdd-boot - 2x 2TB WD WD20EADS

Offline

 

#7 2007-04-24 11:49:15

BertrandB
Member
From: Dijon (France)
Registered: 2006-09-16
Posts: 119
Website

Re: FTP and dynamic IP

personaly i use the dyndns service a simple wget at the boot (the dsm is shutdown every night) and it's ok.

My dsm has a fix ip and my router has nat for this ip adress.

i follow : http://www.dyndns.com/developers/specs/syntax.html
and have this line at end of my fun_plug

Code:

wget --http-user=myname --http-passwd=mypass --level=1 --output-document=dyndns.last 'http://members.dyndns.org/nic/update?sytem=dyndns&hostname=mdyndnsdomain'

Last edited by BertrandB (2007-04-24 22:14:20)

Offline

 

#8 2007-04-28 22:04:18

Bigfoot
Member
Registered: 2007-04-22
Posts: 5

Re: FTP and dynamic IP

Thanks everyone.

I made a script that retreives the IP from http://checkip.dyndns.org:8245, checks if the IP has changed and then updates the dyndns service according to BertrandB's post. Finally I scheduled it to run every 20 minutes. Hopefully everything will be fine now.

Here is the code in case someone else has the same problem (or if you just want to tell me how ugly and full of bugs it is..)

fun_plug:
crontab -l > /mnt/HD_a2/schedule_tmp
echo "*/20 * * * * /mnt/HD_a2/update_ip" >> /mnt/HD_a2/schedule_tmp
crontab /mnt/HD_a2/schedule_tmp
rm -f /mnt/HD_a2/schedule_tmp

update_ip:

###Get stored ip from file

OLD_IP=`cat current_ip`

###Get current outside IP

URL=http://checkip.dyndns.org:8245/
GET_CMD=`wget -O - $URL`
STR_HEADER='<html><head><title>Current IP Check</title></head><body>Current IP Address: '
STR_TRAILER='<'
TMP=${GET_CMD#$STR_HEADER}
TMP=${TMP%%<*}
NEW_IP=$TMP

###Compare

if [ $OLD_IP != $NEW_IP ];
then
    echo "IP has changed" >> /mnt/HD_a2/update_ip.log
    echo -n $NEW_IP > current_ip   
    wget --http-user=xxx --http-passwd=xxx --level=1 --output-document=/mnt/HD_a2/update_ip.log 'http://members.dyndns.org/nic/update?system=dyndns&hostname=xxx'
else
    echo "IP is still the same" >> /mnt/HD_a2/update_ip.log
fi

Offline

 

#9 2007-04-29 22:41:12

Bigfoot
Member
Registered: 2007-04-22
Posts: 5

Re: FTP and dynamic IP

Nope...still doesn't work!

When my update_ip script is run as a cron job it always reports that OLD_IP is the same as NEW_IP regardless if there has been a change or not. If I start it manually it works fine.

Can anyone with more linux experience give me a clue why it behaves like this?

Offline

 

#10 2007-04-30 10:08:52

BertrandB
Member
From: Dijon (France)
Registered: 2006-09-16
Posts: 119
Website

Re: FTP and dynamic IP

Bigfoot wrote:

OLD_IP=`cat current_ip`

first never use relatives path in cron job but i don't think it's real problem. may be a busybox problem try to launch the script with the same busybox the dlink one is a bit "craspy"

do you know how often, what the rythme, your provider change your ip address ?

Offline

 

#11 2007-05-02 09:36:38

Bigfoot
Member
Registered: 2007-04-22
Posts: 5

Re: FTP and dynamic IP

Actually it was the relative path that messed things up.

Here is my new working script that also has some error handling:

BASE_DIR='/mnt/HD_a2/'
CHECK_IP_URL='http://checkip.dyndns.org:8245/'
CHECK_IP_CMD=`wget -O - $CHECK_IP_URL`
CHECK_IP_URL_HEADER='<html><head><title>Current IP Check</title></head><body>Current IP Address: '
CHECK_IP_URL_TRAILER='</body></html>'
IP_START='81'
IP_FILE=${BASE_DIR}'current_ip'
LOG_FILE=${BASE_DIR}'update_ip.log'
UPDATE_IP_MY_URL='xxx'
UPDATE_IP_USER='xxx'
UPDATE_IP_PWD='xxx'
UPDATE_IP_URL='http://members.dyndns.org/nic/update?system=dyndns&hostname='${UPDATE_IP_MY_URL}
UPDATE_IP_CMD=`wget -O - --http-user=$UPDATE_IP_USER --http-passwd=$UPDATE_IP_PWD --level=1 $UPDATE_IP_URL`
#UPDATE_IP_CMD='wget -O - --http-user='${UPDATE_IP_USER}' --http-passwd='${UPDATE_IP_PWD}' --level=1 '${UPDATE_IP_URL}
DYNDNS_GUARD_FILE=${BASE_DIR}'dyndns_stop'

echo "Starting IP update" >> $LOG_FILE
date >> $LOG_FILE

###Check if there is a problem with DynDNS that needs to be manually handled
if [ -e $DYNDNS_GUARD_FILE ];
then
    echo "Previous dyndns client error, quitting" >> $LOG_FILE
    exit 1
fi

###Get stored ip from file
OLD_IP=`cat $IP_FILE`

###Get current outside IP
TMP=${CHECK_IP_CMD#$CHECK_IP_URL_HEADER}
TMP=${TMP%%$CHECK_IP_URL_TRAILER*}
NEW_IP=$TMP

###Simple check that the IP seems to be retreived ok
TMP=${NEW_IP%%.*}
if [ "$TMP" != "$IP_START" ];
then
    echo "Could not get current IP, quitting" >> $LOG_FILE
    exit 1
fi

###Compare
if [ $OLD_IP = $NEW_IP ];
then
    echo "IP is still $OLD_IP" >> $LOG_FILE
    exit 0
fi

###Update
echo "IP has changed to $NEW_IP" >> $LOG_FILE
UPDATE_RESULT=$UPDATE_IP_CMD
echo "DynDNS update result: $UPDATE_RESULT" >> $LOG_FILE
UPDATE_RESULT=${UPDATE_RESULT%% *}
   
if [ "$UPDATE_RESULT" = "good" ];
then
    echo "Storing new IP" >> $LOG_FILE
    echo -n $NEW_IP > $IP_FILE
    exit 0
fi

for var in "nochg" "badsys" "badagent" "badauth" "!donator" "notfqdn" "nohost" "!yours" "numhost" "abuse" ; do
    if [ "$UPDATE_RESULT" = "$var" ];
    then
        echo "DynDNS client problem. User action required!" >> $LOG_FILE
        touch $DYNDNS_GUARD_FILE
        exit 1
  fi
done

for var in "dnserr" "911" ; do
    if [ "$UPDATE_RESULT" = "$var" ];
    then
        echo "DynDNS server problem. Will try again next time!" >> $LOG_FILE
        exit 1
  fi
done

echo "Unknown reply, host probably not reachable. Will try again next time!" >> $LOG_FILE
exit 1

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB