Search code examples
asterisksipvoip

Route Call in Asterisk Server


I have a scenario in which I want to route calls to sip a server from Asterisk but I want to do some thing like this

the sip server is running on : 192.168.1.10 and Asterisk server is running on : 192.168.1.4

client Diales---->sip:[email protected]>To Asterisk and then Asterisk route the calls------->sip:[email protected] --------> sip server

Can someone tell me how can I do this in Asterisk configuration routing file .


Solution

  • As os11k said, you need SIP trunk to do this. I'll add some detail information about issues we encountered when we setup SIP trunk between two cities.

    Add a SIP trunk in sip.conf

    • Make sure you put sendrpid=yes in the SIP trunk configuration, or, 192.168.1.10 will not get the caller id.
    • Optionally, you may want to set context of the SIP trunk to a different context rather than default, say context=sip-server-192-168-1-10.
    • Optionally, you may disallow or allow some codecs if 192.168.1.10 only works with specific codecs.

    SIP trunk sample

    [general]
    register => SIP_ACCOUNT:SIP_PASSWORD@TheOtherSipServer
    
    [TheOtherSipServer]
    type=peer
    context=sip-server-192-168-1-10
    
    host=192.168.1.10
    defaultuser=THE_ACCOUNT_HERE
    fromuser=THE_ACCOUNT_HERE
    remotesecret=THE_PASSWORD_OF_ACCOUNT_HERE
    
    ; if you want to send the remote caller id to 192.168.1.10, then set sendrpid=yes .
    ; you also need to trust the remote caller id in 192.168.1.10 .
    sendrpid=yes
    
    ; if 192.168.1.10 can dial out from here, you need to set trustrpid=yes so you can get the caller id
    ;trustrpid=yes
    
    ; if 192.168.1.10 is picky on codecs
    ;disallow=all
    ;allow=THE_CODEC_NAME_ALLOWED_BY_THE_OTHER_SIP_SERVER
    

    Setup dial plan in extensions.conf

    Dial is all you needed unless you need special requirement.

    Dialplan sample

    [globals]
    SIPTrunk=SIP/TheOtherSipServer
    
    [sip-server-192-168-1-10]
    ;exten=>111,1,Dial(SIP/TheOtherSipServer/111)
    exten=>111,1,Dial(${SIPTrunk}/${EXTEN})