Giter VIP home page Giter VIP logo

vultr-dynamic-dns's Introduction

Vultr Dynamic DNS

Dynamically update IP addresses in Vultr DNS without services like No-IP

If you want to map an A record in Vultr's DNS to a local machine but you aren't paying your ISP for a static IP, use this service to automatically update an IP change in Vultr. Since Vultr does not provide a Dynamic DNS service, programs like ddclient cannot be used, so this is an alternative. It uses Vultr's API and simple GET and POST requests, and uses an API key opposed to your username and password.

Basic Setup

  • First, set up your domain to use Vultr's DNS service if you haven't already. You will need access to your domain registrar to point your domain to Vultr's nameservers. After this is done you can set up your DNS records in Vultr, so add all of the necessary A, CNAME, TXT, MX, etc. records you need and then continue with this guide.
  • Once you have set up Vultr DNS, go to Vultr DNS and click on your domain name in this list. Note which records you would like to be dynamically updated. Only A records are supported by this utility. If you have multiple A records that you want updated to the same IP address, change them to CNAMEs and point them to one A record. This will simplify things for you in the long run and is considered the proper way to configure DNS.
  • Install Python 3
  • Clone this repository: git clone https://github.com/andyjsmith/Vultr-Dynamic-DNS.git vultrddns && cd vultrddns
  • Fill out config.json. Copy sample from config.json.example, you will need to generate an API key in Vultr. It is important to click "Allow All IPv4". See See Configuration for more info.
  • Test the script and configuration: python3 ddns.py. If there aren't any errors, the setup is complete.

Known Issues

  • If you get an error stating your IP is not authorized, you must go to your Vultr account, click on your name in the top right and click API. You can then go to Access Control and click "Allow All IPv4" and/or "Allow All IPv6", or manually specify your IP. This step is important as IPv6 may not be enabled by default but some computers will communicate on IPv6 by default.

Automation

After completing the basic setup, it is important to set up a recurring task as the script does not do this by default.

Linux & Mac OSX

  • Find the full path of the ddns.py file using realpath ddns.py
  • Run crontab -e
  • Add the following line to the end of the file, adding in the real path to the ddns.py file: */30 * * * * cd [full path to ddns.py] && python3 ddns.py > /dev/null 2>&1. This will run the script every 30 minutes and redirect all of its output to /dev/null.
  • Save and quit out of the text editor. The crontab file will automatically be install and your IP will now automatically be updated.

Windows

Create a task in Task Scheduler to run every 30 minutes. Follow the Microsoft guide for basic task creation.

  • Open task scheduler and click "Create Task..."
  • Give it a name and create a new trigger
  • Click "Daily" and under Advanced Settings click to repeat the task every 30 minutes and change "for a duration of" to "Indefinitely"
  • Add a new action to start a program and browse to your python executable. Add the ddns.py script as an argument.

Configuration

{
	// Generate an API key under the Account->API page.
	// Under "Access Control", you need to click "Allow All IPv4".
	// This is required because if you had a static IP you wanted to allow,
	// you would not be using this DDNS service in the first place.
	"api_key": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",

	// The domain you want to use listed under the DNS tab in Vultr.
	"domain": "example.com",

	// Add the name(s) of the dynamic record(s) you want to update.
	// Vultr only uses the subdomain for this list.
	// For example, abc.example.com would be "abc".
	// If you want to use the base domain, use an empty string "".
	"dynamic_records": [
		"",
		"test",
		"123"
	]
}

vultr-dynamic-dns's People

Contributors

akdor1154 avatar andyjsmith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vultr-dynamic-dns's Issues

Default configration doesn't change AAAA records

The configuration is like this:
"api_key": "3***********Q",
"domain": "mydomain.com",
"dynamic_records": [
"sub1"
]

And there are existing A & AAAA records of sub1.mydomain.com. If I delete the A record and attempt to change, it would say "No addresses changed", which I don't think the configuration can't do.

Script Hangs

Hello,

After updating from commit no # ead29d9 , (which is about 8 commits back) my terminal seems to hang with no error. I have to press Ctrl+C to stop the script.

This is what I get :

File "ddns.py", line 25, in
ipv6 = requests.get("https://api6.ipify.org").text
File "/usr/lib/python3/dist-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 376, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 996, in _validate_conn
conn.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 314, in connect
conn = self._new_conn()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 159, in _new_conn
conn = connection.create_connection(
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 74, in create_connection
sock.connect(sa)
KeyboardInterrupt

Anyone else facing the same issue ?

OS: Ubuntu 20.04 Server (LTS)
Python version : 3.8.10

Thanks

PS: I have updated my config.json after updating this. The old version in the above-mentioned commit works correctly

Updating Multiple Domain Example

Hello,

Can you please include an example config.json for updating multiple domains ?

eg.
Domain1.com -> a1.domain.com & b1.domain.com
Domain2.com -> a2.domain2.com

Thanks

Got error

Line 8 error when I execute this script... help?

IPv6 query no longer working

The A record for api6.ipify.org url no longer exists. It looks like one has to use api64.ipify.org instead now.

Force usage of ipv4 or ipv6 source ip address

When accessing vultr apis, make it configurable to force the requests module to stick to either ipv4 or ipv6 based on what user might have configured in their account settings.

On my desktop running windows, the request uses ipv4 address. On my raspberry pi running debian buster, python3 decides to use ipv6 as the source ip address in the tcp packet it sends out to vultr servers, and the vultr api rejects the request as the ip is not allowed.

The following snippet works for me

import requests.packages.urllib3.util.connection as urllib3_cn

def allowed_gai_family():
    family = socket.AF_INET    # force IPv4
    return family

Not working anymore?

So it seems like it doesn't work anymore.

When I edit the dns-entry with let's say 88.55.44.55 and run python3 ddns.py I get:

 vultrddns » python3 ddns.py
IP has changed since last checking.
Old IP on Vultr: 88.55.44.55, current server IP: <MY_LOCAL_IP>
Changed home (<number>) to <MY_LOCAL_IP> in <DOMAIN>

However when I log into the account and check my dns-entries its still 88.55.44.55 (and pinging home.<DOMAIN> still returns 88.55.44.55).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.