Auto edit DNS Records if primary server goes dead

I like the idea of the "Roundrobin DNS Records" but I would like to see a new feature added that will auto update the dns if 1 server goes down and then once the primary is back again it would change the DNS A records back. Of course it would need to edit more then just the " A IP"

I thought about heartbeat but that's way beyond what I am willing to take on and learn. I figured if you can write the "Roundrobin DNS Records" code you could add "Fallover DNS Records" to do what I would like.

It would be a lot simple then trying to setup heartbeat.



That's pretty much what the roundrobin DNS records feature does already though - you can define a list of systems whose IPs will be included in A records, but only if they are up or meet some other conditions..

No it doesn't... it adds whatever record type to use round robin dns.

Lets say I have the following servers added to cloudmin...

master1 with IP and www uses
master2 with IP and www uses

Now master1 is the primary and master2 is the fallover encase master1 fails.

This isn't supported with "Roundrobin DNS Records" at all, In fact it isn't even close. It adds the IP the Cloudmin server is using. So say I add a the WWW record now the WWW record has the wrong IP because roundrobin is using the IP associated with webmin server; EG and

What I was proposing with "Fallover DNS Records" is if ping *and* port 80 fails after X checks it edits "" and replaces the the A record for www with or whatever IP I set it to.

Now once ping *and port 80 responds "Fallover DNS Records" will reverse that and replace the A record for www with

Round Robin is just that -- its a load balancer and it doesn't work the way I described unless I don't understand what Round Robin dns is which I highly doubt.

Ok, so your systems actually have multiple IPs and you are trying to use the non-primary IP in DNS?

Correct but that isn't the whole problem with "Roundrobin DNS Records"

It does actually what round robin does and that is make www answer on 2 IP's IN A IN A

That's round robin dns -- it sorta acts like a load balancer and it's what I was asking for.

I wanted my version "Fallover DNS Records" to only edit the A records for IN A IN A

And change those records to the IP user provides for it in the settings.

So in your failover case, if both the machines on .3 and .5 were up, which one would go into the DNS record? Would it always prefer .3 unless it was down, in which case .5 would be used?

.3 the primary would be preferred unless port 80 AND ping failed after X checks then .5 would takew over and the only records changed would be for www and

OK, so it sounds like what you want is for Cloudmin to have an option to only create an IP record for the IP of the first usable system, rather than all of them. I will include that in the next release..

It will work if you can define the fallover IP and record to modify

The next release will also let you enter arbitrary IP addresses to check and include in the roundrobin, which could be systems that aren't even managed by Cloudmin if you like..

I still don't see where to put the IP to use if the selected server is down.

The screen for round robin is really confusing and there is no help files or hints for any settings.

I don't how to explain this feature request any better.

I know how much you hate talking to people but I think its time for a actual phone call to get our thoughts in sync on this one.

What you want is to create a roundrobin with the primary and backup IPs in the "Systems with IP addresses" field, and "Address records to include" set to 1.

A little clunky, but this feature wasn't really designed for DNS-based single-IP failovers like this.

See for more docs.

Not working like I expected then IP addresses 0 up, 2 down (DNS error : No usable systems found - leaving DNS record un-changed)

I guess I need to figure out how to use heartbeat to do this.

Ya it's definitely not working the way I explained.

I made it fail and the secondary IP I used was but it still forced the IP for master2 instead of what I told it to use.

I can't believe something this simple is so hard to understand.

If IP goes dead I want IP to be used... you just can't get that any simpler. I don't care about if the hostname for the server is up all I care is if the website for a domain is..

If you click on the roundrobin and open the section that shows the status of the hosts, what does it say as the reason why the hosts were rejected?

That wasn't a issue after I figured it out...

The issue was that it was still wanting to use the physical IP for master2( and NOT the IP( assigned to the website that I told it it to use in IP section.

EG if the main IP failed it did this... IN A

and that is wrong, it should be

I have given up trying to explain this (not rocket science) and instead looked for another option like a script which I did find and works exactly how I was trying to explain here. Maybe if you look at the code you will see what I have been trying to get cloudmin to accomplish.

$Main = "";
$Backup = "";

//path to named folder
$Path = '/etc/bind/';
//domains to check through for the IP replacement
$Domains = '';
//A record to look for
$Arecord = '';
//check for a command line parameter
if ($argc >= 2) {
        if ($argv[1] == 'up') {

                //set the A record back to main
                echo "up \n";
                $FindIT = $Backup;
                $SetIT = $Main;
        } elseif ($argv[1] == 'down') {
                //set the A record to backup

                echo "down \n";
                $FindIT = $Main;
                $SetIT = $Backup;
        $lineNum = 0;
        echo $Path . $Domains . '.hosts' . "\n";

        //open the domain file
        $lines = file($Path . $Domains . '.hosts');
        //open the file for editing
        $fp=fopen($Path . $Domains . '.hosts',"w+");
        foreach ($lines as $line_num => $line) {
                $lineNum = $lineNum + 1;

                //increment sequence #
//              if ($lineNum == 3) {
//                      $line = $line + 1;
//                      $line = "                       " . $line . "\n";
//              }
                $pos = 0;
                //loop through each line checking if it matches $FindIT exactly with the
                //last values at the end of the line.  If found, change it to $SetIT
                $pos = strpos('test' . $line, $FindIT);
                if ($pos > 0) {
                        //we found the line
                        $line = str_replace($FindIT, $SetIT, $line);

                //write each line as we loop through
        //reload bind service
        exec('dnstouch /etc/bind/');
        exec('rndc reload');

I see the bug that causes this - will fix in the next release. Let me know if you'd like a patch ..

Sure you can send a rpm and I'll test it.

Opps I meant deb package.. sorry

Ok that works but that php script works much better as it replaces all the same IP's with the fallover IP and visa-versa when the primary server is back online.

Maybe you guys should post that script on the wiki err docs. Man I miss that wiki... I really liked the idea I could maintain my own docs.