Call routing problem

Hi,

before all, excuse me for my bad english :unamused:

I’m trying to configure asterisk with an italian SIP provider called Skypho.
This provider use the same host for incoming and outgoing calls (voip.eutelia.it).

I’ve configured a peer like this

[myprovider-out]
username
secret
host voip.eutelia.it
nat
etc

and a register line.
SIP SHOW REGISTRY tells that asterisk is connected to receive incoming calls from voip.eutelia.it and in fact, it does.
outgoing calls work very well.
But when I receive a call from outside there is a problem… incoming call is redirect (i think) another time to my voip provider throught myprovider-out peer :frowning:
So I can’t catch incoming calls by dialplane extensions. Caller receives an occupied tone and nothing else.

SIP DEBUG reports:

[code]<— SIP read from 83.211.227.21:5060 —>
INVITE sip:9999@NET.NET.NET.MYIP SIP/2.0
Record-Route: sip:83.211.227.21;ftag=3149D7E4-1DD9;lr=on
Record-Route: sip:83.211.227.13;ftag=3149D7E4-1DD9;lr=on
Via: SIP/2.0/UDP 83.211.227.21;branch=0
Via: SIP/2.0/UDP 83.211.227.13;branch=z9hG4bK71b6.1b070b62.0
Via: SIP/2.0/UDP 62.94.88.138:5060;branch=z9hG4bK15D316115D
From: sip:33975*****@62.94.88.138;tag=3149D7E4-1DD9
To: sip:04441837XXX@voip.eutelia.it
Call-ID: DD8E9292-3C211DC-99F9A8A4-2570551E@62.94.88.138
Supported: rel1xx,timer,replaces
CSeq: 102 INVITE
Max-Forwards: 8
Remote-Party-ID: sip:33975*****@62.94.88.138;party=calling;screen=yes;privacy=off
Contact: sip:33975*****@62.94.88.138:5060
Expires: 180
Content-Type: application/sdp
Content-Length: 448

v=0
o=CiscoSystemsSIP-GW-UserAgent 8937 3170 IN IP4 62.94.88.138
s=SIP Call
c=IN IP4 62.94.88.139
t=0 0
m=audio 17686 RTP/AVP 18 8 0 4 3 125 101 19
c=IN IP4 62.94.88.139
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=yes
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:4 G723/8000
a=fmtp:4 annexa=no
a=rtpmap:3 GSM/8000
a=rtpmap:125 X-CCD/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=rtpmap:19 CN/8000
a=direction:passive

<------------->
— (17 headers 19 lines) —
Sending to 83.211.227.21 : 5060 (NAT)
Using INVITE request as basis request - DD8E9292-3C211DC-99F9A8A4-2570551E@62.94.88.138
Found peer ‘04441837XXX-out’

<— Reliably Transmitting (NAT) to 83.211.227.21:5060 —>
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 83.211.227.21;branch=0;received=83.211.227.21
Via: SIP/2.0/UDP 83.211.227.13;branch=z9hG4bK71b6.1b070b62.0
Via: SIP/2.0/UDP 62.94.88.138:5060;branch=z9hG4bK15D316115D
From: sip:33975*****@62.94.88.138;tag=3149D7E4-1DD9
To: sip:04441837XXX@voip.eutelia.it;tag=as6f10dd32
Call-ID: DD8E9292-3C211DC-99F9A8A4-2570551E@62.94.88.138
CSeq: 102 INVITE
User-Agent: Asterisk_Eut
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Proxy-Authenticate: Digest algorithm=MD5, realm=“voip.eutelia.it”, nonce="6465c8c6"
Content-Length: 0

<------------>
Scheduling destruction of SIP dialog ‘DD8E9292-3C211DC-99F9A8A4-2570551E@62.94.88.138’ in 32000 ms (Method: INVITE)
webdevCLI>
webdev
CLI>
<— SIP read from 83.211.227.21:5060 —>
ACK sip:9999@NET.NET.NET.MIOIP SIP/2.0
Max-Forwards: 15
Record-Route: sip:83.211.227.21;ftag=3149D7E4-1DD9;lr=on
Via: SIP/2.0/UDP 83.211.227.21;branch=0
Via: SIP/2.0/UDP 83.211.227.13;branch=z9hG4bK71b6.1b070b62.0
From: sip:33975*****@62.94.88.138;tag=3149D7E4-1DD9
Call-ID: DD8E9292-3C211DC-99F9A8A4-2570551E@62.94.88.138
To: sip:04441837XXX@voip.eutelia.it;tag=as6f10dd32
CSeq: 102 ACK
Content-Length: 0[/code]

Note: If i change myprovider-out from peer to user incoming calls work perfectly but I can’t initiate an outgoing call (user can’t be used to connect to my provider).

Any help would be appreciated

Thank you!

Giulio

edit: debian testing - asterisk (1:1.2.13~dfsg-2)

It sounds like your inbound context is broken. You’ll need to post your contexts from sip.conf for someone to tell if that is the problem.

Mark MacVicar

Broken context it’s possible (I’m not an expert, this is my first experience with asterisk :smile: ) but why when I set peer to user my context/dialplane works perfectly? :confused:
I can’t post now my .conf files sorry, I’ll post they next monday, but I can try to explain situation for the moment.

[general]
context=from-ext ;this is my context for incoming calls
realm=voip.eutelia.it

