I have Asterisk 11.7.0 configured on CentOS 6.4 x64 with following sip.conf configuration:

[general]
register =>mynumber:mypass@xxx.xxx.xxx.xxx
registertimeout=20
context=incoming
allowoverlap=no
bindport=5060
bindaddr=192.168.0.3
srvlookup=no
subscribecontext=from-sip

; The SIP provider
[VoIPProvider]
canreinvite=no
username=mynumber
fromuser=mynumber
secret=mypass
context=incoming
type=friend
fromdomain=xxx.xxx.xxx.xxx
host=xxx.xxx.xxx.xxx
dtmfmode=rfc2833
disallow=all
allow=alaw
allow=ulaw
nat=yes
insecure=very

; ext 100
[100]
type=friend
host=dynamic
secret=MyPass123
context=internal
mailbox=100@default
callgroup=1
pickupgroup=1
dtmfmode=rfc2833
canreinvite=no

; ext 200
[200]
type=friend
host=dynamic
secret=MyPass123
context=internal
callgroup=1
pickupgroup=1
dtmfmode=rfc2833
canreinvite=no

And following extensions.conf:

[incoming]
; Ring on extension 100, 200 and the mobile phone.
exten => s,1,Answer()
exten => s,n,Dial(SIP/100&SIP/200&SIP/VoIPProvider/*320423456789,150,r,t,)

; Pass unanswered call to a mobile phone
exten => s,n,Dial(SIP/VoIPProvider/*320423456789,150,r)

; Still not answered? Pass unanswered calls to voicemail
exten => s,n,Voicemail(100,u)
exten => s,n,Hangup

[outgoing]
exten => _XXXXXXXXXXXXXXX,1,Dial(SIP/VoIPProvider/${EXTEN})
exten => _XXXXXXXXXX,1,Dial(SIP/VoIPProvider/${EXTEN})
exten => _XXXXXX,1,Dial(SIP/VoIPProvider/${EXTEN})

[internal]
exten => _XXX,1,Dial(SIP/${EXTEN})

; Calls to ext 100
exten => 100,1,Dial(SIP/100,20)
exten => 100,n,VoiceMail(100,u)
exten => 100,n,Hangup

; Calls to ext 200
exten => 200,1,Dial(SIP/100,20)
exten => 200,n,Hangup

Whenever I dial my number from mobile phone I get a rejection signal. When I check the wireshark log i see three SIP packets:

MySipProvider -> Me: INVITE sip:s@192.168.0.3:5060 Me -> MySipProvider: 401 Unauthorized MySipProvider -> Me: ACK sip:s@192.168.0.3:5060

and that's all there is. What could be happening? Thank you.

有帮助吗?

解决方案

Looks like your Asterisk server is requesting authentication on the incoming call from your provider. My guess as to why is because the "host" value on your "VoIPProvider" entry in your sip.conf matches the IP address the call came from. You could check if this is the problem by temporarily commenting out the "host" value and seeing if the incoming call works. If so you will need to make adjustments to the "VoIPProvider" entry so it gets matched for outgoing calls only rather than incoming and outgoing (you used to do this by setting the "type" but I'm not up to date on the way it's done now).

其他提示

to solve outgoing problem you user context in internal and outgoing is not included in it please add the following line under context internal in extension.conf

[internal] include = outgoing

so that your users can dial at SIP trunk. :)

use register string as this: register => urusername:urpassword@IPaddress/providername

like in your case:

register => mynumber:mypassword@X.X.X.X/VoIPProvider

give it a go ithink this will solve the issue :)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top