Wednesday, January 26, 2011

Asterisk Server with SIP Account Routing to Cell Phones

I'm having trouble finding the exact documentation to do the following:

I have a SIP Account. I want my Asterisk Server on a VPS somewhere in the United States to accept the credentials of the SIP Account. When people call into my SIP account phone number at 111-222-3333 extension 55, it should re-route the call to my cell phone which is located somewhere in Canada.

Can anyone tell me how to do this? Or refer to me the relevant documentation?

  • You should do basically 2 things:

    1. Setup Asterisk server to allow proper registration of your SIP account. This is done configuring the SIP credentials at /etc/asterisk/sip.conf
    2. Configure Asterisk dialplan to map extension 55 as a dialout to your cellphone. This is done at /etc/asterisk/extension.conf

    You will find extensive documentation about how to do this at the voip-info.org site: sip.conf and extension.conf). This other link seems to be a good example of what you need.

    Heres a small example on how it could look like:

    sip.conf

    [mysipprovider] 
    type=peer 
    secret=password 
    username=2345 
    host=sipserver.mysipprovider.com 
    fromuser=2345 
    canreinvite=no 
    insecure=very 
    qualify=yes 
    nat=yes 
    context=from-mysipprovider ; this section will be defined in extensions.conf 
    

    and at the extension.conf:

    [from-mysipprovider]
    exten => 55,1,Verbose(1|Echo test application)
    exten => 55,n,Dial(SIP/mysipprovider/5551234); Here is the outbound call, the exact dialstring depends on outgoing provider and channeltype
    exten => 55,n,Hangup()
    
  • Alright, I got things to work. This is EXACTLY what my sip.conf and extensions.conf looks like, I left all the other configuration files untouched

    sip.conf - a) replace [username], [password], [host] and [port] with the appropriate values

    b) because my SIP provider is very finicky, I had to try various values for [host], and sometimes the [host] in the register => line was a different value from [host] in the host= line (but this may not be a problem for others)

    [general]
    register => [username]:[password]@[host]:[port]
    context=default
    
    [mysipprovider]
    type=friend
    secret=pass
    username=[username]
    host=host
    port=5070
    fromuser=[username]
    canreinvite=no
    ;insecure=very
    qualify=2000
    dtmfmode=inband
    nat=yes
    

    extensions.conf

    [default]
    exten => s,1,Answer
    exten => s,n,Wait(1)
    exten => s,n,Playback(vm-extension)
    exten => s,n,WaitExten()
    
    
    exten => 55,1,Dial(SIP/mysipacc/3332221111) ; extension 55 calls phone 3332221111
    exten => 55,n,Hangup
    
    exten => 66,1,Dial(SIP/mysipacc/1112225555) ; extension 66 calls phone 1112225555
    exten => 66,n,Hangup
    
    From John

0 comments:

Post a Comment