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:


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



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

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.
; Deny registration from anywhere first
; 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.

Here is my extensions.conf:


; Global variables goes here

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

; 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()

; 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 ‘’ ( 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,

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@;transport=UDP’ failed for ‘’ - Wrong password
[Feb 25 11:24:06] NOTICE[3331]: chan_sip.c:28091 handle_request_register: Registration from ‘sip:Yile@;transport=UDP’ failed for ‘’ - 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 Auto (No) No 5060 Unmonitored
outbound_provider Auto (No) No 5060 Unmonitored
3 sip peers [Monitored: 0 online, 0 offline Unmonitored: 2 online, 1 offline]
CLI> sip show registry
Host dnsmgr Username Refresh State Reg.Time N yile 105 Registered Wed, 25 Feb 2015 11:27:18
1 SIP registrations.

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 interface is NATed so that all traffic that goes out the box goes out my 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

Thanks again that was a big help!

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

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.