Hi,
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.
More specifically,
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:
[root@pbx ~]# cat /etc/dnsmasq.d/dnsmasq-ote.conf
server=/ims.otenet.gr/195.167.21.200
server=/ims.otenet.gr/195.167.22.200
Additionally, the first DNS of the pbx is 127.0.0.1
[root@pbx ~]# cat /etc/resolv.conf
nameserver 127.0.0.1
nameserver 192.168.57.10
nameserver 8.8.8.8
So when I do ping or nslookup, it returns the correct IP.
[root@pbx ~]# nslookup ims.otenet.gr
Server: 127.0.0.1
Address: 127.0.0.1#53
Non-authoritative answer:
Name: ims.otenet.gr
Address: 195.167.16.182
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: 195.167.16.30
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 (195.167.16.30) instead of the right one (195.167.16.182).
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?
[root@pbx ~]# 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.
[root@pbx /]# 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 195.167.21.200
nameserver 195.167.22.200
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?
Thanks,
Nik Sar