Posts Tagged ‘openser.cfg’

OpenSER/OpenSIPS is well known as a robust, powerful SIP server. But one big lack of OpenSER/OpenSIPS is that it doesn’t have a gateway interface to PSTN network. In this case, you’ll have some options. You can use a router with an FXS/FXO card or using Asterisk with Digium cards as a gateway server.

If you’re choosing to use Asterisk with Digium cards as a gateway server, you’ll need to route certain calls destination (such as to PSTN) to this server to be forwarded to PSTN network later. To add a route in OpenSER/OpenSIPS, you can edit openser.cfg or opensips.cfg.

Don’t be afraid editing these files, but don’t forget to always make a backup 😀

Openser.cfg or opensips.cfg consists of four main parts:

Global parameter

This section is used to set common configuration such as logging, debugging, fork

Module loading

OpenSER/OpenSIPS modules will be loaded here

Module parameter

Each module have parameters which will be configured here

Routing

Routing section is used to configure routing of incoming SIP messages

Route certain calls will be added in routing section. Because SIP uses INVITE to initiate a call, you’ll need to find this line:

# account only INVITEs

if (is_method(“INVITE”)) {

setflag(1); # do accounting

}

We will use prefix based routing to difference calls. For example, if you use destination number with prefix of 8 to be routed to Asterisk with IP address 192.168.1.1, the routing script will be like this:

if (is_method(“INVITE”)) {

if(uri=~”^sip:[8] @*”) {

rewritehostport(“192.168.1.1:5060”);

route(1);

}

setflag(1); # do accounting

}

The function rewritehostport is used to replace the destination host and port of an SIP message header. The uri=~”^sip:[8] @*” will be match to any calls to destination number with prefix of 8 and any SIP server host.

Better try to know more 😀