An open API service indexing awesome lists of open source software.

https://github.com/connerwill/dynu-dns-update

DYNU Dynamic DNS Update Script
https://github.com/connerwill/dynu-dns-update

Last synced: 3 months ago
JSON representation

DYNU Dynamic DNS Update Script

Awesome Lists containing this project

README

          

# dynu-dns-update

A bash script to automatically update your
[Dynu](https://www.dynu.com) Dynamic DNS hostname with your current public IP.
Supports IPv4 and optionally IPv6.
Designed to run safely from cron with state tracking.

## Table of Contents

- [dynu-dns-update](#dynu-dns-update)
- [Table of Contents](#table-of-contents)
- [Features](#features)
- [Setup](#setup)
- [Installation](#installation)
- [Install Script](#install-script)
- [Manual installation](#manual-installation)
- [Cron Setup](#cron-setup)
- [Logging](#logging)
- [Logrotate](#logrotate)
- [Links](#links)

## Features

- Updates IPv4 and IPv6 addresses *(skips IPv6 if unavailable)*
- Avoids conflicts with environment variables *(`DYNU_*` prefix)*
- Cron-friendly with lockfile to prevent overlapping runs
- Stores last known IP in a separate state file for comparison

## Setup

### Installation

#### Install Script

Run the `install.sh` script

```bash
./install.sh
```

#### Manual installation

Place the script in a location accessible to the user running cron. Common options

- `/usr/local/bin/dynu-ddns-update.sh` *(system-wide)*
- `~/bin/dynu-ddns-update.sh` *(user-specific)*

```bash
sudo install -vDm755 "dynu-ddns-update.sh" "/usr/local/bin/dynu-ddns-update.sh"
```

Run once manually to generate the configuration file

```bash
/usr/local/bin/dynu-ddns-update.sh
```

This will create a configuration file at `~/.config/dynu-ddns-update/dynu_ddns.conf`

Edit the configuration file

```conf
DYNU_USERNAME="your_username_here"
DYNU_PASSWORD="your_password_here"
DYNU_HOSTNAME="example.dynu.com"
USE_SSL=true
LOG_FILE="${XDG_STATE_HOME:-${HOME}/.local/state}/dynu-ddns/dynu-ddns-update.log"
STATE_FILE="/var/tmp/dynu_ddns_state"
```

### Cron Setup

Open your crontab for editing

```bash
crontab -e
```

Add the following line to run the updater every 10 minutes

```console
*/10 * * * * /usr/local/bin/dynu_ddns.sh
```

### Logging

By default, `dynu-ddns-update.sh` creates and logs to log file:

- `${XDG_STATE_HOME:-${HOME}/.local/state}/dynu-ddns/dynu-ddns-update.log`

The log file path can be changed in the configuration file: `LOG_FILE`

> [!NOTE]
> If you are not root, choose a log file under your home directory,
> e.g. `~/dynu_ddns.log`. Make sure the path is writable.

#### Logrotate

Optional: Use `logrotate` to prevent logs from growing indefinitely

```bash
sudoedit /etc/logrotate.d/dynu-ddns-update
```

```console
/home/*/.local/state/dynu-ddns/dynu-ddns-update.log {
weekly
rotate 4
compress
missingok
notifempty
create 644 user user
}
```

> [!NOTE]
> Change the path to the log file if you changed the default log path

> [!NOTE]
> Replace 'user user' with the username which is running the script.

## Links

- [Dynu IP Update Protocol docs](https://www.dynu.com/DynamicDNS/IP-Update-Protocol)