Dynamic IP changed overnight - how do I automate updating my Public IP across all servers?

OS type and version Rocky Linux 9.2
Virtualmin version 7.7 Pro

My Virtualmin server is on a home setup with Comcast as an ISP, and a non-static IP address. For the most part, it doesn’t change, but on rare occasions it does. The server is not a critical business service, but it does host a bunch of home-based utilities (family photos, personal Nextcloud, etc.) that I would like to keep available as smoothly / as much as possible.

At the moment, I have 9 primary domains (and multiple sub-domains) on my Virtualmin setup. 8 of them host DNS locally on the Virtualmin server, the 9th is solely for the purposes of serving up namservers for the other 8. That one domain (aiskondns.net) is registered at NameCheap, and a script on my Virtualmin server runs once an hour to update the IP of @, *, ns1, and ns2 for that domain on NameCheap’s end.

Last night, Comcast changed my home’s IP. I was able to figure out what happened pretty quickly, and Aiskondns.com was working, so I was able to get into my Virtualmin console and update the Public IPs of my sites, bringing them back online.

The challenge I am looking to solve is this - how do I automate the updating of the Public IP of the 8 domains hosted on my Virtualmin server, when the IP changes?

I did a search and found this thread, but it looks like it ended / closed without a documented resolution. Was this feature ever added to Virtualmin?


You could simply call the external script which executes:

virtualmin modify-all-ips --default-old-ip --detect-new-ip

… in Addresses and Networking ⇾ Dynamic IP Update page by setting Dynamic DNS service option to Run external script …

Please give it a try and let me know if that works for you.

Also, I would suggest spending a few extra bucks to get a static IP. I personally have been doing it for the past decade, and it was never more than $5/month. I think this would be a better approach, if you want your home server to be always available.

The problem with this solution is that some ISPs will not give Non-Business accounts a static IP. Some won’t even allow a 2nd dynamic IP.
Where I live, a business account will run from about 150 to 250 per month. My current ISP does allow a 2nd dynamic IP but even it comes with issues. The modem will not allow a hairpin turn so the only way I can access my home server (from home) is through a VPN.

I run a script on my server that checks the IP address and if it changes the script changes the IP at my Registrar. I haven’t had any issues with the dynamic IP other than it makes using a mail server way harder (My ISP blocks port 25) and occasionally Webmin will tell me that the IP has changed and require me to do something to change the internal IP. Since it hasn’t changed in quite some time I can’t actually remember what I had to do but it was pretty simple. I am only running a couple of virtual servers on that system so updating the IPs is relatively easy.
I should really look at the external script you mentioned and see if I could just incorporate it into my current script. To be honest I haven’t looked at this for a few years so it might be time to refresh my memory.

If I had to pay $150 to $250 a month extra to run a server at home, I think I would just get a hosted server and let someone else look after the equipment for me.

Luckily, I never had a problem with home ISP, neither getting static IP nor port 25 being closed to send mail.

I run a script on my server that checks the IP address and if it changes the script changes the IP at my Registrar.

I think it would be better to let Virtualmin handle it using Addresses and Networking ⇾ Dynamic IP Update page.

Thank you, I think I will.

I just went to check out my setup and realized that when my server crashed last year and I had to rebuild it from scratch I never put the script back in place. Luckily the dynamic IP the server is using hasn’t changed since then.

I’m glad I read this thread or I wouldn’t have realized this until my ip changed on me and would have been struggling to figure out why it wasn’t working any more.

Thanks again.

1 Like

Looks like I will have to rewrite my python script to alter ENOM’s Host records as the External script?

Can you direct me to any place that has some info on writing the scripts for this purpose? I’m not exactly sure what each of the options in the dialog does and what they require either. Is there more info available for these?

I assume it will work something like my original script which was just run using a cron job and updated the ENOM records whenever it noted a change of IP except this has the added benefit of updating all the Virtual Server IPs?

Can I do something like this, for the external script, in order to use my python script to change my registrar’s Host records?


cd /path/to/python/script/directory
python ChangeHostRecords.py $1 $2

Are the command line parameters $1 = New IP and $2 = Hostname?

Thanks for any clarification.

Thank you for this - this is what I was looking for. I normally would have expected the update to be a part of the GUI, but running the script works.

I set this up last night, and this morning, I have a flood of emails with the same error in it:

