# \[solved\]wrong Via: external instead of internal ip set

**URL:** <https://community.asterisk.org/t/solved-wrong-via-external-instead-of-internal-ip-set/24796>\
**Category:** Asterisk Support\
**Created:** [January 2, 2009, 12:30am UTC](https://community.asterisk.org/t/solved-wrong-via-external-instead-of-internal-ip-set/24796 "2009-01-02T00:30:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![idefix](https://avatars.discourse-cdn.com/v4/letter/i/ba8739/32.png) [@idefix](https://community.asterisk.org/u/idefix)\
**Post date:** [January 2, 2009, 12:30am UTC](https://community.asterisk.org/t/solved-wrong-via-external-instead-of-internal-ip-set/24796/1 "2009-01-02T00:30:15Z")

</div>

Hi all,

my Asterisk 1.6 is connected via FritzBox (NAT) to [sipgate.de](http://sipgate.de)  
Register is possible but no incoming and no outgoing calls are possible

1. Problem: incoming calls (from external)  
I installed SJphone and compared both sniffer logs (from SJphone and Asterisk register):  
SJphone:  
Via: SIP/2.0/UDP 192.168.x.x;rportbranch=blabla  
Asterisk:  
Via: SIP/2.0/UDP 93.200.x.x;rportbranch=blabla  
Since Asterisk is behind NAT the internal IP should be used here as well, shouldn’t it ? (currently using the official IP from my FritzBox)

2.Problem outgoing calls (to external)  
If trying to call any external number (e.g. testnumber 10005 from sipgate) I can see the following message in CLI:

called [10005@sipgate.de](mailto:10005@sipgate.de)  
Failed to authenticate on INVITE “USER1” sip:501@217.10.79.9  
Well - of course [sipgate.de](http://sipgate.de) doesn’t know my user 501…

I’m pretty sure both problems are caused by misconfiguration, but I can’t find where.

sip.conf

```auto
[general]
context=general
useragent=Asterisk PBX
bindport=5080
bindaddr=0.0.0.0
language=de
disallow=all
disable=all
allow=alaw
allow=ulaw
allow=g729
allow=gsm
allow=slinear
srvlookup=yes
nat=yes
;externhost=asterisk.dyndns.org
externip=93.200.x.x:5080
externrefresh=180
localnet=192.168.178.0/255.255.255.0
;stunaddr=stun.sipgate.net:10000
host=217.10.79.9
register=><user>:<PW>@sipgate.de/<user>
;register=><user>:<PW>@217.10.79.9/<user>
canreinvite=no
dtmfmode=rfc2833
qualify=yes
fromdomain=217.10.79.9

[sipgate]
type=friend
username=<user>
fromuser=<PW>
host=dynamic
disallow=all
allow=alaw
allow=ulaw
allow=gsm
context=meine-telefone
outgoingproxy=sipgate.de
nat=yes

[200]; Hausmeister
type = friend
callerid="Hausmeister Krause"<200>
context = meine-telefone
secret = 1234
host = dynamic
```

extensions.conf

```auto
[general]
[meine-telefone]
include => sipgate
exten => _9.,1,Dial(SIP/${EXTEN:1}@sipgate.de,30,r)
exten => <user>,1,Ringing
exten => <user>,2,Wait,2
exten => <user>,3 Dial(SIP/200,20,tr)
exten => <user>,4,Hangup

;Hausmeister
exten => 200,1,Dial(SIP/200,5)
exten => 200,2,VoiceMail(200,u)
exten => 200,2,VoiceMail(200,b)
include => voicemailsystem
```

Thanks a lot in advance !

---

<div class="post-metadata">

**Author:** ![ianplain](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/ianplain/32/1776_2.png) [@ianplain](https://community.asterisk.org/u/ianplain)\
**Post date:** [January 2, 2009, 1:09am UTC](https://community.asterisk.org/t/solved-wrong-via-external-instead-of-internal-ip-set/24796/2 "2009-01-02T01:09:38Z")

</div>

Hi Basicly you are just sending the number straight to sipgates server with no auth at all

have a look at their german site for german langague version but heres the english version

[general]  
port = 5060  
bindaddr = 0.0.0.0  
context = sipout  
qualify=no  
disallow=all  
allow=alaw  
allow=ulaw  
allow=g729  
allow=gsm  
allow=slinear  
srvlookup=yes  
register =\> [SIPID:PASSWD@sipgate.co.uk](mailto:SIPID:PASSWD@sipgate.co.uk)/SIPID

[sipgate-out]  
type=friend  
insecure=very ; otherwise I get authentication errors  
nat=yes  
username=SIPID  
fromuser=SIPID  
[fromdomain=sipgate.co.uk](http://fromdomain=sipgate.co.uk)  
secret=SIPPW  
[host=sipgate.co.uk](http://host=sipgate.co.uk)  
qualify=yes  
canreinvite=no  
dtmfmode=rfc2833

# extension.conf

[sipout]  
exten =\> \_X.,1,Set(CALLERID(num)=SIPID)  
exten =\> \_X.,2,Dial(SIP/${EXTEN}@sipgate-out,30,trg)  
exten =\> \_X.,3,Hangup

Ian

---

<div class="post-metadata">

**Author:** ![idefix](https://avatars.discourse-cdn.com/v4/letter/i/ba8739/32.png) [@idefix](https://community.asterisk.org/u/idefix)\
**Post date:** [January 2, 2009, 10:58am UTC](https://community.asterisk.org/t/solved-wrong-via-external-instead-of-internal-ip-set/24796/3 "2009-01-02T10:58:29Z")

</div>

Thanks for your reply !  
I did now adapt the extensions.conf  
to match your’s

```auto
exten => _9.,1,Set(CALLERID(num)=<user>)
exten => _9.,2,Dial(SIP/${EXTEN}@sipgate,30,trg)
exten => _9.,3,Hangup
```

callout-test  
Phone device connected to Asterisk claims “unavailable” in display and in CLI I can see:  
app\_dial.c:1502 dial\_exec\_full: unable to create channel of type ‘SIP’ (cause 20 - unknown)  
== Everyone is busy/congested at this time (1:0/0/1) blabal

The Invite looks good now (so userid@ip)

I’m still doing something wrong. Any idea ? THanks

---

<div class="post-metadata">

**Author:** ![ianplain](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/ianplain/32/1776_2.png) [@ianplain](https://community.asterisk.org/u/ianplain)\
**Post date:** [January 2, 2009, 11:19am UTC](https://community.asterisk.org/t/solved-wrong-via-external-instead-of-internal-ip-set/24796/4 "2009-01-02T11:19:03Z")

</div>

Have you corrected your sipgate peer? as it stands yours is incorrect.

---

<div class="post-metadata">

**Author:** ![idefix](https://avatars.discourse-cdn.com/v4/letter/i/ba8739/32.png) [@idefix](https://community.asterisk.org/u/idefix)\
**Post date:** [January 2, 2009, 11:32am UTC](https://community.asterisk.org/t/solved-wrong-via-external-instead-of-internal-ip-set/24796/5 "2009-01-02T11:32:52Z")

</div>

😕 I can’t see the wood for the trees (spent already the half night with this problem)

What exactly shall I correct ?

---

<div class="post-metadata">

**Author:** ![ianplain](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/ianplain/32/1776_2.png) [@ianplain](https://community.asterisk.org/u/ianplain)\
**Post date:** [January 2, 2009, 11:53am UTC](https://community.asterisk.org/t/solved-wrong-via-external-instead-of-internal-ip-set/24796/6 "2009-01-02T11:53:54Z")

</div>

Ok the easy opting is create a peer called sipgate-out

[sipgate-out]  
type=friend  
insecure=very ; otherwise I get authentication errors  
nat=yes  
username=SIPID  
fromuser=SIPID  
[fromdomain=sipgate.de](http://fromdomain=sipgate.de)  
secret=SIPPW  
[host=sipgate.de](http://host=sipgate.de)  
qualify=yes  
canreinvite=no  
dtmfmode=rfc2833

and then the dial string as

exten =\> \_9.,1,Dial(SIP/${EXTEN}@sipgate-out,30,trg)  
exten =\> \_9.,n,Hangup

and see how that goes.

---

<div class="post-metadata">

**Author:** ![idefix](https://avatars.discourse-cdn.com/v4/letter/i/ba8739/32.png) [@idefix](https://community.asterisk.org/u/idefix)\
**Post date:** [January 2, 2009, 1:44pm UTC](https://community.asterisk.org/t/solved-wrong-via-external-instead-of-internal-ip-set/24796/7 "2009-01-02T13:44:13Z")

</div>

I solved the issue with the incoming calls in the meanwhile (at least it rings at extension 200, no idea yet how to make it possible to let the caller add the desired extension, but this will be another problem).

Regarding the outgoing calls.  
in CLI I get  
callled 910005@sipgate  
SIP/sipgate-082360f0 is circuit-busy  
…handle\_request\_invite: Call from ‘501’ to extension ‘1005’ rejected because extension not found

my configuration after the mentioned changes:  
sip.conf

```auto
[general]
useragent=Asterisk PBX
bindport=5080
bindaddr=0.0.0.0
language=de
disallow=all
disable=all
allow=alaw
allow=ulaw
allow=g729
allow=gsm
allow=slinear
srvlookup=yes
nat=yes
externhost=asterisk.dyndns.org
externrefresh=180
localnet=192.168.178.0/255.255.255.0
;stunaddr=stun.sipgate.net:10000
host=217.10.79.9
register=><user>:<PW>@sipgate.de/<user>
canreinvite=no
dtmfmode=rfc2833
qualify=yes
fromdomain=217.10.79.9

[sipgate]
type=friend
insecure=port,invite
nat=yes
username=<user>
fromuser=>user>
fromdomain=sipgate.de
secret=<PW>
host=sipgate.de
qualify=yes
canreinvite=no
dtmfmode=rfc2833
context=sipgate-in
```

extensions.conf

```auto
[sipgate-in]
exten => <user>,1,Dial(SIP/200,20)
exten => _X.,2,Hangup()

[general]

[meine-telefone]
;exten => _9.,1,Set(CALLERID(num)=<user>)
exten => _9.,1,Dial(SIP/${EXTEN}@sipgate,30,trg)
exten => _9.,n,Hangup
```

---

<div class="post-metadata">

**Author:** ![idefix](https://avatars.discourse-cdn.com/v4/letter/i/ba8739/32.png) [@idefix](https://community.asterisk.org/u/idefix)\
**Post date:** [January 2, 2009, 3:46pm UTC](https://community.asterisk.org/t/solved-wrong-via-external-instead-of-internal-ip-set/24796/8 "2009-01-02T15:46:05Z")

</div>

ah this is solved now.

my extensions.conf was buggy. I changed it to

```auto

[meine-telefone]
exten => _X.,1,Dial(SIP/${EXTEN}@sipgate,30,trg)
```

And outgoing calls are possible now. Also incoming. Great support, Ian! Thanks you very much - you made my day 😄))

PS: remaining problem is to make it possible to dial any extension from outside (not only 200)
