Asterisk SIP redirect

Discussion in 'UK VOIP' started by Theo Markettos, Apr 24, 2010.

  1. I have an account at a SIP provider, which I want to provide a frontend to.
    For example, I want to tell people to connect to:

    Username: myname
    Password: mypassword

    and it gets redirected to:

    Username: abc123
    Password: secret

    The idea is so that I can change the destination details if I need to. I
    don't want to meddle with the dialplan, though I may want to change the CLID
    (as part of the SIP registration - for the moment is a
    Betamax brand).

    I have an Asterisk server. Is there some way I can do this without having
    to handle (or, worse, transcode) the audio stream? If not, how do I do a
    redirect without intercepting the dialled number?

    Theo Markettos, Apr 24, 2010
    1. Advertisements

  2. This is going to be a commercial issue rather more than a technical one.
    If you are telling the callers outbound server to redirect, there are
    probably no commercial implications. If you tell your provider's
    inbound server to redirect, they are either going to reject or charge
    you for the second leg.

    Provided the call has not been answered, the Transfer application will
    send a redirect. If the call has been answered, this still works to
    some extent, but the error handling is broken.

    Providing your NAT environment allows it, and you don't configure any
    Dial options that require RTP to be retained (recall, or monitoring),
    canreinvite=yes should avoid your carrying the speech path. Commercial
    or security considerations may stop this working, if there is a paid
    service on the circuit.

    Incidentally, in a pure SIP world, without commercial considerations, a
    302 redirect could go right back to the originator. Any outbound
    service provider for the caller might not like this, as they would lose
    the revenue.
    Except for canreinvite, I don't see how you can redirect without messing
    with the dialplan!
    Asterisk isn't a proxy, but a proxy could also forward the initial
    INVITE without adding itself to the final connection path, but again, if
    your outbound service provider is involved, they would likely charge.
    David Woolley, Apr 24, 2010
    1. Advertisements

  3. Asterisk isn't a proxy server, however it can do this - providing a few
    bits of vital information/config file settings are in-place.

    Firstly your asterisk server must not be behind NAT.

    You need nat=no and canreinvite=yes in the sip.conf files (for every

    You need an entry in sip.conf to take the incoming call, and an entry
    in sip.conf to register with the 3rd party SIP service (if accepting
    incoming calls), and a standard entry with username & password for it.

    So the sip.conf entry for your phone needs to land in a separate context,
    and there you'll need something like:

    exten _X.,1,Noop(Incoming call going out to ${EXTEN})
    exten _X.,n,Dial(SIP/outbound/${EXTEN})

    and that's about it. (outbound being the name you assign your 3rd
    party carrier) If you have any tTwW flags in the Dial command then your
    asterisk box will hang-on to the audio stream and not pass it over to
    the third party. (the re-invite won't happen) I'm also not sure if codec
    negotiation will take place correctly between your phone and the 3rd
    party. Sometimes best to fix everything to the same codec.

    You could switch between different 3rd partys with:

    exten _7.,1,Noop(Incoming call going out via sipgate to ${EXTEN})
    exten _7.,n,Dial(SIP/sipgate/{${EXTEN:1}

    exten _8.,1,Noop(Incoming call going out via betamax to ${EXTEN})
    exten _8.,n,Dial(SIP/betamax/{${EXTEN:1}

    and prefix the numbers you dial with 7, 8, etc.

    For occasionaly use, and even if your asterisk box is behind an ADSL
    line (full port forwarding or DMZ host), you probably won't nortice much
    difference, even if the asterisk box does carry the audio, but obviously
    you want to shorten the path as much as possible.

    Gordon Henderson, Apr 25, 2010
  4. Thanks. I'll make a note of that for future reference.

    As my net connection was really poor, and not good enough for debugging
    Asterisk remotely, I eventually did it by setting up Libera Il Voip as a
    proxy with a trivial dialplan. That saved me having to fiddle with Asterisk
    over very slow and flaky SSH.

    Libera Il Voip is simple to set up, if you a) speak Italian or can mangle it
    through a translation website and b) have an Italian tax code (Codice
    Fiscale), which is available from a government website by filling in your
    My Asterisk box is a consumer Netgear router, which isn't exactly strong on
    horsepower. Any kind of transcoding brings it to a grinding halt, so
    avoiding the audio is definitely recommended!

    Theo Markettos, May 1, 2010
  5. Even if you do handle the audio, avoiding transcoding isn't hard. Just
    force the codec in the asterisk box for both legs and make it the
    same in your phone.

    The router ought to be able to handle streams of 24Mb/sec - 2 VoIP calls
    at 24Kb/sec each way ought to be fine...

    (G729 is 24Kb/sec each way down a SIP channel)

    Gordon Henderson, May 1, 2010
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.