SIP Trunk based context for peering

Hai Everyone,

I have two asterisk Servers installed with version 16X on Centos 7X.

I have 2 SIP Trunks From Telecom Operator that are Terminated at Server1.

And my applications are deployed at Asterisk 2 Server along with Asterisk and calls are getting initiated from Asterisk 2 Server. In this, I have incoming and outgoing services.

Now in this case when am having two SIP trunks from Asterisk 1 and Asterisk 2 Internal SIP trunks calls are getting in the same context for Asterisk 1. Hence am not able to determine the calls are for Operator1 or Operator 1.

Presently I have used come condition based on the Callerid number on the asterisk 1 and distributing the calls to the Telecom operator. But when there is a large call volume the CPU load increasing due to this IF condition. Hence do we have an alternative option where we can get the calls to a different contexts for each internal SIP trunk between asterisk 1 and asterisk 2

Asterisk 1 SIP.Conf

[Server1]
username=Server1
secret=Server1.password
type=peer
context=from-Server2
host=dynamic
dtmfmode=rfc2833
qualify=yes
insecure=port,invite
canreinvite=no
disallow=all
allow=alaw

[Operator-sip-trunk-1]
disallow=all
allow=alaw
type=peer
host=192.168.1.1
port=5060
dtmfmode=rfc2833
insecure=port,invite
context=OperatorPROD1
qualify=yes
nat=yes

[Operator-sip-trunk-2]
disallow=all
allow=alaw
type=peer
host=192.168.1.2
port=5060
dtmfmode=rfc2833
insecure=port,invite
context=Operatorprod2
qualify=yes
nat=yes

Server 2 sip.conf

register => Server1:Server1.password@10.10.10.1:5060/1234

[sip-trunk-1]
disallow=all
allow=alaw
type=peer
host=10.10.10.1
port=5060
dtmfmode=rfc2833
insecure=port,invite
context=PROD1
qualify=yes
nat=yes

[sip-trunk-2]
disallow=all
allow=alaw
type=peer
host=10.10.10.1
port=5060
dtmfmode=rfc2833
insecure=port,invite
context=prod2
qualify=yes
nat=yes

Seems strange that you processing power is so on the edge that a single If line breaks it.

Which technology driver are you using. chan_pjsip allows multiple IP addresses and multiple ports, so is going to make this sort of thing easier. chan_sip would require user type matches on the From header.

Running two trunks over the same physical route doesn’t seem sensible, and it seems that your configuration is actually only creating one trunk.

Caller ID matching can be achieved by using ex-girlfriend logic, using / and caller ID after the extension, but if you are on the edge of a CPU overload, I don’t know if that would be more or less costly than the extra, If line.

OK. It’s the, legacy chan_sip. insecure=port ruins your last chance of distinguishing them with address matches although chan_sip wouldn’t allow multiple ports anyway. It is basically useless in this context. insecure=invite does nothing, because you have no secret, and as you control both ends, if you authenticated you should be doing it both ways.

You should never need nat other than default, for Asterisk to Asterisk, as Asterisk understands NAT. On the other hand, if there is a NAT boundary, you should have externip, etc, on the configuration on the inside.

@david551 - Am using the chan_sip - presently am not able to migrate to pjsip due to some technical concerns.

As I said - I have two SIP trunk Telecom providers and I need t use both for channel capacity. Because based on the Operator I set the CLI on Server2 and finite the calls using that Internal SIP trunk to Server1.

Once the calls are reaching on context based on the condition transferring to the respective telecom operator from Server1.

Using this above I will be able to use the same telecom Operator SIP trunk on multiple asterisk boxes like an SBC.

But on present conditions, the calls from Server 2 to Server 1 reach on the same context hence need to use conditions to bifurcate the calls. It increases the CPU Load.

Do we have an option where we can send the calls to different contexts using the different SIP trunk with Chan_SIP ?

Use type user matches (friend) and set fromuser on the server two configurations.

However, if you are on the brink of an overload, you should be trying to work out why that is happening. Are you really handling 1,000s of simultaneous calls?

@david551 - Yes I Am handling 1500+ Calls on Each SIP Trunks.

If I select user type=friend and set fromuser= the problem is I can’t callerid(num)= because that will overriten by fromuser.

That’s why people use other mechanisms, like Remote-Party-ID, to convey callerid.

@jcolp
Yes . I can even send different variables or SIP header
But again I have to set CALLER ID(num)=new variable which is setting from a different server

WHich will also create the same amount of load on the server.

Do we have a different mechanism by which we can achieve this ?

You don’t have to do that. You enable the sending of RPID on one side[1], and the trusting of RPID on the other. Caller ID is then sent and received using that mechanism without any involvement by you, except for enabling the functionality.

[1] asterisk/sip.conf.sample at master · asterisk/asterisk · GitHub

Joshua didn’t say anything about setting variables.

He basically said set sendrpid=yes and trustrpid=yes.

Is there some reason why you cannot use a load balancing proxy and multiple servers?

Probably a lot more people use FreePBX, than bare Asterisk, and adding one line of dialplan there is probably going to add less 1% to the signalling load, and maybe less than 0.1% to the total load, given the large number of dialplan steps it runs for each call, and that it pretty much frustrated direct media.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.