Search code examples
siptwiliosip-serveropensips

OpenSIPS and Twilio Elastic Sip Trunking


I'm very very new to the world of VoIP, so please forgive my terminological inaccuracies.

I have just installed ( on to a remote server ) the OpenSIPS software.

I have provisioned a Twilio Elastic SIP Trunk which has it's Origination SIP URI set to the IP address of the OpenSIPS server ( but it prepended with the protocol 'sip:' )

I have two iPhones with some VoIP apps, that allow me to specify Auth Name, Auth Password, Username, Display Name, Domain and SIP Proxy.

In OpenSIPS i have created a domain ( with the IP of my server ) also, i created two users ( on that domain ) and gave them Aliases of 100 and 101.

The software on the iPhones claims that it has 'registered' with the OpenSIPS server, so I have to accept that.

I believe that my configuration of the Twilio SIP Trunk is correct, on the basis that there aren't many settings to set, and they all look correct, and make some kind of logical sense.

What i cant figure out from here, and not for lack of searching the web, watching hours of webinars etc, is how do I get OpenSIPS to send outbound calls through to the Twilio Trunk, and also get the handsets to ring on incomming calls, and Twilio's SIP Trunk has a Termination SIP URI of xxxxxx.pstn.twilio.com which is ( im guessing ) supposed to be entered somewhere in to OpenSIPS but I cannot see how to configure this.

I'm looking for something that is a guide on how to 'connect' OpenSIPS to the Twilio Elastic Sip Trunking service.

Any help appreciated...


Solution

  • So, I'm guessing you want to set up an OpenSIPS instance which acts both as SIP registrar and basic SBC, by simply forwarding all outgoing traffic to the Twilio SIP trunk.

    SIP Registrar

    It looks like you've already handled the registrar part of OpenSIPS scripting. You can always generate a basic configuration that handles user registrations with:

    make menuconfig
        "Generate OpenSIPS script"
        "Residential script"
    

    To list the currently registered OpenSIPS users:

    opensipsctl ul show
    

    SIP Session Border Controller (basic routing)

    - managing outgoing traffic

    Here are a few useful scripting mechanisms:

    • $ru / $rU / $rd variables (management of Entire SIP Request URI / Just username of R-URI / Just domain of R-URI) - do all necessary changes (i.e. force the R-URI to be xxxxxx.pstn.twilio.com...)
    • $du variable - (management of Outbound Proxy) - this will help us route to the Twilio SIP trunk. Setting a destination URI, then doing t_relay() will simply proxy the current request to the specified destination. For a more advanced routing mechanism (i.e. you need to route to a bunch of trunks), consider using the dispatcher module, which supports using a cached SQL table populated with SIP destinations.

    - managing incoming traffic

    • the registrar module functions should be enough for this (test with lookup() or registered(), then just do t_relay()). They will verify if your iPhones are currently registered on the OpenSIPS server.