Problem in SIP trunk calls with --> DIALSTATUS = CHANUNAVAIL and HANGUPCAUSE = 20

Hi All,

I defined a sip trunk and it is registered:

localhost*CLI> sip show registry
Host dnsmgr Username Refresh State Reg.Time
sip.mydivert.com:5060 N 001102183 105 Registered Mon, 27 Dec 2010 01:18:03
1 SIP registrations.

But it does not seem to be in peers:
localhost*CLI> sip show peers
Name/username Host Dyn Nat ACL Port Status
6000 (Unspecified) D N A 5060 UNKNOWN
6001/6001 192.168.0.22 D N A 60884 OK (114 ms)
8000/8000 192.168.0.15 D N A 4082 UNREACHABLE
mydivert/001102183 78.46.43.9 N 5060 UNREACHABLE
4 sip peers [Monitored: 1 online, 3 offline Unmonitored: 0 online, 0 offline]

When I dial to this trunk I receive the response below:

– Executing [s@macro-dialout-trunk:18] GotoIf(“SIP/6001-00000009”, “0?customtrunk”) in new stack
– Executing [s@macro-dialout-trunk:19] Dial(“SIP/6001-00000009”, “SIP/mydivert/00905556960917,300,”) in new stack
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
== Everyone is busy/congested at this time (1:0/0/1)
– Executing [s@macro-dialout-trunk:20] NoOp(“SIP/6001-00000009”, “Dial failed for some reason with DIALSTATUS = CHANUNAVAIL and HANGUPCAUSE = 20”) in new stack

So no invites are going out of my device. Are you familiar to these? Especially why I can not see mydivert in peers? Why this trunk seem to be busy. I can not find a way out.

You had your localnet settings wrong, it’s the network address that needs to be specified not the host.

I guess it should be like below:

externhost = a.dyndns.org
externrefresh = 120
localnet = 192.168.1.0/255.255.255.0
nat = yes

I re-loaded freepbx and I was getting this fatal error where I could not call OUT but anyone could call in.

I edited sip_nat.conf like this

externhost = a.dyndns.org
externrefresh = 120
localnet = 192.168.1.10/255.255.255.0
nat = yes

But it NEVER worked. I installed the asterisk settings for freepbx and it worked the first time. I don’t know what I did wrong but I may try and look at it.

In the meantime, can anyone point me to some resources to register phones off of a LAN but to connect to freepbx/asterisk.

you are my men. It works.

Its really appreciated, I was working for it for 2-3 days.

Thank you very very much.

I am sorry , I am trying to find it out for long hours and i have a headache now. My brain does not work efficiently :slight_smile:

I saw your notes now I will try it now.

On my system I have edited sip_nat.conf by hand. No, don’t edit the peers by hand. Do that in FreePBX gui.

You can do it ALL through the gui if you install the Asterisk SIP Settings module. I forgot about that as I don’t use it.

So again, to recap:

  • Edit sip_nat.conf by hand and put in the block we discussed above, then restart. Remove those lines from your mydivert trunk config in the FreePBX gui.

OR

  • Install Asterisk SIP Settings and set up the NAT options there. You would click

NAT: yes
IP Configuration: Dynamic IP
Dynamic Host: ulasyuce.dyn…whatever 120 Refresh rate
192.168.0.0 / 255.255.255.0 for Local Networks

then configure the rest of the stuff on the screen as you need it.

I made the changes you mentioned:

externhost=ulasyuce.dyndns-remote.com
externrefresh=120
localnet=192.168.0.0/255.255.255.0&127.0.0.0/255.255.255.0
nat=yes
username=00xxx
type=peer
srvlookup=yes
secret=xxx
qualify=3600&yes
insecure=very
host=sip.mydivert.com
fromuser=00xxx
dtmfmode=rfc2833
disallow=all
context=from-trunk
canreinvite=no
authuser=00xxxx
allow=alaw&ulaw&gsm&slinear&ilbc
sendrpid=yes

Still options messages are as follows

Retransmitting #2 (NAT) to 78.46.43.9:5060:
OPTIONS sip:sip.mydivert.com SIP/2.0
Via: SIP/2.0/UDP 192.168.0.120:5060;branch=z9hG4bK1968ef58;rport
Max-Forwards: 70
From: “Unknown” sip:[email protected];tag=as0d7868b3
To: sip:sip.mydivert.com
Contact: sip:[email protected]
Call-ID: [email protected]
CSeq: 102 OPTIONS
User-Agent: Asterisk PBX 1.6.2.11
Date: Mon, 27 Dec 2010 02:43:21 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO
Supported: replaces, timer
Content-Length: 0

peers seem to be unreachable too.

You need to see your external IP address in those SIP OPTIONS packets you’re sending to the provider. I mentioned that you need to configure NAT in the [general] section of sip.conf (or sip_nat.conf for FreePBX) and it looks like you’re still trying to do it in the trunk config.

sip_nat.conf is empty

sip registrations is as follows

