Metadata-Version: 2.4
Name: unifi-dns-sync
Version: 1.0.1
Summary: Automatically sync DNS A records on Unifi controllers
Home-page: https://github.com/cswitenky/unifi-dns-sync
Author: cswitenky
Maintainer: cswitenky
License: MIT
Project-URL: Homepage, https://github.com/cswitenky/unifi-dns-sync
Project-URL: Repository, https://github.com/cswitenky/unifi-dns-sync.git
Project-URL: Issues, https://github.com/cswitenky/unifi-dns-sync/issues
Keywords: unifi,dns,networking,automation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Internet :: Name Service (DNS)
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.28.0
Requires-Dist: urllib3>=1.26.0
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# Unifi DNS Synchronization Tool

Automatically sync DNS A records on Unifi controllers via CLI.

![Demo Screenshot](https://raw.githubusercontent.com/cswitenky/unifi-dns-sync/main/demo.png)

## Installation

From PyPI (recommended)

```bash
python -m pip install --upgrade pip
python -m pip install unifi-dns-sync
```

From source (development)

```bash
git clone https://github.com/cswitenky/unifi-dns-sync.git
cd unifi-dns-sync
python -m pip install -e .
```

## Usage

Create a JSON file with your hostnames and IPs:

```json
[
  { "service1.example.com": "10.0.10.1" },
  { "service2.example.com": "10.0.20.1" },
  "service3.example.com"
]
```

Run the sync:

```bash
python -m unifi_dns_sync config/dns-records.json \
  --controller https://10.0.0.1 \
  --username admin \
  --password your-password \
  --target-ip 10.0.0.123 # Optional for hostnames without explicit IPs
```

## Options

- `--dry-run` - Show what would change without making changes
- `--show-diff` - Show detailed diff of changes
- `--target-ip` - Default IP for hostnames without explicit IPs (default: 10.0.0.123)
- `--verbose` - Enable debug logging

## JSON Formats

**Simple hostnames** (uses `--target-ip`):

```json
["host1.com", "host2.com"]
```

**Hostname to IP mapping**:

```json
[{ "host1.com": "1.2.3.4" }, { "host2.com": "5.6.7.8" }]
```

**Explicit format**:

```json
[{ "hostname": "host1.com", "ip": "1.2.3.4" }, { "hostname": "host2.com" }]
```

## License

MIT License
