I have a SIP Trunk with ITSP (OTENET from Greece) where I have configured a CHAN_PJSIP correctly. The problem arises from the fact that SIP Server is FQDN, but REGISTER goes to wrong IP.
In order to get the correct IP of the SIP Server, I have to do DNS request to specific DNS server that they have provided. So I have configured dnsmasq to ask those DNS servers for SIP Server:
[[email protected] ~]# cat /etc/dnsmasq.d/dnsmasq-ote.conf server=/ims.otenet.gr/188.8.131.52 server=/ims.otenet.gr/184.108.40.206
Additionally, the first DNS of the pbx is 127.0.0.1
[[email protected] ~]# cat /etc/resolv.conf nameserver 127.0.0.1 nameserver 192.168.57.10 nameserver 220.127.116.11
So when I do ping or nslookup, it returns the correct IP.
[[email protected] ~]# nslookup ims.otenet.gr Server: 127.0.0.1 Address: 127.0.0.1#53 Non-authoritative answer: Name: ims.otenet.gr Address: 18.104.22.168
Without the dnsmasq configuration, nslookup returns the wrong IP for SIP Server. Eg from my PC:
nslookup ims.otenet.gr Server: local Address: XX.XX.XX.XX Non-authoritative answer: Name: ims.otenet.gr Address: 22.214.171.124
Now, what happens is that even though from linux (it’s freepbx distro) I get the correct IP from nslookup, the PJSIP trunk sends REGISTER packets to wrong IP (126.96.36.199) instead of the right one (188.8.131.52).
If I wait long enough, eventually it uses the correct IP. And everything else works correctly (OPTIONS,INVITE etc are also being sent to correct IP after that).
But on system reboot, again it sends REGISTER to wrong IP.
IF I setup the trunk as CHAN_SIP, it works flawlessly. Having said that it’s the last configuration left for me in order to convert into full-PJSIP. So I am trying to figure that out.
Is it something I am doing wrong? What is the expected behaviour?
[[email protected] ~]# cat /etc/asterisk/dnsmgr.conf [general] enable=yes refreshinterval=300
UPDATE: If I use DNS between resolv.conf and dnsmasq the other way round, it works and returns the correct IP.
Local DNS server for local domain on dnsmasq.
[[email protected] /]# cat /etc/dnsmasq.d/dnsmasq-local.conf server=/[local-domain-name.com]/192.168.57.10
DNS Servers of the ITSP on resolv.conf
cat /etc/resolv.conf nameserver 127.0.0.1 nameserver 184.108.40.206 nameserver 220.127.116.11
This begs the question, what is the proper configuration in such cases where there are various SIP Server FQDNs that have to be resolved from different DNS servers.
Does asterisk use resolv.conf by default and ignores dnsmasq?
Maybe I need to “ditch” resolv.conf and have only 127.0.0.1 so I can set all dns configuration from dnsmasq?