[root@localhost asterisk]# cat sip_registrations.conf
;--------------------------------------------------------------------------------;
; Do NOT edit this file as it is auto-generated by FreePBX. All modifications to ;
; this file must be done via the web gui. There are alternative files to make ;
; custom modifications, details at: http://freepbx.org/configuration_files ;
;--------------------------------------------------------------------------------;
;

register=user:[email protected]/user —> with the username and password

and sip_additional.conf
has all the settings exactly as in route.

Do you think these are correct?
I can not understand why I can not see unreachable for peer mydivert.

Take the NAT config lines out of your peer config, and put them in sip_nat.conf. I have written it three times now.

I am a bit confused.

I was not changing conf files manually, i was only changing from web gui shoud I do it?
I can not touch sip.conf so should I change sip_additional.conf(which gui changes too)?

It already has the modifications I have done, you can see it as follows

[root@localhost asterisk]# cat sip_additional.conf
;--------------------------------------------------------------------------------;
; Do NOT edit this file as it is auto-generated by FreePBX. All modifications to ;
; this file must be done via the web gui. There are alternative files to make ;
; custom modifications, details at: http://freepbx.org/configuration_files ;
;--------------------------------------------------------------------------------;
;
[mydivert]
disallow=all
externhost=ulasyuce.dyndns-remote.com
externrefresh=120
localnet=192.168.0.0/255.255.255.0
localnet=127.0.0.0/255.255.255.0
nat=yes
username=0xxx
type=friend
srvlookup=yes
secret=xxxx
qualify=3600
qualify=yes
insecure=port,invite
host=sip.mydivert.com
fromuser=xxxxx
dtmfmode=rfc2833
context=from-trunk
canreinvite=no
authuser=xxxxx
allow=alaw
allow=ulaw
allow=gsm
allow=slinear
allow=ilbc
sendrpid=yes

what do you think?

“sip set debug peer mydivert”

Then try your calls. See what happens. The SIP packets will tell you the story.

Standard/verbose Asterisk logs rarely tell enough about a SIP problem to effectively debug.

I see an option message with from : unknown , I am not sure if this is the problem. Other then OPTION message and 200 ok messages there is nothing else in these logs.

In wireshark logs there is only incoming messages and there is no outgoing messages to that service provider.

OPTIONS sip:sip.mydivert.com SIP/2.0

Via: SIP/2.0/UDP 192.168.0.120:5060;branch=z9hG4bK3406d1c4;rport

Max-Forwards: 70

From: “Unknown” sip:[email protected];tag=as0ad95491

To: sip:sip.mydivert.com

Contact: sip:[email protected]

Call-ID: [email protected]

CSeq: 102 OPTIONS

User-Agent: Asterisk PBX 1.6.2.11

Date: Mon, 27 Dec 2010 01:47:06 GMT

Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO

Supported: replaces, timer

Content-Length: 0

Do you have any comments?

You trimmed out the “Contact” header, which would help identify whether your NAT config is correct. Does it have your public IP address in it?

192.168.0.120 is my local ip. I am behind a NAT and I configured that in the trunk. In my firewall 5060 and 10000-20000 is redirected to my local ip.

Do you think contact address should show my external ip?

The part below is taken from my trunk configuration:

externhost=ulasyuce.dyndns-remote.com
externrefresh=120
localnet=192.168.0.120
username=00xxxxx
type=peer
srvlookup=yes
secret=xxxxxx
qualify=3600&yes
nat=yes
insecure=very
host=sip.mydivert.com
fromuser=00xxxx
dtmfmode=rfc2833
disallow=all
context=from-trunk
canreinvite=no
authuser=00xxxx
allow=alaw&ulaw&gsm&slinear&ilbc
sendrpid=yes

Yeah, your NAT config is not correct. The Contact header and Call-ID header should have your public IP address.

You don’t put the NAT stuff in the trunk config. Since you’re using FreePBX it goes in the sip_nat.conf (which gets included as part of the sip.conf general block).

localnet=192.168.0.120 is not right. Use a block something like this:

externhost = ulasyuce.dyndns-remote.com externrefresh = 120 localnet = 192.168.0.0/255.255.255.0 localnet = 127.0.0.0/255.255.255.0 nat = yes

Hello,

I’m having the same issue with Eurotech GSM gateway. After looking at the packets, I see all there is is OPTIONS back and forth between the gw and Asterisk.

So, when I try to make a call through the gw, wireshark doesn’t show it going to the gw at all. Wireshark and sip debug would show 3 IPs had this worked, my PC (softphone), Asterisk server and Eurotech GW IP. But I see PC and Asterisk IP only during calls.

And I get a CHANUVAIL congested hangupcause 20 message.
All the aforementioned IPs are in an office behind a router. And no firewalls between them.

Some help would be GREAT.
Thanks!
Also made a forum post: http://www.elastix.org/index.php/en/component/kunena/3-help/93252-eurotech-gsm-gateway-with-elastix-as-trunk.html

Sounds like you have your outbound route set up incorrectly, since your call is not even attempting to use the trunk. It’s a different topic than this one, so I recommend starting a new thread. The OPTIONS packets you see are Asterisk’s pings to check that the trunk is alive.