Elastix DNS Cache

Overview

 

Quite a few people have requested a DNS Server,  Cache or "proxy" for Elastix. There are some benefits to this request, but primarily the requests are due to a problem with SIP based communications in the event of loss of the Internet.

 

This issue manifests itself on Elastix (Asterisk) based systems which use SIP based Phones, and SIP based VoIP provider. This issue (as far as I am aware) does not occur where IAX based Phones are being used, and/or IAX based VoIP Providers are being used. The issue is that when the SIP VoIP provider becomes unavailable (usually due to no Internet either through a router (dead or otherwise) or Internet comms fault, the SIP Phones become inoperable for internal calls or for calls to go out via a PSTN system which makes the failover capability useless.

 

I have not come across this issue on many, many systems that I have implemented but this comes down to the fact that almost all Elastix systems we implement are on well constructed business style networks. Whilst I have spent a little time on it, I have not gone into depth on what the primary cause is. Part of the issue comes down to network design, setup of DNS entries, router ability to proxy address even with Internet down. This last one, I believe is probably the primary cause, with the DNS request becoming hung on routers that appear to lose DNS proxy capability because the WAN side of the router is down.

 

Now having said that, I believe the problem can be corrected fundamentally in the Asterisk SIP code, based on the fact that  IAX does not suffer the same fault, however, as others have mentioned it, it might be impossible to get Asterisk to fix the "design feature" as it only affects a small percentage and I am sure many would argue that it is a network issue that needs to be resolved.

 

I have seen this issue on a friends system (home office), so I know the problem exists for some, so to this end this tutorial will teach you simply how to implement DNSMASQ which is essentially a DNS Cache. It caches the DNS information, so for those small periods that your Internet is down, it should correctly return the DNS Address to Asterisk, which should stop the issue with SIP hanging. In effect we are replacing the DNS Proxy capability of your router and placing it on the Elastix Server providing some reliability.

 

DNSMASQ is not a DNS Server like Bind or similar. There is no requirement for a system that complex to be placed on an Elastix Server, and unless you know what you are doing, it is not recommended that you even try.  DNSMASQ provides the same response as the one we would expect.

 

Please note at this point, the DNSMASQ function has been tested reasonably well, and confirmed that it say what it says it is going to do. However as I do not have a system in front of me that has the SIP based hang issue, I am relying on those users to confirm that DNSMASQ resolves the issue. In any case, if you want to try it, there is very little you can do wrong.

 

 

Installing DNSMASQ

 

Either at the console or via SSH (Putty), after login type the following command

 

yum install dnsmasq

 

Wait for this to complete and show no errors

 

Now using your favourite editor in Linux (I use Nano) edit the following file

 

/etc/dnsmasq.conf

 

In dnsmasq.conf, you will find a line similar to the following diagram

 

dnsmasqconf1.png

 

Add this on the next line

 

server=172.22.22.5 ( naturally replace this with your router or ISP DNS Server)

 

So it now looks like the following diagram

 

dnsmasqconf2.png

 

 

Now access the System/Network Tab in Elastix and make the following changes

 

elastixdnssetup.png

 

 

  1. The host remains as it is
  2. The Gateway remains as it is
  3. The primary DNS changes to 127.0.0.1 which is the local machine (Elastix Server).
  4. The secondary DNS is clear

 

The reason for the secondary DNS to be empty is that if you add an address of your router or ISP in here, it will hang again, which is not what we want it  to do. It checks DNSMASQ for a DNS address, doesn't get one, and falls straight through which is what we want.

 

REBOOT YOUR ELASTIX BOX (this is necessary).

 

Now before you get going, make sure that you can ping a domain name from the Linux command prompt. e.g. I used one I have used before and also a site I have not pinged before. If it resolves the name then it is working.

 

Seriously, let me know if it resolves the SIP Hanging issue, otherwise I will get back to drawing board to sort it out.