Asterisk Peers from single IP Address

HI All,

At the moment we are using Asterisk with few ISP SIP Trunks where we are getting the calls. We need that every ISP SIP Trunk to get into a different context. We are authenticating all ISP as a friend by IP Address.
To be able to scale the current infrastructure - we put the SIP Proxy (Kamailio) in front - and forwarding all SIP messages to the Asterisk Farm. But, the problem now is that all SIP Messages are coming from one single IP (kamailio) - and we cannot any more to distinguish between ISP and send calls to the correct context. I was looking on the internet and I found that this could be possible by changing 'From: ’ header and for every SIP Trunk add userfrom field - but in this case, the callerid(num) variable will not be available in asterisk or will be the wrong one. Is there any other methods to solve this issue?

You could add a SIP header in Kamailio which identifies which one it is from and then in the dialplan examine the header and use a Goto to the correct context.

Note that friend is pointless, and can cause problems, if you are authenticating on IP address. Use peer.

I’m not certain, but I think that chan_sip can discriminate on remote port number and that chan_pjsip can also do so on local port number.

If they are all going through Kamailio then it’s the same IP address and port, the only difference can be expressed in the signaling itself.