How to change dynamic IP address (changip.com) using Node-RED?

#1

Hi,

I would like to create a Node-RED flow which allows me to change my dynamic IP address (changeip.com) to a new IP address as my ISP is regularly changing the WAN IP address of my router.

I already figure out how to automatically detect that my routers WAN IP address changed and I can easily manually change the IP address by entering the following URL in a browser:

http://nic.changeip.com/nic/update?hostname=bo....onmypc.org&myip=81.241.37.232

After I have entered the above in the browser, I get a screen in which I need to enter my changeip.com user name and password.

The following page explains the actual API of changeip.com:
https://www.changeip.com/accounts/knowledgebase.php?action=displayarticle&id=34

So I only need to know how to create a Node-RED flow that allows me to change my dynamic IP address to another specific IP address in a secure way.

Jan

0 Likes

#2

In managed to get it working by using a http request node and by specifying the user name and the password in the URL (see screenshot above). For this I had to use the query string parameters "u=" and "p=" for the user name and the password.

Note that It didn't work when I selected "Use Basic Authentication" and specified the user name and the password there instead of in the URL. In that case I got following 401 HTTP response:

{"_msgid":"4587d1ac.fea2","topic":"","payload":"401 Access Denied - Failed to Authenticate (0)","statusCode":401,"headers":{"date":"Sun, 21 Oct 2018 12:08:35 GMT","server":"Apache","x-powered-by":"PHP/5.6.36","www-authenticate":"basic realm="DDNS"","cache-control":"max-age=2592000","expires":"Tue, 20 Nov 2018 12:08:35 GMT","vary":"Accept-Encoding","content-length":"46","connection":"close","content-type":"text/plain;charset=UTF-8","x-node-red-request-node":"eb2849ee"},"responseUrl":"https://nic.changeip.com/nic/update?hostname=boXXXXXX.onmypc.org&myip=87.67.108.163"}

0 Likes

#3

Why?

I am certainly not the expert to be asking, or answering your question, but... why do you want to change your dynamic IP address? And which IP? The one assigned by your ISP or your local network? The logic escapes me.

0 Likes

#4

Hi Jan,

Glad you got it working. For completeness I use duckdns.org which also works fine. And when the update of my new IP address on duckdns fails for some reason, I send a mail to myself with the new IP address. Then at least I can logon via the new URL in my mail. My wife always says 'trust is good, but control is better ...' :face_with_raised_eyebrow:

Thanks for sharing the solution !
Bart

0 Likes

#5

I don't want to change it - it is my ISP that is reassigning from time to time a new WAN IP address to my internet router. If this happens I have to change also the IP address that is linked to my hostname that is managed by changeip.com.

0 Likes

#6

Thanks for the comment.

I have configured it a bit similar but instead of sending a mail it will post a comment in my slack workspace that specifies the success or failure of the change.

0 Likes

#7

The whole idea of a dynamic DNS is that you don't need to care what your public IP is. If your ISP changes your public IP, your Dynamic DNS host should pick up your new IP fairly quickly.

1 Like

#8

Hi Steve,

It is not really working like that. A DDNS host provider (like changeip.com) will not detect and automatically change the IP address of my public hostname if my ISP has changed the IP address of my WAN router.

Some WAN routers support Dynamic DNS (or at least some DDNS host providers) which means that you can configure those routers so that they will automatically detect if their WAN IP address changes and in that case they will request the DDNS host provider to change the IP address of your public hostname. The problem in my case that my WAN router doesn't work with the changeip.com DDNS provider so therefore I did this in a Node-Red flow.

1 Like

#9

changeip.com appear to have an api to update your IP address. See https://www.changeip.com/accounts/knowledgebase.php?action=displayarticle&id=34

Could you -

  • within node-RED, check your IP address say every 10 minutes.
  • on first run, save your IP to context, thereafter compare your IP address with context.
  • if it's the same - do nothing
  • if it's different (IP has changed), then send your new IP to the changeip.com api to update your new IP by using a http request node.
  • save your new IP address back to context.

Paul

1 Like

#10

And while you are at it, why not update your LAN DNS with the new address so that you can use the same IP name internally as externally. I'm now doing that at home so that I can use Let's Encrypt certificates. In my case, my WAN IP address is fixed thanks to an enlightened ISP but all I have to do is update the hosts file on my router. I use the router for LAN DNS.

0 Likes

#11

Hi Paul,
Thanks for your advice that is exactly what I am doing.
Jan.

0 Likes

#12

Hi Julian,

I admit that your comment is not fully clear to me.
I am also not using "Let's Encrypt certificates" so I do not immediately see the benefit.

Jan.

0 Likes

#13

Sorry, maybe that was a side-track - all I was saying was that if you set things up right, you can use the same IP name whether you are on the internal network or an external one.

0 Likes

#14

Evening Jan,

Last week a new contribution node-red-contrib-ip has been published on NPM. I use that one now in my flow to get the current WAN ip address. This way my flow looks a bit cleaner ...

Bart

2 Likes

#15

You could also feed the ip address through a RBE node, it will only get sent if it changes.

0 Likes

#16

This page has a download of a script (Rinker.sh) that will update your ip for you. Download that, fill in your user name and so on, and run it every 5 or 10 minutes using cron (or from node-red if you prefer) and that should do it.

https://www.changeip.com/accounts/downloads.php?action=displaycat&catid=4

1 Like