API Documentation

This part of the documentation should cover all the relevant interfaces of dyndnsc.

Main Interface

class dyndnsc.DynDnsClient(updater=None, detector=None, plugins=None, detect_interval=300)[source]

This class represents a client to the dynamic dns service.

Initialize.

Parameters

detect_interval – amount of time in seconds that can elapse between checks

check()[source]

Check if the detector changed and call sync() accordingly.

If the sleep time has elapsed, this method will see if the attached detector has had a state change and call sync() accordingly.

has_state_changed()[source]

Detect changes in offline detector and real DNS value.

Detect a change either in the offline detector or a difference between the real DNS value and what the online detector last got. This is efficient, since it only generates minimal dns traffic for online detectors and no traffic at all for offline detectors.

Return type

boolean

needs_check()[source]

Check if enough time has elapsed to perform a check().

If this time has elapsed, a state change check through has_state_changed() should be performed and eventually a sync().

Return type

boolean

needs_sync()[source]

Check if enough time has elapsed to perform a sync().

A call to sync() should be performed every now and then, no matter what has_state_changed() says. This is really just a safety thing to enforce consistency in case the state gets messed up.

Return type

boolean

sync()[source]

Synchronize the registered IP with the detected IP (if needed).

This can be expensive, mostly depending on the detector, but also because updating the dynamic ip in itself is costly. Therefore, this method should usually only be called on startup or when the state changes.

IP Updaters

Afraid

Functionality for interacting with a service compatible with https://freedns.afraid.org/.

Duckdns

Module containing the logic for updating DNS records using the duckdns protocol.

From the duckdns.org website:

https://{DOMAIN}/update?domains={DOMAINLIST}&token={TOKEN}&ip={IP}

where:

DOMAIN the service domain DOMAINLIST is either a single domain or a comma separated list of domains TOKEN is the API token for authentication/authorization IP is either the IP or blank for auto-detection

Dyndns2

Module providing functionality to interact with dyndns2 compatible services.

IP Detectors

Command

Module containing logic for command based detectors.

class dyndnsc.detector.command.IPDetector_Command(command='', *args, **kwargs)[source]

IPDetector to detect IP address executing shell command/script.

Initialize.

Parameters

command – string shell command that writes IP address to STDOUT

__init__(command='', *args, **kwargs)[source]

Initialize.

Parameters

command – string shell command that writes IP address to STDOUT

DNS WAN IP

Module containing logic for DNS WAN IP detection.

See also https://www.cyberciti.biz/faq/how-to-find-my-public-ip-address-from-command-line-on-a-linux/

class dyndnsc.detector.dnswanip.IPDetector_DnsWanIp(family=None, *args, **kwargs)[source]

Detect the internet visible IP address using publicly available DNS infrastructure.

Initialize.

Parameters

family – IP address family (default: ‘’ (ANY), also possible: ‘INET’, ‘INET6’)

__init__(family=None, *args, **kwargs)[source]

Initialize.

Parameters

family – IP address family (default: ‘’ (ANY), also possible: ‘INET’, ‘INET6’)

Interface

Module providing IP detection functionality based on netifaces.

class dyndnsc.detector.iface.IPDetector_Iface(iface=None, netmask=None, family=None, *args, **kwargs)[source]

IPDetector to detect an IP address assigned to a local interface.

This is roughly equivalent to using ifconfig or ipconfig.

Initialize.

Parameters
  • iface – name of interface

  • family – IP address family (default: INET, possible: INET6)

  • netmask – netmask to be matched if multiple IPs on interface (default: none (match all)”, example for teredo: “2001:0000::/32”)

__init__(iface=None, netmask=None, family=None, *args, **kwargs)[source]

Initialize.

Parameters
  • iface – name of interface

  • family – IP address family (default: INET, possible: INET6)

  • netmask – netmask to be matched if multiple IPs on interface (default: none (match all)”, example for teredo: “2001:0000::/32”)

Socket

Module containing logic for socket based detectors.

class dyndnsc.detector.socket_ip.IPDetector_Socket(family=None, *args, **kwargs)[source]

Detect IPs used by the system to communicate with outside world.

Initialize.

Parameters

family – IP address family (default: INET, possible: INET6)

__init__(family=None, *args, **kwargs)[source]

Initialize.

Parameters

family – IP address family (default: INET, possible: INET6)

Teredo

Module containing logic for teredo based detectors.

class dyndnsc.detector.teredo.IPDetector_Teredo(iface='tun0', netmask='2001:0000::/32', *args, **kwargs)[source]

IPDetector to detect a Teredo ipv6 address of a local interface.

Bits 0 to 31 of the ipv6 address are set to the Teredo prefix (normally 2001:0000::/32). This detector only checks the first 16 bits! See http://en.wikipedia.org/wiki/Teredo_tunneling for more information on Teredo.

Inherits IPDetector_Iface and sets default options only.

Initialize.

__init__(iface='tun0', netmask='2001:0000::/32', *args, **kwargs)[source]

Initialize.

Web check

Module containing logic for webcheck based detectors.

class dyndnsc.detector.webcheck.IPDetectorWebCheck(*args, **kwargs)[source]

Class to detect an IPv4 address as seen by an online web site.

Return parsable output containing the IP address.

Note

This detection mechanism requires ipv4 connectivity, otherwise it will simply not detect the IP address.

Initialize.

__init__(*args, **kwargs)[source]

Initialize.