[phone1,2,N]
context=from-sip ;this is my context for outgoing calls

My peer, myprovider-out, it’s also on from-sip context.

Regards

Giulio

sip.conf

[code][general]
context=from_ext ; per la gestione delle chiamate entranti da VoIP
realm=voip.eutelia.it ; Dominio del servizio VoIP SIP
port=5060 ; Porta UDP per la segnalazione SIP
bindport=5060
bindaddr=0.0.0.0 ; Indirizzo IP di ascolto (generico)
srvlookup=yes ; Abilita il DNS SRV per chiamate uscenti
defaultexpirey=330 ; timer di registrazione degli account SIP
useragent=Asterisk_Eut
nat = yes
; PARAMETRI IP
localnet=192.168.5.0/255.255.255.0 ; subnet e mask della LAN
externip=82.105.X.X ; indirizzo IP pubblico

; DEFINIZIONE DEI CODEC IN USO
disallow=all
;allow=g729 ; da attivare in modalità 'passthrough’
allow=alaw
allow=ulaw
callerid = Unknow

; register => ::@voip.eutelia.it/
register=04441837XXX:MYPASS:04441837XXX@voip.eutelia.it/04441837XXX

[04441837XXX-out]
context = from_sip
type=peer
secret=77/p1d.i
username=04441837XXX
fromuser=04441837XXX
host=voip.eutelia.it
nat = yes
dtmfmode=inband
qualify=yes
regcontext=from_sip
canrenvite=no

[xlite1]
type=friend
context = from_sip
username=xlite1
callerid="Giulio"
host=dynamic
nat=no
canreinvite=no
disallow=all
allow=gsm ; GSM consumes far less bandwidth than G711-u (ulaw)
allow=ulaw
allow=alaw [/code]

estensions.conf

[code][general]
static=yes
writeprotect=no
autofallthrough=yes
clearglobalvars=no
priorityjumping=no

[globals]
CONSOLE=Console/dsp ; Console interface for demo
IAXINFO=guest ; IAXtel username/password
TRUNK=Zap/g2 ; Trunk interface

[from-sip-external]
include => from_ext

[from_ext]
exten => 04441837XXX,1, Answer
exten => 04441837XXX,n,BackGround(auth-thankyou)
exten => 04441837XXX,n, Hangup

[from_sip]
exten => 1010,1, Dial(SIP/xlite1,30,t)
exten => 1011,1, Dial(SIP/xlite2,30,t)
exten => 1012,1, Dial(SIP/claudio,30,t)

exten => _X.,1,Answer
exten => _X.,n,Set(LANGUAGE()=it)
exten => _X.,n,Wait(1)
exten => _X.,n,BackGround(beep)
exten => _X.,n,Dial(SIP/${EXTEN}@04441837XXX-out,30,t)

[/code]

When I receive a call from outside there is a problem… incoming call is redirected (i think) another time to my voip provider throught 04441837XXX-out peer
If i change myprovider-out from peer to user incoming calls work perfectly but I can’t initiate an outgoing call (user can’t be used to connect to my provider).

Any help would be appreciated

Thank you!

Giulio

I need to get my terminology straight, apologies.

I think I see your problem. You need different contexts defined for your inbound and outbound calls, otherwise dialing in will behave as if you are dialing out. Your outbound definition looks good.

Your inbound definition “xlite1” in sip.conf should refer to a incoming context in extensions.conf and not “from_sip”. For example:

[xlite1]
type=friend
context = incoming

in extensions.conf, create an “incoming” context and have it dial your phone. For example if your Zap channel is 4, a really simple incoming context might be:

[incoming]
exten => s,1,Answer ; answer call
exten => YOURNUMBER,2,Dial(Zap/4,20)
exten => YOURNUMBER,3,Hangup

If you can get that to work then you’re on the right track and it’s just a matter of getting your dialplan to work the way you want it.

This page may explain it better voip-info.org/wiki/index.php … g+sip.conf

Also, as a note about security make sure you don’t past your username and secret in these forums. It looks like you might have missed a few.

Mark MacVicar

Hmmm you’re right eheh, thank you to let me know my -bip- :smile:
Anyway I tried your solution and nothing change :frowning:
Asterisk seems to completly ignore my dialplan… in fact it doesn’t say “hey boy, i can’t find a dialplan!” on sip debug… it’s strange…
Maybe a problem with destination of call?

from sip debug:

Destination’s host and peer’s host are the same… (voip.eutelia.it)
I think that asterisk wants to work as a router. So it simply skips my dialplan and rewrite a new request for destination’s host to route call by peer…

from sip debug:

Sending to 83.211.227.21  : 5060 (NAT) <<<----- (aka voip.eutelia.it)
Using INVITE request as basis request - DD8E9292-3C211DC-99F9A8A4-2570551E@62.94.88.138
Found peer '04441837XXX-out'

Why asterisk uses a peer to route an incoming call? It’s possible? Can I stop this behavior?

Thanks a lot

Giulio

I don’t know the answers to your questions. I’d have to see your new sip.conf and extensions.conf to diagnose the issue.

there are some useful links here for getting started with asterisk: asterisk.org/support/get-started

Including “Asterisk: The Future of Telephony” from O’Reilly Media, which has a good section on setting up your first dialplan in Chapter 5:
asteriskdocs.org/modules/tin … .php?id=11

Mark MacVicar