Skip to main content

octodns-routeros

RouterOS DHCP lease source for octoDNS.

Fetches active (bound) DHCP leases from a MikroTik RouterOS device via the REST API and provides them as DNS A/AAAA records.

Router-side prerequisites

Enable the HTTPS API service on the router:

/ip service enable www-ssl

Or for plain HTTP (not recommended):

/ip service enable www

Installation

pip install octodns-routeros

Configuration

providers:
  routeros:
    class: octodns_routeros.RouterOSSource
    # Required: router hostname/IP
    host: 192.0.2.1
    # Required: API user
    user: admin
    # Password: literal value, or env/<var> to pull from environment
    password: env/ROS_PASS

    # Optional settings (shown with defaults)
    scheme: https
    verify: false
    port: null           # null = default port (443/80)
    timeout: 10
    ttl: 300            # TTL for generated records

    # How to handle multiple leases sharing a host name:
    # fail | pick | disambiguate
    resolution_strategy: fail
    # Which lease wins under pick/disambiguate:
    # oldest | most_recent | lowest_ip | highest_ip
    preference: oldest

zones:
  dyn.example.com.:
    sources:
      - routeros
    targets:
      - your_dns_provider

Alternatively, the password can be specified directly:

    password: your_secret_password

Or via a ROS_PASS environment variable in the shell running octoDNS.

How it works

On each sync cycle, the source:

  1. Queries the RouterOS REST API for bound DHCP leases from both /rest/ip/dhcp-server/lease (IPv4) and /rest/ipv6/dhcp-server/lease (IPv6).

  2. Each bound lease with a non-empty host-name creates a record:

    • Only the first label of the host name is used as the record name (e.g. laptop.lan becomes laptop).
    • IPv4 addresses produce A records.
    • IPv6 addresses produce AAAA records.
  3. A missing IPv6 endpoint (HTTP 404) is silently ignored — safe for RouterOS 6.x or routers without IPv6 DHCP.

  4. If multiple leases map to the same record name, they are resolved via resolution_strategy (default fail):

    • fail: raise an error listing the conflicting leases
    • pick: publish a single record, selecting the lease that ranks first by preference
    • disambiguate: publish a record for every lease — the winner keeps the plain name, the rest get a MAC-address suffix (e.g. laptop-aa-bb-cc-dd-ee-ff)

    preference determines the winner (default oldest):

    • oldest: longest-held lease (largest age) — most stable, avoids a name switching between devices
    • most_recent: most recently seen (smallest last-seen)
    • lowest_ip / highest_ip: numerically lowest/highest address

Development

# Install dependencies
uv sync --group dev

# Run tests
uv run pytest

Releasing

  1. Update CHANGELOG.md — move the new version's entry from - unreleased to a date and add any missing items.
  2. Commit and push to main.
  3. Tag the release: git tag 0.2.0 && git push --tags.

CI will run the test suite, build the package, create a GitLab Release with the changelog section, and publish to PyPI.

Changes

See CHANGELOG.md for release history.

License

MIT

Metadata

Release files for octodns-routeros 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for octodns-routeros 0.4.0
File Size Uploaded Provenance Actions
octodns_routeros-0.4.0.tar.gz 71.5 kB Without provenance Details for octodns_routeros-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for octodns-routeros 0.4.0
File Interpreter ABI Platform Actions
octodns_routeros-0.4.0-py3-none-any.whl Python 3 none any Details for octodns_routeros-0.4.0-py3-none-any.whl

Total release size: 80.7 kB

Release files / octodns_routeros-0.4.0.tar.gz

Download URL octodns_routeros-0.4.0.tar.gz
Size 71.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9452844572b6560899ee487ce707715785fc1c7d716b8b1b0dff368fba330033
BLAKE2b-256 checksum
How to use checksums
0bb85a64cc1d0cb87b07f8967b8fbf3bdfcf35e382776deb26a674bb553c70c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.7

Release files / octodns_routeros-0.4.0-py3-none-any.whl

Download URL octodns_routeros-0.4.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a1fa1b3a747427b3cf2ef92e6df69df7088bb551ef3951a1d278e57ce175a1d
BLAKE2b-256 checksum
How to use checksums
204dda5ad98050fd5e33c50a074dc006a5fc6fc161ee5bd19caefa25b47b0a68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.7

Security for octodns-routeros 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page