ast_gethostbyname / name resolution problem?


I just installed asterisk on a server in the internet as pure SIP proxy (some upstream SIP trunks and some SIP extensions).

However I have a lot of problems with name resolution and cannot find the cause. Name resolution for the server itself is fine, using dig & nslookup I can lookup all types of records: A, PTR, NAPTR, SRV using all servers that are in /etc/resolve.conf for all names that are in use somewhere.

But asterisk is unable to resolve peers configured with in sip.conf for whatever reason.
It also doesn’t matter if I have srvlookup enabled or not.

I tried to trace this back and ended up at ast_gethostbyname in main/util.c which seems to be a thread-safe replacement for gethostbyname.
I don’t know if this is intentional but this function always gives a zero output and I really think this shouldn’t be the case.

Thanks and best regards,

i have the same problem as you, i had to put manually ip’s of provider, and create many duplicate peers as my provider has many ip’s associated to one domain name, dont search i’s asterisk problem

What distribution are you using?
I’m running CentOS and tried the latest stock 4.4 and 4.5 kernels both with Asterisk 1.2.18 from trixbox and self-compiled latest 1.4 with the same result…

Best regards,

it is not destrib related, i have tryed a lot of them with different version of asterisk, beleive me its asterisk bad dns resolution bug

this is good and bad…

Bad because not a lot of people have this problem, so it will be something tricky.
Good because we might be able to fix it.

I’ll dig a bit deeper into the “ast_gethostbyname” function, maybe there is a workaround.

Btw, did you put the IPs in the /etc/hosts or Asterisk’s sip.conf?
/etc/hosts didn’t work for me, sip.conf did, except for a single provider…

Best regards,

i put the directly in sip.conf