Skip to main content

A CLI tool for obtaining and updating your public IP address at dynamic DNS providers.

Project description

Poetry Ruff codecov Pipeline PyPI - Version

Dynamic DNS Update Client

A CLI tool for obtaining and updating your public IP address at dynamic DNS providers.

Instead of supporting any dynamic DNS provider in the world (like almost any other tool I found), this CLI tool aims to be a flexible tool kit. Using it, you can put together a solution which works for 90% of the use cases.

It obtains the current IP address by different means depending on the --ip-address-provider option:

  • openwrt_network on an OpenWRT device by calling OpenWRT specific functions, specify network with --ip-network
  • interface physical network interface to look for the public IP address, specify interface with --ip-interface
  • by calling one of the following IP address services using an HTTP GET request:

It then updates the obtained IP address with another HTTP GET request at the dynamic DNS provider using the specified URL parameters and authentication method.

You can run it from any machine that has a Python v3 environment available. This also includes OpenWRT routers where you can install a Python interpreter and this package (see instructions below).

This CLI tool plays together nicely with my other project simple-dynamic-dns-aws. If you happen to have an AWS account, you can put together your own Dyn DNS server almost for free.

Install

Anywhere

$ pip install dynamic-dns-update-client 

OpenWRT

For installing and running dynamic-dns-update-client on your OpenWRT router, you need to install the Python v3 interpreter and pip. You need the packages python3-light and python3-pip. These can be installed via Luci web interface or via SSH:

$ opkg install python3-light python3-pip

You can install dynamic-dns-update-client using pip now:

$ pip install dynamic-dns-update-client

Usage

$ dynamic-dns-update-client --help
Usage: dynamic-dns-update-client [OPTIONS] DYNAMIC_DNS_PROVIDER_URL

  Dynamic DNS Update Client.

  A CLI tool for obtaining and updating your public IP address at dynamic DNS
  providers.

  It obtains the current IP address by different means depending on the --ip-
  address-provider option:

  - openwrt_network: on an OpenWRT device by calling OpenWRT specific
  functions,   specify network with --ip-network

  - interface: physical network interface to look for the public IP address,
  specify interface with --ip-interface

  - by calling one of the following IP address services using an HTTP GET
  request:

      - ipify: https://www.ipify.org/

      - dyndns: https://help.dyn.com/remote-access-api/checkip-tool/

  It then updates the obtained IP address with another HTTP GET request at the
  dynamic DNS provider using the specified URL parameters and authentication
  method.

Options:
  --ip-address-provider [openwrt_network|interface|ipify|dyndns]
                                  Type of IP address provider. Default: ipify
  --ipv6                          Obtain IP V6 address from IP address
                                  provider.
  --ip-network TEXT               OpenWRT network to look for the public IP
                                  address. Default: wan
  --ip-interface TEXT             Physical interface to look for the public IP
                                  address. Default: eth0
  --ip-address-url-parameter-name TEXT
                                  Name of the URL parameter for IP address. It
                                  will be appended to the dynamic DNS provider
                                  URL.  [required]
  --url-parameter URL_PARAMETER   URL parameter which will be appended to the
                                  dynamic DNS provider URL. You can specify
                                  this option multiple times. Format:
                                  param=value
  --basic-auth-username TEXT      Basic Auth username for calling dynamic DNS
                                  provider URL.
  --basic-auth-password TEXT      Basic Auth password for calling dynamic DNS
                                  provider URL.
  --dry-run                       Instead of calling the dynamic DNS provider,
                                  print the URL which would have been called.
  --help                          Show this message and exit.

Example

Use the --dry-run option to check if your CLI call is correct:

$ dynamic-dns-update-client https://example.com --ip-address-url-parameter-name ip-address --url-parameter domain=example.com --url-parameter api-token=nd4u33huruffbn --dry-run
Current IP address: 82.4.110.122
Dry run, no changes will be made.
Dynamic DNS provider URL: https://example.com/?ip-address=82.4.110.122&domain=example.com&api-token=nd4u33huruffbn

dynamic-dns-update-client will call that URL effectively when you scratch that --dry-run option after your test.

Environment Variables

If you are concerned about security and don't want to use the CLI options for secrets or passwords, you can also use the following environment variables to provide these values to Dynamic DNS Update Client.

DYNAMIC_DNS_UPDATE_CLIENT_IP_ADDRESS_PROVIDER=ipify
DYNAMIC_DNS_UPDATE_CLIENT_IPV6=0
DYNAMIC_DNS_UPDATE_CLIENT_IP_NETWORK=wan
DYNAMIC_DNS_UPDATE_CLIENT_IP_INTERFACE=eth0
DYNAMIC_DNS_UPDATE_CLIENT_IP_ADDRESS_URL_PARAMETER_NAME=ip
DYNAMIC_DNS_UPDATE_CLIENT_URL_PARAMETER="foo=bar boom=bang cat=mouse"
DYNAMIC_DNS_UPDATE_CLIENT_BASIC_AUTH_USERNAME=username
DYNAMIC_DNS_UPDATE_CLIENT_BASIC_AUTH_PASSWORD=password
DYNAMIC_DNS_UPDATE_CLIENT_DRY_RUN=0

Known issues

For obtaining the IP address with --ip-address-provider interface the ifcfg library is used. On OpenWRT this library errors out. Please use --ip-address-provider openwrt_network on your OpenWRT router until this is fixed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dynamic_dns_update_client-0.4.1.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dynamic_dns_update_client-0.4.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file dynamic_dns_update_client-0.4.1.tar.gz.

File metadata

  • Download URL: dynamic_dns_update_client-0.4.1.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-1015-azure

File hashes

Hashes for dynamic_dns_update_client-0.4.1.tar.gz
Algorithm Hash digest
SHA256 0d56343ef056a4e15ac74290a338149dd38ef6eb6e991979b494eb4866e4b995
MD5 7db9efed4bbf4ca51510ea4ef45e9e37
BLAKE2b-256 1f0b8257bdf2ccb7de967f99310215b5019be1e3795141fa4135cb85981a0aed

See more details on using hashes here.

File details

Details for the file dynamic_dns_update_client-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for dynamic_dns_update_client-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b908489e23b370faa495c0bb81992f327ffe25da0c19c15a768e1b9b8924cd2
MD5 0edd24298e7d543471fea8da8beb8786
BLAKE2b-256 98c041b30d3440e7ac440339cacabf4a95aee1a84d4d7e0827e7e34a1dcecba4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page