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.
- 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.
- 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.
After completing the basic setup, it is important to set up a recurring task as the script does not do this by default.
- 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.
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.
{
// 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"
]
}