[SOLVED] Custom DNS - Updating Single Webserver IP for multiple domains

Hello.

I have been using MIAB for over a year and has been working great!

I am changing hosting providers and the static IP for my Web server will change. I have over 100 domains hosted on one IP. Any way I can make an update in the backend to find and replace the old IP with the new IP? The UI seems to only have the option to either add or delete. I would hate to do this individually (deleting each domain and adding each domain back in).

Can anyone provide any advice in updating the IP for each domain without deleting and adding the domain back in individually?

Thank you in advance!

You can do this with MIAB’s API, I have a bunch of scripts on my github that can show you how to use the API. One of them also manages DNS specifically too:

My GitHub:

The DNS Project:


-AND-


You will need to figure out a way to do this yourself, but I hope these can point you in the right direction. Of course, if you want to PM me, I can work with you directly (as some potentially sensitive infos might be passed back and forth) to help out and then we can post the final solution here.

Hi @lifehacker nice to see you back again.

May I ask two questions of you please? Do you have secondary DNS set up for your MiaB ? And are you really running DNS for 100+ domains on MiaB? If so, and you are open to it I would like to offer you some feedback. Please let me know.

Thank you murgero.

I will review your scripts and see if I can decipher in making use of them.

Much appreciated!

1 Like

Hi alento,

Do you have secondary DNS set up for your MiaB ?

No I do not. In my current environment, I am running the server as a virtual private server (VPS) and can spin up another image within a few seconds should the image fail. By trade, I am more of an System Administrator (SA) than an Applications Administrator (AA).

And are you really running DNS for 100+ domains on MiaB?

Yes I am. I am always open to feedback. Please do share!

I am grateful you assisting last time, so I know any feedback that you may offer will further assist me.

Thank you alento!

Hi murgero,

Would you know where the domains’ IPs are stored? Are they stored in an SQLite DB? I was going to try and use grep/sed to find and replace the IPs in the zone directory and tested with one domain before doing so, no success (updated the zone (IPs, serial#, restarted dns service)).

Am I making this more difficult than this is supposed to be?

I am still reviewing your scripts.

Thank you!

Custom entries are stored in /home/user-data/dns/custom.yaml

Yeah, unfortunately … everything for custom DNS is stored in that file and automagically is applied to where it needs to be. Mine only has A records so I cannot comment on the formatting of the entries, but some trial and error should answer that for you. :slight_smile:

Don’t worry - I traveled down the same path and failed too. Search ‘yaml custom dns’ here and you’ll see.

What I cannot specifically answer is how you’d update nsd after editing that file, likely there is a restart command … worst case … reboot? @murgero

Hi alento,

Thank you for your tip!

I was able to make a successful IP change by touching the following files and replacing the current IP with the one I wanted:
sudo nano /home/user-data/dns/custom.yaml
sudo nano /etc/nsd/zones/example.com.txt
sudo nano /etc/nsd/zones/example.com.txt.signed
sudo service nsd restart

I updated the serial number by 1 (furthest digit on the right) when I edited /etc/nsd/zones/example.com.txt, I do not know if this is necessary or not, but I recall when I was studying DNS back in the day, when updating a zone the serial number had to be changed for the change to be recognized and updated, but that was like 10-15 years ago!

Once I secure an IP with the new cloud server and have restored my the files, I will go through the steps again in updating the IP and will provide the steps, if different.

!* BACKUP the mailinabox domain *!
These hold the configuration to the DNS and mail. After running the sed commands bellow, these two files will have to be overwritten by the original (backup). Otherwise the IP of the host will be the same as the Web server and will not resolve.

example.com is the main domain that Main in A Box uses, as in box.example.com
/etc/nsd/zones/example.com.txt
/etc/nsd/zones/example.com.txt.signed

*If you are copying and pasting the above, make sure to correct the single quote, as I noticed the single quote gets an HTML conversion.

I will be using the following sed command to replace all the current IPs with the new IP:
old IP = 1.2.3.4
new IP = 5.6.7.8
sed -i ‘s/1.2.3.4$/5.6.7.8/g’ *.txt
sed -i ‘s/1.2.3.4$/5.6.7.8/g’ *.yaml
sed -i ‘s/1.2.3.4$/5.6.7.8/g’ *.signed

Question: If the topic closes in 7 days after the last reply, is updating a closed topic still possible? If not, can you advise in how I can provide an update on a closed topic?

I did the math; if updating the IPs via the UI (deleting all the domains and adding them back in) took 15 seconds per domain, that is 4 domains a minute. The manual task would have taken me 32 minutes to do the update for all 128 domains. If everything goes as planned, the automated update should take no more than 5 minutes, at most!

I will be making a backup of all the files prior to any attempt in updating the files.

Thank you again for your assistance!!!

UPDATED: 07/19/2019
I was able to update all the domains with expected results! I updated the instructions, as I discovered a few discrepancies when implementing the above instructions when including the main domain that Mail In A Box uses.

Editing the file, then restarting mailinabox services should be enough but a reboot would work too.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.