Documentation.Tutorials-Redirect History

Hide minor edits - Show changes to markup

May 16, 2013, at 07:13 PM by -
Changed line 1 from:
Documentation -> Tutorials -> SIP Redirect
May 09, 2013, at 05:33 PM by -
Changed lines 1-2 from:

SIP Redirect with script example

April 24, 2013, at 08:57 PM by -
Added lines 1-38:

SIP Redirect with script example

You will need to load the module so you can run external scripts

loadmodule ""

In this snippet I am restricting by IP address and by a IP range. You will notice that I used a regular expression to determine the IP range You will also notice in this example the use of the function exec_dest(). This function calls an external script and assumes that the script returns a SIP URI. Then sets the "Contact" header to the returned SIP URI. You can also use pseudo variables in the exec_dset() function. In this example $tU (To Username) and $fU (From Username) are used.

route {
    if ( src_ip == 10.x.x.x || src_ip =~ "^192\.168\..*") {
        if(method == "INVITE") {
            exec_dset("/usr/local/bin/local_check $fU $tU");
            sl_send_reply("302","LCR Redirect");
        } else {
    } else {
        sl_send_reply( "403", "You are not allowed here!" );

Now here is just a dummy script that echoes a SIP URI. You can make it any script you want but is needs to output a valid SIP URI to standard out: (IE.



NOTE: To get this to work correctly with Asterisk you need to add "promiscredir=yes" to the general section of your sip.conf

Page last modified on May 16, 2013, at 07:13 PM