# Does Asterisk uses secondary DNS server?

**URL:** <https://community.asterisk.org/t/does-asterisk-uses-secondary-dns-server/44323>\
**Category:** Asterisk General\
**Created:** [October 31, 2013, 1:25pm UTC](https://community.asterisk.org/t/does-asterisk-uses-secondary-dns-server/44323 "2013-10-31T13:25:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joao\_Marcelo](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@Joao\_Marcelo](https://community.asterisk.org/u/Joao_Marcelo)\
**Post date:** [October 31, 2013, 1:25pm UTC](https://community.asterisk.org/t/does-asterisk-uses-secondary-dns-server/44323/1 "2013-10-31T13:25:31Z")

</div>

Hello to all,

I know theres a problem regarding DNS on asterisk 1.8, and I know that the best way to resolve this it’s to install a DNS server on the same machine.

But, just for curiosity, assuming I don’t have a DNS server running on my \* server, if I put on my resolv.conf two or three DNS servers, like OpenDNS as my primary server, and a DNS server on my private network as secondary, \* will change to the secondary if my internet connection fails? Or \* just asks to the primary server?

There’s one time when all my SIP extensions and trunks became unavailable, but I was able to see by a nslookup and dig that the secondary DNS server was working.

Sorry about my english.

Best regards,

Joao Marcelo

---

<div class="post-metadata">

**Author:** ![david55](https://avatars.discourse-cdn.com/v4/letter/d/e19adc/32.png) [@david55](https://community.asterisk.org/u/david55)\
**Post date:** [October 31, 2013, 3:31pm UTC](https://community.asterisk.org/t/does-asterisk-uses-secondary-dns-server/44323/2 "2013-10-31T15:31:23Z")

</div>

Asterisk uses the standard BIND libraries so will support all the relevant options.

---

<div class="post-metadata">

**Author:** ![Joao\_Marcelo](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@Joao\_Marcelo](https://community.asterisk.org/u/Joao_Marcelo)\
**Post date:** [October 31, 2013, 5:13pm UTC](https://community.asterisk.org/t/does-asterisk-uses-secondary-dns-server/44323/3 "2013-10-31T17:13:19Z")

</div>

David, thanks for your help.

Sorry, but now I’m confused, because when all SIP phones become unavailable I see that \* wasn’t able to resolve names, but the O.S. (CentOS) was. So I had imagined that the \* was able to just use the primary DNS since it was unavailable at that time.

Unfortunatly I wasn’t at the lab when the problem happened, so I don’t have enought data to make a conclusion.

Best regards,

Joao Marcelo

---

<div class="post-metadata">

**Author:** ![ambiorixg12](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/ambiorixg12/32/1887_2.png) [@ambiorixg12](https://community.asterisk.org/u/ambiorixg12)\
**Post date:** [November 1, 2013, 2:03am UTC](https://community.asterisk.org/t/does-asterisk-uses-secondary-dns-server/44323/4 "2013-11-01T02:03:02Z")

</div>

If Asterisk loses internet connectivity or DNS, it stops responding to all SIP devices and trunks, and all extensions lose connectivity. This bug has apparently been around since Asterisk 1.4, persisted through 1.6, and remains in 1.8

This is the Matt Jordan response

[quote]  
Asterisk uses synchronous hostname resolution when it performs a DNS lookup for a peer’s hostname. As such, if chan\_sip has to resolve a hostname and the DNS server is not available, it can block the SIP do\_monitor thread until the request times out. How long the call blocks is dependent on the system Asterisk is running on, but can be more then several seconds. Obviously, if a large number of peers have to be resolved and Asterisk enters this state, it will be come unresponsive to SIP traffic on a local intranet.

At this time, there we are not planning to implement a DNS cache or asynchronous DNS lookups in Asterisk. The best solution is to instead install and configure a local DNS cache on the system that Asterisk runs on - there are many very good ones available in all major Linux distributions (and I would imagine the same to be true for other Operating Systems). In the case where internet connectivity is lost, this should prevent long hostname resolution times as Asterisk will still hit the local DNS cache, as opposed to timing out. In Asterisk versions 1.8 and greater, you may also find that using the dnsmgr feature (which periodically refreshes DNS information on a separate background thread) will alleviate chan\_sip from becoming unresponsive. Without having a local DNS cache, however, you may be simply trading which thread is blocked for a long period of time - so this is not a solution in and of itself.

If you can, please implement a local DNS cache on the system experiencing this behavior and retest, and let us know if this prevents the complete loss of SIP functionality when the DNS provider is no longer available (you’re obviously going to lose some SIP functionality[/quote]

My Suggestion  
A real and fast solution to this problem, change any domain name to his current IP address. on the SiP trunk configuration

[issues.asterisk.org/jira/browse/ASTERISK-18930](https://issues.asterisk.org/jira/browse/ASTERISK-18930)

---

<div class="post-metadata">

**Author:** ![david55](https://avatars.discourse-cdn.com/v4/letter/d/e19adc/32.png) [@david55](https://community.asterisk.org/u/david55)\
**Post date:** [November 1, 2013, 9:10am UTC](https://community.asterisk.org/t/does-asterisk-uses-secondary-dns-server/44323/5 "2013-11-01T09:10:18Z")

</div>

It uses synchronous resolution because that’s what the standard BIND libraries do.

---

<div class="post-metadata">

**Author:** ![Joao\_Marcelo](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@Joao\_Marcelo](https://community.asterisk.org/u/Joao_Marcelo)\
**Post date:** [November 4, 2013, 11:31am UTC](https://community.asterisk.org/t/does-asterisk-uses-secondary-dns-server/44323/6 "2013-11-04T11:31:25Z")

</div>

Thank you very much.

You guys helped me a lot.

Best Regards,

Joao Marcelo
