Asterisk as a Proxy/Man-in-the-middle Server

I’m setting up Asterisk as a kind of “man-in-the-middle” server to perform the task of a registration server. Users will register end-user devices against it, but this box must pass the call on to the actual gateway server that has all the billing scripts on it.

like this:
[sip] <-> [GW] <-> [upstream provider]

Each member has his own sip details in the database, and they have been mapped to both the GW and the SIP. The SIP however has all the fancy scripts on it, and the GW has only billing script on it… so here is the problem, i can dial in from GW to SIP no problem:

easy, whatever you dial to get to the GW, now just redial for the SIP, easy… but outbound is where im stuck…

This fails because it thinks its an inbound call. remember the dialplan will use “default” in this case

exten => _X.,n,Set(CALLERID(num)=${CHANNEL(peername)}) exten => _X.,n,Dial(SIP/${EXTEN}
This makes the GW fail because the authentication fails.

So I don’t want to make a Trunk entry for each client - what a pain!!

What i would really like to be able to do is setup the trunk in the dial-plan or at runtime
I saw this:

But i really doesn’t see how this can help… where do you tell it what number to dial?? /extension doesnt work

Contexts are irrelevant to the Dial application.

Your problem is that you cannot set the authentication user for non-sip.conf outbound calls, not that you can’t set the number to dial.

If you want a proxy, you should use a proxy, not a back to back user agent.

I suppose you can always just RTFM…


gives you

an on-the-fly, and authenticated trunk with no need for any [trunk] in the sip.conf

Works perfectly