Next: , Previous: , Up: Nastavenie systému   [Contents][Index]

3.5 Dynamic DNS mcron job

If your ISP (Internet Service Provider) only provides dynamic IP addresses, it can be useful to setup a dynamic DNS (Domain Name System) (also known as DDNS (Dynamic DNS)) service to associate a static host name to a public but dynamic (often changing) IP address. There are multiple existing services that can be used for this; in the following mcron job, DuckDNS is used. It should also work with other dynamic DNS services that offer a similar interface to update the IP address, such as, with minor adjustments.

The mcron job is provided below, where DOMAIN should be substituted for your own domain prefix, and the DuckDNS provided token associated to DOMAIN added to the /etc/duckdns/DOMAIN.token file.

(define duckdns-job
  ;; Update personal domain IP every 5 minutes.
  #~(job '(next-minute (range 0 60 5))
            (with-extensions (list guile-gnutls) ;required by (web client)
                  (use-modules (ice-9 textual-ports)
                               (web client))
                  (let ((token (string-trim-both
                                (call-with-input-file "/etc/duckdns/DOMAIN.token"
                        (query-template (string-append ""
                    (http-get (format #f query-template token))))))
         #:user "nobody"))

The job then needs to be added to the list of mcron jobs for your system, using something like:

  (cons* (service mcron-service-type
             (jobs (list duckdns-job ...))))