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

Hi all,

my Asterisk 1.6 is connected via FritzBox (NAT) to 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
Failed to authenticate on INVITE “USER1” sip:501@217.10.79.9
Well - of course 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

[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

[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 !

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/SIPID

[sipgate-out]
type=friend
insecure=very ; otherwise I get authentication errors
nat=yes
username=SIPID
fromuser=SIPID
fromdomain=sipgate.co.uk
secret=SIPPW
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

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

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

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

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

What exactly shall I correct ?

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
secret=SIPPW
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.

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

[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

[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

ah this is solved now.

my extensions.conf was buggy. I changed it to


[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 :smile:))

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