Asterisk Configuration - SIP

*****NOTE*****This document is deprecated. Please see OnSIP Trunking. 07/30/14 *** Please note that if there is a Firewall or NAT (Network Address Translator) between your Asterisk and Junction Networks, the following configuration instructions may not be applicable. ***

Configuring SIP

  1. Go to and login. Go to the Configuration tab and note your VOIP username and password.

    Edit /etc/asterisk/sip.conf, replacing MY_USERNAME and MY_PASSWORD in the "register => " statement below with your VOIP username and password.
    ; The "general" context should already exist in sip.conf
    ; Add a line to register with with Junction Networks
    register =>
    *** Please note that your VOIP password is *NOT* the same as the password you selected when you signed up for service and now use to access your account information via the Junction Networks web site. You can find your OnSIP VOIP username and password by logging into the Junction Networks web site at and going to the VOIP page. *** Note: Make sure your username (SIP Address) and Auth Username are the same. If they are not, please edit your SIP address to make them identical in the OnSIP Admin interface.

  2. Edit your /etc/asterisk/sip.conf and create a peer entry for Junction Networks
    ; A new entry for calls to Junction Networks
    [jnctn]                   ; <-- Should match peer in extensions.conf
    *** Please note:
    "insecure=invite" instead of "insecure=very" in Asterisk 1.6 and above

    Your VOIP password is not the same as the password you selected when you signed up for service and now use to access your account information via the OnSIP web site. You can find your OnSIP VOIP username and password by logging into the OnSIP web site at and going to the VOIP page. ***

  3. Edit the /etc/asterisk/extensions.conf and add a context which will send outgoing calls to OnSIP.

    Give those users who are going to be making calls via OnSIP access to this context. Examples...
    ; ---------------------------------------------------------
    ; This context is used to send all outgoing calls to
    ; Junction Networks for connection to the PSTN.
    ; ---------------------------------------------------------
    exten => _1NXXNXXXXXX,1,Dial(SIP/${EXTEN}@jnctn)
    exten => _1NXXNXXXXXX,2,Congestion()
    exten => _1NXXNXXXXXX,102,Busy()
    ; ---------------------------------------------------------
    ; Another example where the caller-id number is set first
    ; ---------------------------------------------------------
    ;for Asterisk 1.6 ONLY set the CallerPres variable
    exten => _1NXXNXXXXXX,1,Set(CALLERID(num)=15555551234)
    exten => _1NXXNXXXXXX,2,Dial(SIP/${EXTEN}@jnctn)
    exten => _1NXXNXXXXXX,3,Congestion()
    exten => _1NXXNXXXXXX,103,Busy()
  4. Add an extension to the default context in your extensions.conf for processing incoming SIP calls. The default section most likely already exists in your extensions.conf and may be named [default].

    Here is an example which answers the call and reads back any digits you press.
    ; ---------------------------------------------------------
    ; [default] is the default context defined in the [general] 
    ; section in your sip.conf -  the default context for 
    ; incoming calls. This is where your custom incoming 
    ; call processing should go.
    ; Replace 1NXXNXXXXXX in the exten => lines below with
    ; the DID you are subscribing to. If you are subscribing
    ; to multiple DIDs, add entries for each DID.
    ; For sample purposes, this section will read back the
    ; dialed number and then test DTMF by reading back each
    ; digit pressed by the caller.
    ;      *** Unauthenticated Incoming SIP Calls ***
    ; Note that Junction Networks expects you to receive 
    ; unauthenticated SIP calls and cannot guarantee that 
    ; calls will always come from the same IP address or
    ; network address. Please take this into consideration 
    ; if you attempt to direct calls from Junction Networks 
    ; to a context other than the "default" context defined 
    ; in the [general] section of your sip.conf - such a 
    ; configuration may appear work for a period of time 
    ; and then stop working when calls arrive from another 
    ; IP address. Furthermore, note that anyone may be able 
    ; to access this context, so be very careful using 
    ; "extenion patterns" in this context (for example, 
    ; DO NOT match on _1NXXNXXXXXX as you will likely create 
    ; a security hole by allowing general access to your 
    ; Junction Networks account).
    ; ---------------------------------------------------------
    [default]  ; <-- Should match the context specified
               ;     in the [general] section of sip.conf
    ; Replace 1NXXNXXXXXX in the lines below with your DID
    ; For example, exten => 15555551234,1,Playback(beep)
    exten => 1NXXNXXXXXX,1,Playback(beep)
    exten => 1NXXNXXXXXX,2,SayDigits(${EXTEN})
    exten => 1NXXNXXXXXX,3,Goto(testdtmf|s|1)
    ; This context is used by the sample [default]
    ; context above to read back each digit you press.
    exten => s,1,Background(beep)
    exten => s,2,ResponseTimeout(60)
    exten => s,3,WaitExten(10)
    exten => _x,1,SayDigits(${EXTEN})
    exten => _x,2,Goto(testdtmf|s|1)
    exten => i,1,Goto(testdtmf|s|1)
    exten => t,1,Hangup
  5. Finally, remember to "reload" your Asterisk configuration. From a shell prompt you can type:
    asterisk -r -x "reload"
    At this point you should be able to confirm that you are registered with Junction Network for incoming calls.

    From a shell prompt you can type:
    asterisk -r -x "sip show registry"
    This should report your "State" as "Registered". If your "State" is "Rejected", return to step 2 and confirm that you have used the correct username and password.

    That's it. Once you've confirmed that you are receiving incoming calls, you should modify your dialplan to appropriately dispatch your calls.
Was this article helpful?
0 out of 0 found this helpful