Metadata-Version: 2.4
Name: netcup-dns
Version: 0.5.0
Summary: Set DNS records to public IP using netcup DNS API
Project-URL: Repository, https://codeberg.org/privacy1st/netcup-dns
Project-URL: Issues, https://codeberg.org/privacy1st/netcup-dns/issues
Project-URL: DOWNLOAD, https://codeberg.org/privacy1st/netcup-dns/archive/main.tar.gz
Author-email: Daniel Langbein <daniel@systemli.org>
License-Expression: MIT
License-File: LICENSE
Keywords: dyndns,netcup-dns
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: Unix
Classifier: Topic :: Internet :: Name Service (DNS)
Requires-Python: >=3.13
Requires-Dist: nc-dnsapi
Requires-Dist: requests
Description-Content-Type: text/markdown

# 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/):

```shell
pip install netcup-dns
```

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

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

Build and install on Arch Linux:

```shell
make
```

Build and install with `pip`:

```shell
make install-pip
```

## Configuration

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

There is an [example configuration](cfg/example.json).

## 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. 

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

## TODOs

Alternatives:

- https://codeberg.org/anschu/netcup-dyndns-client
- https://codeberg.org/linxside/ncdapi (archived)

API backend:

- Currently: nc-dnsapi
  - https://pypi.org/project/nc-dnsapi/
  - https://github.com/nbuchwitz/nc_dnsapi
- Alternatives:
  - https://github.com/johndoe31415/dnssync_nc

Alternative external IP detection:

```python
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()))
```
