Tutorials Linux DDNS Update Client wget

From WebOS Internals
Jump to navigation Jump to search

This document contains instructions for setting up your Pre to automatically update a dynamic DNS hostname to your Palm Pre's IP address (assigned by your data service provider).

If you're using the Optware Package Feed you might want to check out ez-ipupdate or INADYN. However, if your dynamic DNS service isn't supported by either of these, you're building a custom service, or you want a freedns.afraid.org solution that doesn't require an always-on daemon, this guide may be for you.

This mechanism functions by adding a priority default routing rule that forces all traffic to go over the ppp0 (EV-DO) connection. This ensures we're updating your service with your ppp0 ip and not your eth0 (Wifi) ip. It optionally then finds your IP address from http://checkip.dyndns.org. Then, it calls your update URL. Finally, it removes the default route it created in step 1.

Prerequisites

  • This page assumes that you have just finished the procedure on the Portal:Accessing_Linux page, and are still logged in as root via telnet, novaterm, or novaproxy.
  • This page assumes you have a Dynamic DNS service account with a service that provides URL based updating (i.e. http://freedns.afraid.org)

Enabling write access to the file system

 mount -o remount,rw /

Obtain the Update URL provided by your service

For http://freedns.afraid.org, log in, and find the 'Direct Update URL' for your dynamic DNS entry. Mine looks like this:

 http://freedns.afraid.org/dynamic/update.php?ZzYyXxWwUuTtSsRr==

This updates the IP of my DNS entry to the IP of the client. We need to make sure we call this address from the ppp0 interface so that it updates to the correct IP. When the Pre is connected to a wifi connection, a default routing entry forces all data to go over that connection.

However, your service may differ, and require different information (example):

 http://mydynamicdnsservice.com/?host=myhost.com&Ip=99.123.222.101


This example doesn't require the caller to be from the new target IP address, and won't need the routing entries.

Update your service whenever your ppp0 (EV-DO) IP address changes

You can do this by adding a script to /etc/ppp/ip-up.d called 09update-ddns.

This is the script for the first example shown above:

 #!/bin/sh
 export gateway=`ip route | tail -1 | awk '{print $3}'`
 ip route add default via $gateway dev ppp0 metric 1
 wget -qO- http://freedns.afraid.org/dynamic/update.php?ZzYyXxWwUuTtSsRr==
 ip route del default via $gateway dev ppp0 metric 1

This is the script for the second example. Note that it gets your IP address and stores it in $myip:

 #!/bin/sh
 export myip=`ifconfig ppp0 | head -2 | tail -1 | awk '{print $2}' | sed 's/[^1-9.]//g'`
 wget -qO- http://mydynamicdnsservice.com/?host=myhost.com&Ip=$myip


Make this script executable

 chmod 755 /etc/ppp/ip-up.d/09update-ddns

Remount the file system as readonly

 mount -o remount,ro /
  • by raeb
  • big thanks to dreadchicken's tutorial