Newbie setting up sip.conf and extensions.conf

I am trying a simple configuration setting up sip.conf and extensions.conf. I have a media gateway that will translate sip calls to PSTN calls and I want to forward all my SIP calls to the gateway.

Here is my sip.conf:
[general]
;context=incoming

allow=ulaw
allow=alaw
allow=gsm

; Register and get calls from Foo Provider, to our number 1-555-455-1337
register => yile:@10.254.1.101

[fooprovider]
type=friend
host=10.254.1.101
dtmfmode=rfc2833
canreinvite=no
disallow=all
allow=ulaw
allow=alaw
allow=gsm
insecure=port,invite
context=incoming

[outbound_provider]
type=friend
host=10.254.1.101
dtmfmode=rfc2833
canreinvite=no
disallow=all
allow=ulaw
allow=alaw
allow=gsm
insecure=port,invite
context=outbound

; ------------------------------------

[1000]
type=friend
secret=ku
dtmfmode=rfc2833
callerid=“First Phone” <1000>
; Our phones will register to Asterisk.
; Otherwise we would define the IP address or FQDN of the phone on the following line.
host=dynamic
canreinvite=no
; Deny registration from anywhere first
deny=0.0.0.0/0.0.0.0
; Replace the IP address and mask below with the actual IP address and mask
; of the computer running the softphone, or the address of the hardware phone,
; either a host address and full mask, or a network address and correct mask,
; registering will be allowed from that host/network.
permit=192.168.1.0/255.255.255.0
context=outbound

Here is my extensions.conf:

[general]
static=yes
writeprotect=no
clearglobalvars=no

[globals]
; Global variables goes here

[incoming]
exten => s,1,Log(NOTICE, Incoming call from ${CALLERID(all)})
exten => s,n,Dial(SIP/1000)
exten => s,n,Hangup()
; End of the “incoming” context

[myphones]
; When we dial something from the phones we just added in
; sip.conf, Asterisk will look for a matching extension here,
; in this context.

; First Phone, extension 1000. If 1000 is called, here is
; where we land, and the device registered with the
; name 1000, is dialed, after that Asterisk hangs up.
exten => 1000,1,Dial(SIP/1000)
exten => 1000,n,Hangup()

; The same goes for Second Phone, extension 1001
exten => 1001,1,Dial(SIP/1001)
exten => 1001,n,Hangup()

; Testing extension, prepare to be insulted like a
; Monthy Python knight
exten => 201,1,Answer()
exten => 201,n,Playback(tt-monty-knights)
exten => 201,n,Hangup()

; Echo-test, it is good to test if we have sound in both directions.
; The call is answered
exten => 202,1,Answer()
; Welcome message is played
exten => 202,n,Playback(welcome)
; Play information about the echo test
exten => 202,n,Playback(demo-echotest)
; Do the echo test, end with the # key
exten => 202,n,Echo()
; Plays information that the echo test is done
exten => 202,n,Playback(demo-echodone)
; Goodbye message is played
exten => 202,n,Playback(vm-goodbye)
; Hangup() ends the call, hangs up the line
exten => 202,n,Hangup()

[outbound]
; Call POTS numbers through Foo Provider (any number longer than 5 digits starting with 9)
exten => _9XXXX.,1,Log(NOTICE, Dialing out from ${CALLERID(all)} to ${EXTEN:1} through Foo Provider)
exten => _9XXXX.,n,Dial(SIP/fooprovider/${EXTEN:1},60)
exten => _9XXXX.,n,Playtones(congestion)
exten => _9XXXX.,n,Hangup()

I have a SIP phone that I try and dial 9-3096 (3096 is a valid extension on the media gateway) but I get the error:
[Feb 25 09:05:04] NOTICE[3331][C-00000001] chan_sip.c: Call from ‘’ (192.168.3.6:53288) to extension ‘93096’ rejected because extension not found in context ‘default’.

For now I just want all outbound (from my SIP phone to the PSTN) calls to work by going through the media gateway.

Thanks for any help in advance,
Y-

Are you sure you try to dial from 1000?
What is the output of #asterisk -rx “sip show peers”?

–Satish Barot

I have a SIP app on the phone. It has a register function. When I try to register I get :
localhost*CLI> [Feb 25 11:24:06] NOTICE[3331] chan_sip.c: Registration from ‘sip:Yile@192.168.3.1;transport=UDP’ failed for ‘192.168.3.6:51473’ - Wrong password
[Feb 25 11:24:06] NOTICE[3331]: chan_sip.c:28091 handle_request_register: Registration from ‘sip:Yile@192.168.3.1;transport=UDP’ failed for ‘192.168.3.6:51473’ - Wrong password

I have checked and I put in ‘ku’ for the password on the phone.

Here is the output for sip show peers:
localhostCLI> sip show peers
Name/username Host Dyn Forcerport Comedia ACL Port Status Description
1000 (Unspecified) D Auto (No) No A 0 Unmonitored
fooprovider 10.254.1.101 Auto (No) No 5060 Unmonitored
outbound_provider 10.254.1.101 Auto (No) No 5060 Unmonitored
3 sip peers [Monitored: 0 online, 0 offline Unmonitored: 2 online, 1 offline]
localhost
CLI> sip show registry
Host dnsmgr Username Refresh State Reg.Time
10.254.1.101:5060 N yile 105 Registered Wed, 25 Feb 2015 11:27:18
1 SIP registrations.
localhost*CLI>

Your problem lies here and is also visible here:

You have defined an extension 1000 with context outbound which will work as expected, once the phone is correctly registered. But: Registering fails as the phone tries to register as b]Yile[/b] instead of 1000. You will need to check the phone-settings and asure that it’s trying to register as account 1000 instead of Yile.
As the phone is not registered and the sip-configuration allows guests, the phone actuelly interacts as non registerd guest with asterisk thus it’s call is directed to the default-context where the extension Youi want to reach is not defined which results in the error “Rejected”.

Thanks very much that got the sip connection request going to the media gateway. I have a quick question if the 192.168.3.1 interface is NATed so that all traffic that goes out the box goes out my 10.254.1.67 interface, do I need to put “nat=yes” in the [1000] section so asterisk can translate or proxy the call to the media gateway at 10.254.1.101?

Thanks again that was a big help!
Y-

I added the externaddr to the sip.conf and it is working now.
Thanks for all the excellent help!
Y-

Also, canreinvite is obsolete and may even be rejected on current versions.

insecure=invite makes no sense when you are not secure in the first place (no secret). In any case, remotesecret makes it redundant.

It is almost always safer to use type=peer than type=friend, with SIP.