Project

do-dyndns

0.0
Low commit activity in last 3 years
No release in over a year
Finds the wan IPv4 address of the server it's running on and updates the corresponding DNS records on digital ocean.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.1
~> 13.0.6
~> 3.11

Runtime

~> 3.18.0
 Project Readme

DO-Dyndns

Automatically update DNS records on DigitalOcean to the current IP of the machine running the script.

Finds the wan IPv4 address of the server it's running on and updates the corresponding DNS records on digital ocean.

This is useful if you don't have a static ip from your ISP.

Installation

$ gem install do-dyndns

Gemfile

gem 'do-dyndns', '~> 0.3.0'

require 'do_dydns'

Usage

require 'do_dyndns'

updater = DoDyndns::Updater.new(
  token: '...',
  domains: {
    'example.com' => [
      'subdomain'
    ]
  },
  logger: Logger.new($stdout)
)

updater.update_ips # Updates 'subdomain.example.com' to your current IPv4 address

CLI Configuration

When runninng do_dyndns, the updater reads a configuration file:

Configuration is located at: ~/.config/do-dyndns.yml

if no config file is found, do-dyndns will create one and open it with your $EDITOR

:token: your_digital_ocean_token_here
:domains:
  example-domain1.com:
    - example-subdomain1

CLI Usage

$ do-dyndns 
I, [2019-03-26T14:39:20.643564 #11387]  INFO -- : Started IP check
I, [2019-03-26T14:39:20.720905 #11387]  INFO -- : Current WAN IP: **.**.**.**
I, [2019-03-26T14:39:21.977426 #11387]  INFO -- : IPs Match for ***.***.***

Automation

Following are examples on how to run this script periodically to update your VPS with the machine's current IP

Cron:

Check every 15 minutes:

*/15 * * * * /path/to/do-dyndns

Launchctl

Check every 15 minutes:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>com.pixelfaucet.do-dyndns</string>

    <key>WorkingDirectory</key>
    <string>~/</string>

    <key>UserName</key>
    <string>nobody</string>

    <key>ProgramArguments</key>
    <array>
      <string>~/.rvm/wrappers/ruby-2.6.5@do-dyndns</string>
      <string>do-dyndns</string>
    </array>

    <key>StartInterval</key>
    <integer>900</integer>
  </dict>
</plist>