Difference between revisions of "Tutorials Linux DDNS Update Client wget"
(add note about missing wget / misleading wget in title) |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | 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). | + | ==Preamble== |
+ | 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), using only software that comes installed stock on the Pre (other than the small shell script you will write) and not requiring a daemon process running all the time to monitor the connection (other than pppd itself, which is what makes the connection in the first place, not anything extra). | ||
− | If you're using the Optware Package Feed you might want to check out [[Tutorials_Linux_DDNS_Update_Client_ez-ipupdate|ez-ipupdate]] or [[Tutorials_Linux_DDNS_Update_Client_INADYN|INADYN]]. However, if your dynamic DNS service isn't supported by either of these, you're building a custom service, or you want a | + | If you're using the Optware Package Feed you might want to check out [[Tutorials_Linux_DDNS_Update_Client_ez-ipupdate|ez-ipupdate]] or [[Tutorials_Linux_DDNS_Update_Client_INADYN|INADYN]]. However, if your dynamic DNS service isn't supported by either of these, you're building a custom service, or you want a solution that doesn't require an always-on daemon or installing any additional software, this guide may be for you. |
− | + | There are many ddns service providers and most of them offer some way to update your ddns entry via URL. | |
+ | There are two main ways that a ddns service provider obtains your dynamic IP from you. Some providers use one way, some use the other way, some provide both methods and allow you to use whichever way is more convenient for you. | ||
+ | |||
+ | * In one way, call it Type A, You submit an http request to a cgi on their server, and their server uses the IP that the request came from. | ||
+ | |||
+ | One potential advantage to this method (for other environments besides the Pre) is that the url is static. It doesn't need any variables, and your script or program doesn't need to figure out what your current IP is when it runs. This can be good for PC's behind NAT routers that don't have a built-in ability to update your particular ddns service. | ||
+ | |||
+ | However on the Pre this advantage is outweighed by the need to ensure that this request always goes out via the evdo connection even if you happen to be near a wifi access point which would be used otherwise. This is so that the ddns service always gets your evdo IP, never the IP of any wifi access points you might happen to be near at the time. The evdo connection is the only IP that will be useful for remotely accessing the Pre. | ||
+ | |||
+ | To do that, on the Pre, we momentarily make the ppp0 connection the highest priority by adding a routing table entry just before updating the ddns service, and remove it immediately after. This does not affect any of the existing routing table entries of the moment, just temporarily supercedes them. So when we are done, things are safely & reliably left just as they were before the script ran. | ||
+ | |||
+ | * In the other way, call it Type B, You submit an http request to a cgi on their server, and you supply the IP you want the ddns service to use, usually via query string arguments. | ||
+ | If you have a choice, this method is optimal for the Pre since it allows us to take advantage of built in features of pppd and doesn't matter if the ppp0 (evdo) connection is currently the default or only route at that moment. (Doesn't matter if you happen to be near, and using, a wifi connection at the time the script runs.) | ||
+ | |||
+ | If you have the option to use either method (such as with DynDNS.org), try to use Type B.<br> | ||
+ | In the particular case of the Pre, it's simpler and may be a little more reliable.<br> | ||
==Prerequisites== | ==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 | + | * 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, novaproxy, or using the homebrew on-device Terminal app. |
− | * This page assumes you have a Dynamic DNS service account with a service that provides URL based updating | + | * This page assumes you have a Dynamic DNS service account with a service that provides URL based updating. |
− | |||
− | |||
− | |||
==Obtain the Update URL provided by your service== | ==Obtain the Update URL provided by your service== | ||
− | + | Some Type A examples: | |
− | + | * [https://www.dyndns.com/developers/specs/syntax.html DynDNS.org/DynDNS.com]: <nowiki>http://username:password@members.dyndns.org/nic/update?hostname=yourhostname&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG</nowiki> | |
+ | * [http://freedns.afraid.org afraid.org]: <nowiki>http://freedns.afraid.org/dynamic/update.php?XXXXXXXXXXXX</nowiki> | ||
− | + | Some Type B examples: | |
+ | * [https://www.dyndns.com/developers/specs/syntax.html DynDNS.org/DynDNS.com]:<nowiki>http://username:password@members.dyndns.org/nic/update?hostname=yourhostname&myip=ipaddress&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG</nowiki> | ||
+ | * [http://www.dnsmadeeasy.com/s0306/res/ddnsc.html dnsmadeeasy] <nowiki>http://www.dnsmadeeasy.com/servlet/updateip?username=YOURUSERNAME&password=YOURPASSWORD&id=DNSRECORDID&ip=YOURIPADDRESS</nowiki> | ||
+ | * [https://joker.com/faq/content/11/427/en/what-is-dynamic-dns-dyndns.html?highlight=dynamic%20dns joker.com]: <nowiki>http://svc.joker.com/nic/update?username=YOURUSERNAME&password=YOURPASSWORD&hostname=YOURHOSTNAME&myip=YOURIPADDRESS</nowiki> | ||
− | + | ==Enable write access to the root file system== | |
− | <nowiki> | + | <nowiki>mount -o remount,rw /</nowiki> |
− | + | ==Update your service whenever your ppp0 (EV-DO) IP address changes== | |
+ | pppd will do this for us automatically by creating a script in the /etc/ppp/ip-up.d/ directory called 09update-ddns. So, | ||
+ | <nowiki>vi /etc/ppp/ip-up.d/09update-ddns</nowiki> | ||
− | + | Then write whichever of these scripts applies to your provider. | |
− | |||
− | + | Type A: | |
− | |||
<nowiki> | <nowiki> | ||
#!/bin/sh | #!/bin/sh | ||
− | # pppd provides IFNAME and IPREMOTE | + | # pppd provides $IFNAME and $IPREMOTE |
ip route add default via $IPREMOTE dev $IFNAME metric 1 | ip route add default via $IPREMOTE dev $IFNAME metric 1 | ||
− | + | curl -s --retry 6 "http://MYUSERNAME:MYPASSWORD@members.dyndns.org/nic/update?hostname=MYHOSTNAME&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG" | |
ip route del default via $IPREMOTE dev $IFNAME metric 1 | ip route del default via $IPREMOTE dev $IFNAME metric 1 | ||
</nowiki> | </nowiki> | ||
− | + | Type B: | |
− | |||
<nowiki> | <nowiki> | ||
#!/bin/sh | #!/bin/sh | ||
− | # pppd provides IPLOCAL | + | # pppd provides $IPLOCAL |
− | + | curl -s --retry 6 "http://MYUSERNAME:MYPASSWORD@members.dyndns.org/nic/update?hostname=MYHOSTNAME&myip=${IPLOCAL}&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG" | |
</nowiki> | </nowiki> | ||
==Make this script executable== | ==Make this script executable== | ||
− | <nowiki> | + | <nowiki>chmod 755 /etc/ppp/ip-up.d/09update-ddns</nowiki> |
− | chmod 755 /etc/ppp/ip-up.d/09update-ddns | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | ==Remount the root file system as readonly== | |
− | + | <nowiki>mount -o remount,ro /</nowiki> | |
− | + | ==Notes== | |
− | + | * The title of this document says "wget" yet "wget" is not used anywhere in it. | |
− | + | Wget on the Pre is just a busybox built-in and lacks the retry feature we need. | |
− | + | Since curl is also shipped as a stock part of the Pre's OS, and since it's | |
− | + | the full-featured real curl program including --retry, | |
− | + | it's simpler and costs us nothing to just use that instead of writing a retry loop around the fake wget in the shell script. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | wget | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | curl --retry | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== == | == == | ||
* raeb | * raeb | ||
* dreadchicken | * dreadchicken | ||
− | * [[User:Bkw|Bkw]] | + | * [[User:Bkw|Bkw]] 13:09, 1 November 2009 (UTC) |
Latest revision as of 12:54, 5 November 2009
Preamble
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), using only software that comes installed stock on the Pre (other than the small shell script you will write) and not requiring a daemon process running all the time to monitor the connection (other than pppd itself, which is what makes the connection in the first place, not anything extra).
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 solution that doesn't require an always-on daemon or installing any additional software, this guide may be for you.
There are many ddns service providers and most of them offer some way to update your ddns entry via URL. There are two main ways that a ddns service provider obtains your dynamic IP from you. Some providers use one way, some use the other way, some provide both methods and allow you to use whichever way is more convenient for you.
- In one way, call it Type A, You submit an http request to a cgi on their server, and their server uses the IP that the request came from.
One potential advantage to this method (for other environments besides the Pre) is that the url is static. It doesn't need any variables, and your script or program doesn't need to figure out what your current IP is when it runs. This can be good for PC's behind NAT routers that don't have a built-in ability to update your particular ddns service.
However on the Pre this advantage is outweighed by the need to ensure that this request always goes out via the evdo connection even if you happen to be near a wifi access point which would be used otherwise. This is so that the ddns service always gets your evdo IP, never the IP of any wifi access points you might happen to be near at the time. The evdo connection is the only IP that will be useful for remotely accessing the Pre.
To do that, on the Pre, we momentarily make the ppp0 connection the highest priority by adding a routing table entry just before updating the ddns service, and remove it immediately after. This does not affect any of the existing routing table entries of the moment, just temporarily supercedes them. So when we are done, things are safely & reliably left just as they were before the script ran.
- In the other way, call it Type B, You submit an http request to a cgi on their server, and you supply the IP you want the ddns service to use, usually via query string arguments.
If you have a choice, this method is optimal for the Pre since it allows us to take advantage of built in features of pppd and doesn't matter if the ppp0 (evdo) connection is currently the default or only route at that moment. (Doesn't matter if you happen to be near, and using, a wifi connection at the time the script runs.)
If you have the option to use either method (such as with DynDNS.org), try to use Type B.
In the particular case of the Pre, it's simpler and may be a little more reliable.
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, novaproxy, or using the homebrew on-device Terminal app.
- This page assumes you have a Dynamic DNS service account with a service that provides URL based updating.
Obtain the Update URL provided by your service
Some Type A examples:
- DynDNS.org/DynDNS.com: http://username:password@members.dyndns.org/nic/update?hostname=yourhostname&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG
- afraid.org: http://freedns.afraid.org/dynamic/update.php?XXXXXXXXXXXX
Some Type B examples:
- DynDNS.org/DynDNS.com:http://username:password@members.dyndns.org/nic/update?hostname=yourhostname&myip=ipaddress&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG
- dnsmadeeasy http://www.dnsmadeeasy.com/servlet/updateip?username=YOURUSERNAME&password=YOURPASSWORD&id=DNSRECORDID&ip=YOURIPADDRESS
- joker.com: http://svc.joker.com/nic/update?username=YOURUSERNAME&password=YOURPASSWORD&hostname=YOURHOSTNAME&myip=YOURIPADDRESS
Enable write access to the root file system
mount -o remount,rw /
Update your service whenever your ppp0 (EV-DO) IP address changes
pppd will do this for us automatically by creating a script in the /etc/ppp/ip-up.d/ directory called 09update-ddns. So,
vi /etc/ppp/ip-up.d/09update-ddns
Then write whichever of these scripts applies to your provider.
Type A:
#!/bin/sh # pppd provides $IFNAME and $IPREMOTE ip route add default via $IPREMOTE dev $IFNAME metric 1 curl -s --retry 6 "http://MYUSERNAME:MYPASSWORD@members.dyndns.org/nic/update?hostname=MYHOSTNAME&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG" ip route del default via $IPREMOTE dev $IFNAME metric 1
Type B:
#!/bin/sh # pppd provides $IPLOCAL curl -s --retry 6 "http://MYUSERNAME:MYPASSWORD@members.dyndns.org/nic/update?hostname=MYHOSTNAME&myip=${IPLOCAL}&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
Make this script executable
chmod 755 /etc/ppp/ip-up.d/09update-ddns
Remount the root file system as readonly
mount -o remount,ro /
Notes
- The title of this document says "wget" yet "wget" is not used anywhere in it.
Wget on the Pre is just a busybox built-in and lacks the retry feature we need. Since curl is also shipped as a stock part of the Pre's OS, and since it's the full-featured real curl program including --retry, it's simpler and costs us nothing to just use that instead of writing a retry loop around the fake wget in the shell script.
- raeb
- dreadchicken
- Bkw 13:09, 1 November 2009 (UTC)