PSTN to OpenSIPS to next SIP destination

1k views Asked by At

I have worked with Asterisk for years but I am very new to OpenSIPS. What I need is to have calls come in from our DID provider to the OpenSIPS server then redirect them to another SIP URI.

Something like this:

DID Origination Provider -> OpenSIPS -> next SIP server

Basically I need the OpenSIPS server to sit between my DID provider and and Plivo which is basically a Twilio type service.

I have installed OpenSIPS and the control panel GUI. Using the GUI I have successfully setup calls to go from the DID provider to any of the the SIP phones I have registered to OpenSIPS, calls work fine.

I need to spend a lot of time learning the routing logic and such for OpenSIPS which I am willing to do but, at the moment I am trying to solve the problem and hoping there is a solution using the OpenSIPS CP. If not, I am hoping for an example on how to set this up in the config files.

Any help is appreciated, I have been at this for several days and have searched Google and Youtube, looked over tutorials, watched videos, spent time reading the book etc. So, not for lack of effort. This will obviously be quite a learning curve but, I am hoping for a little help to get this specific task done sooner than later.

Thanks again, in advance for any help. Using the latest 2.4 version of OpenSIPS on Debian 8 if that matters.

1

There are 1 answers

3
Liviu Chircu On

First of all: there is no way of doing this via CP. The OpenSIPS CP is meant to work on a lower level, helping you manage your data (users, routing rules, routing destinations, dialplan rules, TLS certs, etc.). Any custom, higher-level logic linking these pieces of data together needs to be scripted within opensips.cfg.

Fortunately, the default opensips.cfg already covers 90% of what we need here. So, instead of routing calls to users and going straight through to Plivo, you should remove this part:

# do lookup with method filtering
if (!lookup("location","m")) {
    ...
}

... and then either:

  1. preserve the Request-URI, but make the message route out to Plivo when doing t_relay():
$du = "sip:your_plivo_ip:5060"; # set a "destination URI"
  1. rewrite the Request-URI of the SIP message, so it will head out to Plivo upon doing t_relay():
$ru = "sip:your_plivo_ip:5060"; # rewrite the "Request-URI"

And that's it! The default script already does record_route(), ensuring the proxy stays within the path of all mid-call requests.