# Call routing problem

**URL:** <https://community.asterisk.org/t/call-routing-problem/14513>\
**Category:** Asterisk Support\
**Created:** [May 18, 2007, 7:09pm UTC](https://community.asterisk.org/t/call-routing-problem/14513 "2007-05-18T19:09:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ironoxid](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/ironoxid/32/1044_2.png) [@ironoxid](https://community.asterisk.org/u/ironoxid)\
**Post date:** [May 18, 2007, 7:09pm UTC](https://community.asterisk.org/t/call-routing-problem/14513/1 "2007-05-18T19:09:28Z")

</div>

Hi,

before all, excuse me for my bad english 😒

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](http://voip.eutelia.it)).

I’ve configured a peer like this

[myprovider-out]  
username  
secret  
host [voip.eutelia.it](http://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](http://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 ☹  
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](mailto: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](mailto: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](mailto: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](http://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)  
webdev_CLI\>  
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](mailto: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)

---

<div class="post-metadata">

**Author:** ![mmacvicar](https://avatars.discourse-cdn.com/v4/letter/m/e8c25b/32.png) [@mmacvicar](https://community.asterisk.org/u/mmacvicar)\
**Post date:** [May 18, 2007, 10:08pm UTC](https://community.asterisk.org/t/call-routing-problem/14513/2 "2007-05-18T22:08:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ironoxid](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/ironoxid/32/1044_2.png) [@ironoxid](https://community.asterisk.org/u/ironoxid)\
**Post date:** [May 19, 2007, 10:13am UTC](https://community.asterisk.org/t/call-routing-problem/14513/3 "2007-05-19T10:13:16Z")

</div>

Broken context it’s possible (I’m not an expert, this is my first experience with asterisk 😄 ) but why when I set peer to user my context/dialplane works perfectly? 😕  
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.

```auto
[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

---

<div class="post-metadata">

**Author:** ![ironoxid](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/ironoxid/32/1044_2.png) [@ironoxid](https://community.asterisk.org/u/ironoxid)\
**Post date:** [May 21, 2007, 7:25am UTC](https://community.asterisk.org/t/call-routing-problem/14513/4 "2007-05-21T07:25:05Z")

</div>

sip.conf

[code][general]  
context=from\_ext ; per la gestione delle chiamate entranti da VoIP  
[realm=voip.eutelia.it](http://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](mailto: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](http://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

---

<div class="post-metadata">

**Author:** ![mmacvicar](https://avatars.discourse-cdn.com/v4/letter/m/e8c25b/32.png) [@mmacvicar](https://community.asterisk.org/u/mmacvicar)\
**Post date:** [May 21, 2007, 8:34pm UTC](https://community.asterisk.org/t/call-routing-problem/14513/5 "2007-05-21T20:34:26Z")

</div>

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](http://www.voip-info.org/wiki/index.php?page=Asterisk+config+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

---

<div class="post-metadata">

**Author:** ![ironoxid](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/ironoxid/32/1044_2.png) [@ironoxid](https://community.asterisk.org/u/ironoxid)\
**Post date:** [May 22, 2007, 10:57pm UTC](https://community.asterisk.org/t/call-routing-problem/14513/6 "2007-05-22T22:57:03Z")

</div>

Hmmm you’re right eheh, thank you to let me know my -bip- 😄  
Anyway I tried your solution and nothing change ☹  
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:

```auto

```

Destination’s host and peer’s host are the same… ([voip.eutelia.it](http://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:

```auto
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

---

<div class="post-metadata">

**Author:** ![mmacvicar](https://avatars.discourse-cdn.com/v4/letter/m/e8c25b/32.png) [@mmacvicar](https://community.asterisk.org/u/mmacvicar)\
**Post date:** [May 23, 2007, 4:43pm UTC](https://community.asterisk.org/t/call-routing-problem/14513/7 "2007-05-23T16:43:34Z")

</div>

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](http://www.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](http://www.asteriskdocs.org/modules/tinycontent/index.php?id=11)

Mark MacVicar
