Skip to main content

Set DNS records to public IP using netcup DNS API

Project description

netcup-dns

Set DNS A/AAAA records to your current external IP address using the netcup DNS API.

Security

The public IP is determined through external services. If these are malicious, they could reply with an attackers IP. If we update our DNS entries to that IP, the attacker could generate valid HTTPS certificates, etc.

To remedy this, we ensure that at least 3 different services are queried and that all report the same external IP.

Installation

Install release from PyPI (https://pypi.org/project/netcup-dns/):

pip install netcup-dns

Install release from TestPyPI (https://test.pypi.org/project/netcup-dns/):

pip install -i https://test.pypi.org/simple/ netcup-dns

Build and install on Arch Linux:

make

Build and install with pip:

make install-pip

Configuration

For each netcup customer, create a .json configuration file inside /etc/netcup-dpns.

There is an example configuration.

Usage

usage: netcup-dns [-h] [--config CFG_FILES [CFG_FILES ...]]
                  [--cache-directory CACHE_DIR]
                  [--cache-validity-seconds CACHE_VALIDITY_SECONDS]

Update DNS A/AAAA records with your current external IP address using the
netcup DNS API.

options:
  -h, --help            show this help message and exit
  --config CFG_FILES [CFG_FILES ...]
                        Path to one or more .json configuration files.
  --cache-directory CACHE_DIR
                        Path to cache directory. Retrieved and updated DNS
                        records are cached there.
  --cache-validity-seconds CACHE_VALIDITY_SECONDS
                        Value in seconds for how long cached DNS records are
                        valid. Set to `0` to disable caching.

Examples

Both examples use the same effective configuration. In the second case, personal information such as the API password is stored in a separate configuration file.

netcup-dns --config ./cfg/example.json
netcup-dns --config ./cfg/public.json ./cfg/secret.json

TODOs

Alternatives:

API backend:

Alternative external IP detection:

def external_ip_upnp():
    """
    https://stackoverflow.com/a/41385033

    Didn't work for me. Even after double checking fritz.box settings:

    fritz.box > Heimnetz > Netzwerk > Statusinformationen über UPnP übertragen
    """
    import miniupnpc
    u = miniupnpc.UPnP()
    u.discoverdelay = 1000
    u.discover()
    u.selectigd()
    print('external ip address: {}'.format(u.externalipaddress()))

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

netcup_dns-0.5.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

netcup_dns-0.5.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file netcup_dns-0.5.0.tar.gz.

File metadata

  • Download URL: netcup_dns-0.5.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for netcup_dns-0.5.0.tar.gz
Algorithm Hash digest
SHA256 8e81b5610f6ffd7ad383c683e35bf58a3c3abf0ab04af3c92193f4124d467b7a
MD5 375d94fceab7bbd352fd591e36270a12
BLAKE2b-256 8e49f23168a56aaf6cd976c950d009ba4cf5ab0d371499652733a881072bfd66

See more details on using hashes here.

File details

Details for the file netcup_dns-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: netcup_dns-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for netcup_dns-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f8bdb338c57221a16f6f257890c91885cf4ef90cc6a482cbe2cdd039584ad5e
MD5 aa7f67ee2c9f6252f9b1cffa91d18d39
BLAKE2b-256 30e615d7e99ec14764d8ce7ad8991f545c9a6c9cd3239ef81841e445613f4720

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