An attempt to update the dynamic IP for [webhost.aiskon.net](http://webhost.aiskon.net/) to
with Run external script .. failed: /root/dynamicip-update.sh 76\.117\.62\.249
ns1\.aiskon\.net failed : The old and new IP addresses are the same!

Update all virtual servers with a new IP address.

virtualmin modify-all-ips [--old-ip address | --default-old-ip]
[--new-ip address | --detect-new-ip]Sent by Virtualmin at: [https://webhost.aiskon.net:10000](https://webhost.aiskon.net:10000/)

It looks like it’s running the script, even when the IP hasn’t changed?

Regarding home IPs - where I am located (New Jersey, USA) my town has only one broadband ISP - Comcast. They are a monopoly, and they know it, so they charge whatever they want and do the bare minimum for service and support. Other towns have more options and competition, but not mine, unfortunately.

FCC should do a better job, as supporting (not doing anything is form of support) anti-competitive practices will have a negative effect on the people living in the region and future technology pace of growth.

I’d say, the practice itself, should be seen as an infringement on First Amendment rights that indirectly limits the free speech and access to information and/or ability to share information.

The law is designed to promote competition and prevent abusive business practices, such as Comcast. I think you could file a class action lawsuit against Comcast. The challenge would be in convincing others their rights are being violated, as we all may tend to overlook (unfortunately) the issue until it’s too late.

While I agree with you, they have much more money than I do, and simply put, it’s collusion with other ISPs. I’ve already spoken with the local mayor about this, and there’s not much to do because other ISPs don’t want to move in and compete, when they have their own monopolies they can milk.

This is off topic, but here’s how it works in a lot of areas: The major Cable Providers (Comcast, Optimum, Spectrum, etc.) collude and decide who will cover what areas. When they do this, they then approach the local governments and offer free service to government buildings, in exchange for exclusive access to operate in the area. Of course, the local town governments are going to accept free high-speed internet & Cable TV, so they sign the agreement. None of the other major players try to compete, and the smaller ones can’t afford to.

When Verizon came into the game with Fiber / FiOS, they were able to get around this because they were a telephone company that carried Internet & TV on the side (As opposed to a Cable TV company, that offered Internet and Telephone). However, Verizon only wants to provide service to areas where they will make a high profit - they are mandated to serve a minimum of New Jersey’s population, which they have, but they pick and choose what neighborhoods to light up with their fiber where they will make the most money. FiOS is available two blocks down the street from me, but not in my neighborhood, because it’s not as wealthy a town. We’ve been asking when Verizon will come to our town for years now (since 2008) - at first, it was “Soon,” then it became “We are focusing on other technologies, and no longer rolling out service to new areas.”

Capitalism sucks. Short of mandating that other ISPs come in to compete, there’s no incentive for them to do so in most areas, although that’s beginning to change in parts of Rural NJ where there is less profit for the Big Players to defend.

How much will it cost you to put this on a VPS in your neck of the woods ?

$30 / month for a quality host, and minimal storage. I had been on SiteGround before this, but I own my own TrueNAS at home, which has 12+ TB of storage. That’s the main appeal for me - all my photos, NextCloud files, etc. that take up a ton of space can live on my NAS at home, and I’m only paying for the Virtualmin Pro license instead of a hosting fee.

how much space do you truly want or need to host ?

It’s surprising that governments can still take money from companies. Governments should get their money from taxes so they focus on what people need, not what companies want through lobbying.

Although that’s beginning to change in parts of Rural NJ where there is less profit for the Big Players to defend.


What is actually in your script?
What are the available command line parameters?

The script is a single line:

virtualmin modify-all-ips --default-old-ip --detect-new-ip

My concern is that it seems to be calling the script every 5 minutes, not just when my public IP changes.

It shouldn’t be a problem.

Where did you find information on this?
I am planning on using this to modify the Virtual Server IPs on the server but also send the new IP to my Registrar to update my Host records for DNS.
I expect that I can run the initial script and have it call my python script which will update the Host records. The initial script can pass on the command line parameters (mainly new IP) to the python script.
I expect that the $1 is the new IP and $2 is the Host Name as entered in the dialog but I am not sure. I was also wondering if the Username and Password in the dialog are also available as command parameters.
It would be nice to know where this information is so I can read up on it rather than trying to work in the dark.

The second link in this discussion:

Also, each sub command has a documentation with explanations, e.g.:

virtualmin help modify-all-ips