IAX2 and DNS issues with FreePBX13

Steps to replicate
Create IAX2 trunks between servers and use DNS names instead of IP addresses

For purpose of testing this, I have a simplified IAX2 config.

type=friend
qualify=yes
host=pbx.site1.com
deny=all
context=from-internal
allow=ulaw

Right after you apply config you will see this. Repeatedly.

[2016-10-17 10:10:52] ERROR[23988]: netsock2.c:98 ast_sockaddr_stringify_fmt: getnameinfo(): ai_family not supported
[2016-10-17 10:10:52] ERROR[23988]: netsock2.c:98 ast_sockaddr_stringify_fmt: getnameinfo(): ai_family not supported
[2016-10-17 10:10:52] ERROR[23988]: netsock2.c:98 ast_sockaddr_stringify_fmt: getnameinfo(): ai_family not supported
[2016-10-17 10:10:52] ERROR[23988]: netsock2.c:98 ast_sockaddr_stringify_fmt: getnameinfo(): ai_family not supported
[2016-10-17 10:10:52] ERROR[23988]: netsock2.c:98 ast_sockaddr_stringify_fmt: getnameinfo(): ai_family not supported
[2016-10-17 10:10:52] ERROR[23988]: netsock2.c:98 ast_sockaddr_stringify_fmt: getnameinfo(): ai_family not supported
[2016-10-17 10:10:57] ERROR[22771]: netsock2.c:524 ast_sockaddr_hash: Unknown address family '0'.
[2016-10-17 10:10:57] ERROR[22764]: netsock2.c:524 ast_sockaddr_hash: Unknown address family '0'.
[2016-10-17 10:10:57] ERROR[22773]: netsock2.c:524 ast_sockaddr_hash: Unknown address family '0'.

Showing the peers results in no IP listed.

fpbx*CLI> iax2 show peers
Name/Username    Host                                           Mask                                      Port           Status      Description
bundy_to_site1                                              (S)  255.255.255.255                                          UNREACHABLE
bundy_to_site2                                           (S)  255.255.255.255                                          UNREACHABLE
bundy_to_site3                                           (S)  255.255.255.255                                          UNREACHABLE
3 iax2 peers [0 online, 3 offline, 0 unmonitored]

Eventually, DNS will refresh.

[2016-10-17 10:14:45] ERROR[22726]: netsock2.c:98 ast_sockaddr_stringify_fmt: getnameinfo(): ai_family not supported
[2016-10-17 10:14:45] NOTICE[22726]: dnsmgr.c:226 dnsmgr_refresh: dnssrv: host 'pbx.site2.com' changed from  to 12.XXX.XXX.XXX:0
[2016-10-17 10:14:45] ERROR[22726]: netsock2.c:98 ast_sockaddr_stringify_fmt: getnameinfo(): ai_family not supported
[2016-10-17 10:14:45] NOTICE[22726]: dnsmgr.c:226 dnsmgr_refresh: dnssrv: host 'hpbx.site3.com' changed from  to 67.XXX.XXX.XXX:0
[2016-10-17 10:14:45] ERROR[22726]: netsock2.c:98 ast_sockaddr_stringify_fmt: getnameinfo(): ai_family not supported
[2016-10-17 10:14:45] NOTICE[22726]: dnsmgr.c:226 dnsmgr_refresh: dnssrv: host 'pbx.site1.com' changed from  to 68.XXX.XXX.XXX:0

But the trunks do not come online.

fpbx*CLI> iax2 show peers
Name/Username    Host                                           Mask                                      Port           Status      Description
bundy_to_site1     68.XXX.XXX.XXX                            (S)  255.255.255.255                           0              UNREACHABLE
bundy_to_site2  12.XXX.XXX.XXX                            (S)  255.255.255.255                           0              UNREACHABLE
bundy_to_site3  67.XXX.XXX.XXX                           (S)  255.255.255.255                           0              UNREACHABLE
3 iax2 peers [0 online, 3 offline, 0 unmonitored]

looking at a single peer

fpbx*CLI> iax2 show peer bundy_to_site1


  * Name       : bundy_to_site1
  Description  :
  Secret       : <Not set>
  Context      : from-internal
  Parking lot  :
  Mailbox      :
  Dynamic      : No
  Callnum limit: 0
  Calltoken req: No
  Trunk        : No
  Encryption   : No
  Callerid     : "" <>
  Expire       : -1
  ACL          : Yes
  Addr->IP     : 68.XXX.XXX.XXX Port 0
  Defaddr->IP  : (null) Port (null)
  Username     :
  Codecs       : (gsm|ulaw|alaw)
  Codec Order  : (ulaw|alaw|gsm)
  Status       : UNREACHABLE
  Qualify      : every 60000ms when OK, every 10000ms when UNREACHABLE (sample smoothing Off)

;deny=0.0.0.0/0.0.0.0
;permit=209.16.236.73/255.255.255.0
;allow={codec_list}
;disallow={codec_list}

I think your config is messed up from the start.

>insert lots of bad words<

how the heck did my brain melt on that.

off to test.

Alright problem still exists, and I found a related post. The user gave up on using FQDN, so the problem was never actually resolved.

So I guess time to open a bug report.

Seems to me we looked at this for another guy a few weeks ago. His problem was a flaky DNS server. Seems to me he had to add Google DNS (8.8.8.8) to his list of valid DNS servers.

It might also be that the DNS response is just not fast enough for the config rebuild, so the address gets dropped. It’s kind of old-school, but have you through about adding the host records to your /etc/hosts file?

If this is truly a DNS problem, then making the response to the name query as fast as possible might be a good idea.

Or they could fix the problem and have it do an immediate DNS lookup like any normal service if the DNS cache is stale and not dump it to null on reload and wait 10 minutes to refresh DNS.

Because when this is happening, I can most certainly ping by FQDN from another SSH session.

I’m running FreePBX 13.0.190.9 w/ Asterisk 13.14.0 and have this same problem. The only way I’ve found to resolve it is to open up /etc/asterisk/dnsmgr.conf and change enable to no. I was always able to go to console and ping vancouver2.voip.ms but unless I used the IP in my IAX2 config, I would always receive a "app_dial.c: Unable to create channel of type 'IAX2' (cause 20 - Subscriber absent)" error when making an outgoing call. I even tried setting my DNS to our domain controller, our firewall, Google, ISP.

Here’s my config that works:

[general]
enable=no
refreshinterval=300