navilg / godaddy-ddns Goto Github PK
View Code? Open in Web Editor NEWDynamic DNS with GoDaddy
Home Page: https://medium.com/linux-shots
License: MIT License
Dynamic DNS with GoDaddy
Home Page: https://medium.com/linux-shots
License: MIT License
If TTL value in properties file doesn't match the existing value, update it.
Script fails with below error when internet connection is not working fine.
godaddyDDNS.sh: line 47: [: too many arguments
Build arm arch container image for raspberry pi and MacOS support.
fixed
Not an issue with godaddy-ddns as such, but in case anyone else tries using the API service for the first time like me, it seems GoDaddy changed the requirements of usage a couple of days ago so that you have to have 50 domains registered with them to be able to use the API.
You'll see this error in the godaddy-ddns logs:
Authenticated user is not allowed access, StatusCode: 403, StatusCode: 1
Replace existing (below) method with source command to read variables from godaddyDDNS.properties file.
domain="$(grep -i domain "$properties_file"|tail -1|awk -F "=" '{print $2}')" #domain name
name="$(grep -i name "$properties_file"|tail -1|awk -F "=" '{print $2}')" #sub-domain
ttl="$(grep -i ttl "$properties_file"|tail -1|awk -F "=" '{print $2}')"
key="$(grep -i key "$properties_file"|tail -1|awk -F "=" '{print $2}')" #godaddy developer key
secret="$(grep -i secret "$properties_file"|tail -1|awk -F "=" '{print $2}')" #godaddy developer secret
When the script is run for first time:
e.g.
To setup for first time interactivley, User can run:
sudo bash godaddy-ddns.sh setup
To update the properties, User can run:
sudo bash godaddy-ddns.sh update
When cronjob runs this script, It should run as:
sudo bash godaddy-ddns.sh nointeraction
When user or cron runs the script, without any argument or any other argument which do not have any action associated to it. It should print a message with help page and example and exit the script.
Add an option to sync the record by running
godaddyddns sync
Option to reduce polling time to 1 minute
When server reboots, below error is pops in docker container
ERROR 2022/03/27 12:03:00 myserver.navratangupta.in Failed to add record. Error: record already exist, StatusCode: 1
This script is fantastic as-is, but there are a couple of "minor" enhancements I would love to see included for my own use case. Let me preface these by saying that I am very unfamiliar with Linux and scripting in that environment so I'm not sure how challenging these suggestions would be. I am a developer/programmer working in a predominantly Windows environment but have finally started trying to get into using the Linux command line so, while I understand the concepts of what the script is doing, I don't know the syntax for how to make the types of changes I'm asking about.
First, I actually have two domains registered with GoDaddy and would like to have a subdomain on each that points to the dynamic IP address from my ISP. What I've done to achieve this is to make renamed copies of the three main files (the .sh
, .properties
, and .log
files) and replaced the references to the name in the script with the new name, then run the new .sh
file to create a separate cron job. This works as expected - both of my domains are having the A
record updated on a 15-minute schedule - but it seems a bit more of a hassle than it could be. Also, if I ever need/want to add another subdomain (and new A
record), as it stands, I'm going to have to repeat this process of copy/rename (and possibly verify permissions) -> edit -> run (to create a new cron job) for the new subdomain.
What I believe would be a "better" experience would be if the script were capable of accepting multiple domain names and/or subdomain names from the .properties
file. For example, making the keys for domain
and name
accept a pipe-delimited (or some other delimiter) list of names that the script would parse out to an array, then check each item.
domain=example.com|mydomain.net
name=linuxshots|subdomain2
ttl=3600
key=godaddyAPIKey
secret=godaddyAPIsecret
I do see the potential for some confusion with this if the two lists do not have the same number of elements or the user enters them in a different order, but that could simply be a "troubleshooting" step for the end-user if the script doesn't work as expected for them.
Additionally, if only a single name
value is provided, the script could basically assume that the same subdomain should be checked on each of the domains, and vice-versa. For example:
domain=example.com
with name=linuxshots|subdomain2
tries to update the A
records for both linuxshots
and subdomain2
on the same domain (example.com
)domain=example.com|mydomain.net
with name=linuxshots
tries to update an A
record for linuxshots
on both domains (example.com
and mydomain.net
)Also, I realize that most "additional" subdomains pointing to the same IP address on the same domain could likely simply be created as CNAME
records with GoDaddy. But there may be certain use-case scenarios where an A
record would be more appropriate (such as targets for MX
or NS
records), so I still think it'd be a good option to include.
Alternately - and I admit that I'm not sure if this would even work for this kind of script in a Linux environment - creating property groups could make it "easier" to customize the configuration according to very specific requirements:
[godaddy]
key=godaddyAPIKey
secret=godaddyAPIsecret
[example.com]
name=linuxshots|subdomain2
ttl=3600
[mydomain.net]
name=subdomain2
ttl=3600
Such a setup (if possible) would allow for granular control over each domain and its associated subdomain(s), as well as allow for possible future "expansion" or additional settings. I suppose it would be possible to even allow the user to specify different GoDaddy API credentials for each domain, but that's probably just me over-thinking the process.
I could definitely see this being incorporated with #9 on the issue list to dynamically build/modify the .properties
file as a part of both the proposed setup
and update
operations. Perhaps this is an interactive thing:
Enter the domain name:> example.com
Enter the name of the A record:> linuxshots
Enter the TTL (Time To Live):> 3600
> GoDaddy DDNS task added for linuxshots.example.com
Please make sure the A record exists for your domain by logging into your GoDaddy account
The other thing I would personally like to see is some historical logging of any time the script actually makes changes. This is probably totally unnecessary and just my own desire to keep records of everything, but it would be nice to see something like this in the log file:
DNS Name: linuxshots.example.com
Last Check: Sat 26 Feb 2022 12:15:02 AM CST
DNS IP: 98.123.123.123
TTL: 3600
Status: OK
[2022-01-12 09:45:05] [SUCCESS] Public IP changed (45.147.147.147 -> 68.21.21.21) A Record for linuxshots successfully updated with TTL 3600
[2022-02-25 22:30:02] [SUCCESS] Public IP changed (68.21.21.21 -> 98.123.123.123) A Record for linuxshots successfully updated with TTL 3600
Of course, if the first UX suggestion were implemented, this log would provide the details for each of the domains and their subdomains:
Last Check: Sat 26 Feb 2022 12:15:02 AM CST
DNS IP: 98.123.123.123
Domain: example.com
-------
DNS Name: linuxshots.example.com
TTL: 3600
Status: OK
DNS Name: subdomain2.example.com
TTL: 3600
Status: OK
Domain: mydomain.net
-------
DNS Name: subdomain2.mydomain.net
TTL: 3600
Status: OK
[2022-01-12 09:45:05] [INFO] Public IP changed (45.147.147.147 -> 68.21.21.21)
[2022-01-12 09:45:05] [SUCCESS] A Record for linuxshots successfully updated to 68.21.21.21 with TTL 3600
[2022-01-12 09:45:05] [SUCCESS] A Record for subdomain2 successfully updated to 68.21.21.21 with TTL 3600
[2022-01-12 09:45:05] [SUCCESS] A Record for subdomain2 successfully updated to 68.21.21.21 with TTL 3600
[2022-02-25 22:30:02] [INFO] Public IP changed (68.21.21.21 -> 98.123.123.123)
[2022-02-25 22:30:02] [SUCCESS] A Record for linuxshots successfully updated to 98.123.123.123 with TTL 3600
[2022-02-25 22:30:02] [SUCCESS] A Record for subdomain2 successfully updated to 98.123.123.123 with TTL 3600
[2022-02-25 22:30:02] [SUCCESS] A Record for subdomain2 successfully updated to 98.123.123.123 with TTL 3600
Obviously, this gets a lot more complicated very quickly, but it would be an extremely nice (in my opinion) enhancement to see a detailed history of the actions the script has actually taken. One option I could see to help avoid "clutter" in the log file might be to have separate logs for each domain.
In my "vision", this historical log would, of course, also include documentation of any warnings, failures, or other errors the script encounters. A few potential errors/warnings I imagine a user encountering:
[2022-01-02 12:01:16] [ERROR] The supplied GoDaddy API credentials are invalid
[2022-01-02 12:05:38] [ERROR] No A record exists for linuxshots in the example.com domain - please create an A record pointing to 45.147.147.147
[2022-01-03 05:22:54] [ERROR] No Internet connection available
[2022-01-03 07:18:21] [WARNING] Could not retrieve current public IP address from ipinfo.io - assuming no changes are required
As I said before, this script is functionally fantastic and seems to work exactly as I need it to. The above suggestions are simply a matter of UX choices and preferences that I believe would provide even more utility and "user-friendliness" to an already great script. Please let me know if you have questions or need clarification on anything I've presented here. Thank you again for this as it's made my life a whole lot easier.
Hi,
When i am checking the log i am getting:
"Status: NOT OK - Request"
How can i troubleshoot that ?
Thank you
I have the following error after nearly 12-24h of running the Dockercontainers.
I've configured and running 4 containers with default options like you've described it. I've used the same API key 4 times with different domains. For the first few hours everything was working perfectly and without any problems but after 12h the problems started with the following logentrys:
ERROR 2022/04/11 22:47:51 DOMAIN Failed to update record. Error: One or more of the given records is invalid, StatusCode: 422
Configuration already exist. Syncing the record
I've stopped the containers now and tried to update the domains with another script and that was working well so its not the API limit or a problem with the key/secret.
My machine is a debian 10 with a fresh dockerinstallation. No other containers or something else is running on the machine.
Hope you can help =)
curl ipinfo.io/json
{
"status": 429,
"error": {
"title": "Rate limit exceeded",
"message": "You've hit the daily limit for the unauthenticated API. Create an API access token by signing up to get 50k req/month."
}
}
Find a way to find public IP from local source instead of relying on an external service which may go do down and affect the godaddy-ddns
Hello.
Trying to run this container via portainer on a Rapsberrypi3 and, in the logs, I am getting: exec /app/container-entrypoint.sh: exec format error
I using the image: linuxshots/godaddy-ddns:arm64v8-linux-1.0.0.
Does this runs on a Raspberrypi3 or only Raspberrypi4?
Any ideas?
Thank you
Hello, sorry for my bad English, it is not my first language.
Before I start I want to clarify that I am a complete newbie to networks and the Internet, so I may actually be asking a stupid question.
I am using your script to have a ddns with godaddy. It works very well, thanks for creating something so good.
But I have a question, could I use this script to update the IP of my main domain?
I mean, using the syntax that is in the instructions I can create a subdomain that obtains the IP address if it changes. But could godaddy-ddns be applied for the current main record?
I'm thinking something like:
docker run --name @.example.com -d --restart unless-stopped --env GD_NAME=@ --env GD_DOMAIN=example.com --env GD_TTL=1200 --env GD_KEY=key-value-from-godaddy-developer-console --env GD_SECRET=secret-key-value-from-godaddy-developer-console linuxshots/godaddy-ddns:latest
According to godaddy the "@" is used to add an A record in the main domain. I was wondering if I could apply the same in godaddy-ddns.
When user runs, sudo bash godaddy-ddns.sh interactive
it should display menu like below and perform actions based on user input.
Main Menu
0. Exit
1. Run
2. Fresh setup
3. Update properties
4. Remove/Uninstall
Enter your choice (0-4) >>
Keep the log file size in check so that it doesn't cost more storage. For E.g. Limit log size not more than 5 MB or 10MB.
Currently we need to add cron jobs manually using crontab.
We can automate this process in shell script itself for more easy installation
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.