LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Looking for bash script which can change the DNS records for down hosts (https://www.linuxquestions.org/questions/linux-server-73/looking-for-bash-script-which-can-change-the-dns-records-for-down-hosts-4175440749/)

manya 12-10-2012 12:15 AM

Looking for bash script which can change the DNS records for down hosts
 
Hi Folks,

I am planning to build DNS system with low TTL and which will also monitor the health of servers or port so if the hosts goes down it will automatically removes that entry from zone and have the traffic diverted from down hosts

Say zone is example.com and have two webservers

www.1.example.com = 30.30.30.30 and www.2.example.com 40.40.40.40.
DNS will monitor the health of both the servers on port 80 through regex and if connection fails it will remove the entry from zone. I am planning to keep the TTL value to something around 180 so that in about 3 mins new entry should be populated and thus reduce the downtime.

heinblöd 12-10-2012 03:55 AM

For me it doesn't sound logical.
Simply removing a zone from a DNS Server will not stop incoming traffic for this domain. It would have it's effect maybe after 72 hours, when the records are updated everywhere.

Except in a local network, where you got one dns server and all clients connect only to that one, but for the Internet it sounds pointless to me.

If you only want to stop filling your apache logs with errors, you could maybe have an apache instance for every domain and shut down Apache, if pinging fails

TenTenths 12-10-2012 04:19 AM

Quote:

Originally Posted by heinblöd (Post 4846081)
For me it doesn't sound logical.

It's fully logical assuming you know how DNS is supposed to work.

Quote:

Originally Posted by heinblöd (Post 4846081)
It would have it's effect maybe after 72 hours, when the records are updated everywhere.

Again, if you know how DNS is supposed to work you'll know that DNS servers should only cache results for the TTL. It's only when cache DNS servers don't actually respect the appropriate standards that it becomes a problem.

We pretty much do what manya wants to do except that we use an external company (www.tzo.com) to do it rather than in-house scripts.

heinblöd 12-10-2012 06:31 AM

Quote:

Originally Posted by TenTenths (Post 4846095)
It's fully logical assuming you know how DNS is supposed to work.

Well I guess I know, how DNS is supposed to work and I'am aware that DynDns etc are working like this.

But what I mean is that, assuming you know how DNS is supposed to work :), the caching name servers will still request the Zone files from the authoritive Server, until they recieve an update saying, the zone is not hosted there anylonger,

So it fail fail for the request to
Quote:

have the traffic diverted from down hosts
And in this case I just think that it takes quite a long time until the requests won't result in a (NXDOMAIN) anymore


All times are GMT -5. The time now is 08:20 AM.