Asterisk to VoIP Provider

Hi everyone, need help.

I have an Asterisk /Debian Linux server with two interfaces. eth0 with service provider and eth1 for my clients with dhcp.
Clients in local network can make calls between them successfully but when I tried calls to VoIP Service Provider can not be established.
The Service Provider brings me an ip address (softswitch address). X.X.X.X This is my configuration (by the way this not a registration configuration, just ip address conf.):

sip.conf

[general]
canreinvite=no
dtmfmode=rfc2833
host=X.X.X.X
insecure=invite,port
port=5060
qualify=yes
type=friend

[myserviceprovider]
type=peer
context=incoming_calls
host=X.X.X.X
fromdomain=X.X.X.X
fromuser=X.X.X.X
insecure=invite,port
canreinvite=no
disallow=all
allow=alaw

[25928150]
type=friend
host=dynamic ;
insecure=port,invite ;
context=phones ;
allow=all

[25928151]
type=friend
host=dynamic ;
insecure=port,invite ;
context=phones ;
allow=all

extensions.conf

[globals]

[general]
autofallthrough=yes

[default]

[incoming_calls]
exten => _X.,n,Dial(SIP/25928150)
exten => _X.,n,Hangup()
exten => _X.,n,Dial(SIP/25928151)
exten => _X.,n,Hangup()

[outgoing_calls]
exten => _X.,n,Dial(SIP/${EXTEN}@10.181.1.11)
exten => _X.,n,Hangup()

[internal]
exten => _X.,1,NoOp()
exten => _X.,n,Dial(SIP/${EXTEN},60)
exten => _X.,n,Hangup()

[phones]
include => internal
include => outgoing_calls

if can bring me any help, would be really apreciate it (sorry for my english )

You are supposed to dial number@context. In this case, you are executing:

exten => _X.,n,Dial(SIP/${EXTEN}@10.181.1.11)

Furthermore, you are not specifying command priorities and in the [incoming_calls] context you are using a very ambiguous pattern ("_X.") that will result, for any number dialed, in calls to SIP/25928151.

Thank you andrescm, I did every changes you told me

sip.conf

[myserviceprovider]
type=peer
context=incoming_calls
host=X.X.X.X
fromdomain=X.X.X.X
fromuser=X.X.X.X
insecure=invite,port
canreinvite=no
disallow=all
allow=alaw

[25928151]
type=friend
host=dynamic ;
insecure=port,invite ;
context=phones ;
allow=all

extensions.conf

[globals]

[general]
autofallthrough=yes

[default]

[incoming_calls]
exten => _NXXXXXXX,1,Dial(SIP/25928151)
exten => _NXXXXXXX,2,Hangup()

[outgoing_calls]
exten => _NXXXXXXX,1,Dial(SIP/${EXTEN}@myprovider)
exten => _NXXXXXXX,2,Hangup()

[internal]
exten => _NXXXXXXX,1,NoOp()
exten => _NXXXXXXX,2,Dial(SIP/${EXTEN},60)
exten => _NXXXXXXX,n,Hangup()

[phones]
include => internal
include => outgoing_calls

But I’m getting the following error when trying to set a call to my service provider:

== Using SIP RTP CoS mark 5
– Executing [87180259@phones:1] NoOp(“SIP/25928151-00000001”, “”) in new stack
– Executing [87180259@phones:2] Dial(“SIP/25928151-00000001”, “SIP/87180259,60”) in new stack
[Apr 30 13:59:49] WARNING[4393]: chan_sip.c:5824 create_addr: Purely numeric hostname (87180259), and not a peer–rejecting!
[Apr 30 13:59:49] WARNING[4393]: app_dial.c:2345 dial_exec_full: Unable to create channel of type ‘SIP’ (cause 20 - Subscriber absent)
== Everyone is busy/congested at this time (1:0/0/1)
– Executing [87180259@phones:3] Hangup(“SIP/25928151-00000001”, “”) in new stack
== Spawn extension (phones, 87180259, 3) exited non-zero on 'SIP/25928151-00000001’
control*CLI>

And supposed myserviceprovider peer and 25928151 client test is online.

control*CLI> sip show peers
Name/username Host Dyn Forcerport ACL Port Status
25928150 (Unspecified) D N 0 UNKNOWN
25928151/25928151 192.168.1.5 D N 5060 OK (18 ms)
myserviceprovider X.X.X.X N 5060 OK (69 ms)
3 sip peers [Monitored: 2 online, 1 offline Unmonitored: 0 online, 0 offline]

The first match is in the internal context, so that is what you would expect.

I already solved the issue. I deleted fromdomain variable and works great! :smiley:

[myserviceprovider]
type=peer
context=incoming_calls
host=X.X.X.X
; fromdomain=X.X.X.X

Now my service provider told me when trying to capture sip packets the from field is empty, so they can not capture using this variable, but this is their problem. 8)

Thanks everyone for your help!

Also you have a serious security problem due to unthinking use of insecure.

For your internal device, add secret, remove insecure, and change friend to peer.

Thanks david for your help!