VoIP Cookbook: How to route to PSTN and Cellular in OpenSIPS

From OnnoWiki
Jump to navigation Jump to search

Basically, we need an Analog Telephone Adapter (ATA) to interconnect a VoIP network to PSTN or Cellular network. In this example, we assume

  • ATA is located at IP address 192.168.0.200
  • ATA is using port 5061
  • Area code for PSTN is 021
  • Area code for Cellullar is 08

We need to add to the opensips configuration file

/usr/local/etc/opensips/opensips.cfg

For example, to be able to use the ATA to call PSTN from all host / domain

# attempt handoff to PSTN 
if (uri=~"^sip:021[0-9]*@*") {
     rewritehostport( "192.168.0.200:5061");  ##  192.168.0.200:5061 is the ATA
     route(1);
     };

To restrict the call to PSTN only from mydomain.com

# attempt handoff to PSTN
if (uri=~"^sip:021[0-9]*@mydomain.com") {     ##  caller registered to mydomain.com
     rewritehostport( "192.168.0.200:5061");  ##  192.168.0.200:5061 is ATA
     route(1);
     };

To be able to use the ATA to call Cellullar from all host / domain

# attempt handoff to cellullar
if (uri=~"^sip:08[0-9]*@*") {
     rewritehostport( "192.168.0.200:5061");  ##  192.168.0.200:5061 is ATA
     route(1);
     };

To restrict the call to Cellular only from mydomain.com

# attempt handoff to cellullar
if (uri=~"^sip:08[0-9]*@mydomain.com") {      ##  caller registered to mydomain.com
     rewritehostport( "192.168.0.200:5061");  ##  192.168.0.200:5061 is ATA
     route(1);
     };


See Also