Torsten Förtsch
IT System Development & Security
Kaum macht man's richtig, schon geht's, ;-)

>> Home >> dynip.sh

dynip.sh — a DynDNS client

dynip.sh is a very simple bash script. It does not use a configuration file, all configuration is done in the script header. dynip.sh is designed to run completely without human attention. An email address can be set up to receive error notifications. All data transfer is encrypted using HTTPS. It requires the curl utility to be installed.

Download Download dynip-0.5.tar.gz (7786 Bytes)

Usage

dynip.sh expects the DYNIP_ADDR environment variable to be set to your current IP address. If not set it calls local_ip_detector.sh in the same directory as dynip.sh to get it.

If local_ip_detector.sh is called directly (not from dynip.sh) it fetches the IP address and calls dynip.sh

Hence, no matter whether you call dynip.sh or local_ip_detector.sh they'll do the right thing.

dynip.sh is best called directly by the program that connects you to the Internet. If you are using pppd look for a ip-up script in your pppd documentation.

Alternatively you can use cron to check your IP address every minute. In this case it is necessary to use an IP cache on your file system and to change local_ip_detector.sh to fetch your IP address without additional Internet traffic.

Configuration

Edit dynip.sh and local_ip_detector.sh (if needed).

You need to edit local_ip_detector.sh if the standard method of detecting your IP address does not work or if you don't like it. All other configuration is done directly in dynip.sh.

The standard IP detection method invokes

curl -qs http://checkip.dyndns.org

This generates network traffic and may not work with proxies.

Configuring dynip.sh

There is a configuration section at start of the script. You can set the following variables:

Configuring local_ip_detector.sh

Since the method of detecting your IP address heavily depends on your local setup no general method can be provided. This script implements a default method. Change it to meet your needs.

Modern Curl SSL Settings

Modern curls check the certificate provided by the WEB server more thoroughly than before. Particularly the certificate signer is checked against a list of certificates you trust. Such a list is called a certificate bundle. The DynDNS certificate signer is unforunately not installed in the default certificate bundle. It can be obtained from here.

To add it to your certificate bundle first you need to locate the bundle on your file system. Curl helps you by means of the -v option. Calling an arbitrary https url says for example:

$ curl -v https://bahn.de
* About to connect() to bahn.de port 443
* Connected to bahn.de (81.200.194.40) port 443
* successfully set certificate verify locations:
*   CAfile: /usr/share/curl/curl-ca-bundle.crt
  CApath: none
* SSL certificate problem, verify that the CA cert is OK
* Closing connection #0
curl: (60) SSL certificate problem, verify that the CA cert is OK
More details here: http://curl.haxx.se/docs/sslcerts.html

The interesting lines are CAfile: ... and CApath: .... CAfile is a text file containing certificates. Here you simply append the Geotrust certificate. CApath is a directory where you can store the cert in a extra file. Refer to the openssl docs to learn how.

Alternatively you can set curlopt to -k or --cacert FILENAME where FILENAME points to a file where the Geotrust certificate is stored.

For your convenience the Geotrust certificate is included in this distribution.

Letzte Aktualisierung: 06.08.2008