Developing a perl program to update my IP address Developing a perl program...

Topic: Developing a perl program to update my IP address

Post developing a perl program to update my IP address
by richwicks on 17 July 2018

I've written a simple perl program to run as a cron job every 20 minutes and there's something I can't figure out.

I'm basically using wget to request an update using the IP update protocol found here:

https://www.dynu.com/en-US/DynamicDNS/IP-Update-Protocol

The script basically does this:

wget --tries=1 --timeout=10 -P /tmp "https://api.dynu.com/nic/update?hostname=dynu.net&alias=MYDOMAINNAME&password=MD5SUM_PASSWORD"

(wget is a simple program that allows you to basically download web pages, like a very primitive web browser)

And this works perfectly fine, on my machine, at my desk, at home - where my IP address hasn't changed in a few months.

However, if I do the same thing on another machine, with another IP address, I always get this following response:

badauth

Why am I getting a badauth? Why does this only work on my machine at home? Why am I doing this? I'm trying to invalidate the IP address by updating it just to test the script.

This happens if I enter that URL in a web-browser too. Why won't it update the IP address? I certainly have the correct domain name, and password.

The script checks to see if the IP address may have changed, by accessing a web browser file, so it actually only connects to https://api.dynu.com ONLY IF, this file is inaccessible (i.e. the IP address has changed) - so I should be not be seen as being abuse. My goal is to update ONLY when the IP address has changed to reduce traffic to api.dynu.com.

Also, if you want, I'll give you the perl script, but it's dependent on you running a webserver, and having /home/${USER}/public_html accessible as it's currently written, and you having a valid TLS certificate.

Reply with quote | Report
Post Re: developing a perl program to update my IP address
by anthonywebuser on 17 July 2018

The update URL should be corrected to the below:

https://api.dynu.com/nic/update?hostname=yourname.dynu.net&password=MD5SUM_PASSWORD


Reply with quote | Report
Post Re: developing a perl program to update my IP address
by anthonywebuser on 17 July 2018

https://api.dynu.com/nic/update?hostname=sth.dynu.net&alias=MYDOMAINNAME&password=MD5SUM_PASSWORD if you have a subdomain for sth.dynu.net and the subdomain is MYDOMAINNAME.sth.dynu.net.

Reply with quote | Report
Post Re: developing a perl program to update my IP address
by richwicks on 18 July 2018

Ohhhhh, I think I got it. I didn't quite understand what a subdomain was. I wonder why it works on the computer that has the current IP address/domain name set?

Let me see if I have time to fix it tomorrow, then I'll post a link to the perl script if anybody wants it. Um, I'll make it a BSD license, or whatever. May as well set it up to work with either HTTPS or HTTP, and not require /home/*/public_html to be present. Probably be useful to more people if I did that.

Reply with quote | Report
Post Re: Re: developing a perl program to update my IP address
by richwicks on 18 July 2018

anthonywebuser wrote:The update URL should be corrected to the below:

https://api.dynu.com/nic/update?hostname=yourname.dynu.net&password=MD5SUM_PASSWORD

Nope, that doesn't work either. I get badauth with:

wget "https://api.dynu.com/nic/update?hostname=[MY_DYNU_NAME]&password=2[MY_MDSUM_PASSWORD]"

Get the same result with a web browser as well. I'll reverse engineer one of the other cliens this weekend, on a virtual machine.

Reply with quote | Report
26 December 2024 19:05
Loading...