Mutiple SIP trunk between the Asterisk servers

Hai Everyone,

I have two asterisk servers installed with Asterisk 16.

Asterisk Server 1: 10.10.10.10
Asterisk server 2: 10.10.10.11

I have created two SIP extensions on Server 1 and registred those extensions on Server 2. And I have also given different context name fo both. Below are my details.

On Server 1 SIP.conf

[test]
username=test
secret=123456
type=friend
context=from-test
host=dynamic
dtmfmode=rfc2833
qualify=yes
deny=255.255.255.255/255.255.255.255
permit=10.10.10.10/255.255.255.0
insecure=port,invite
canreinvite=no
disallow=all
allow=alaw

[test1]
username=test1
secret=1234567
type=friend
context=from-test1
host=dynamic
dtmfmode=rfc2833
qualify=yes
deny=255.255.255.255/255.255.255.255
permit=10.10.10.10/255.255.255.0
insecure=port,invite
canreinvite=no
disallow=all
allow=alaw

And I have registered the same on Server 2 :slight_smile:

SIP.conf

register =>test:123456@192.168.50.3:5060/1234
register =>test1:1234567@192.168.50.3:5060/12345

Also added the below line to make the call from Server2 to Server1

[test]
disallow=all
allow=ulaw,alaw
type=friend
username=test
secret=123456
;host=192.168.50.3
host=dynamic
context=from-test
port=5060
dtmfmode=rfc2833
insecure=port,invite
qualify=yes

[test1]
disallow=all
allow=ulaw,alaw
type=peer
username=test1
secret=1234567
context=from-test1
host=dynamic
port=5060
dtmfmode=rfc2833
insecure=port,invite
qualify=yes


The problem which is facing: While making the call from server 2 to Server1 using any trunk its always getting answered on context from-test1.

I want to dial to different contexts with both SIP trunk. Like
1.While making the call from server 2 using test it should get an answer on server 1 context from-test,
2.and while making the call from server 2 using test1 it should get an answer on server 1 context from-test1.

Can anyone help with this.

Have you considered using IAX for linking Asterisk systems? For example:

; Office A - iax.conf

[officeB]
type=friend
host=X.X.X.X
trunk=yes
secret=welcome
context=incoming_officeB
qualify=yes
disallow=all
allow=ulaw
allow=alaw

; office A - extensions.conf

[incoming_officeB]
include => internal-extensions

[internal-extensions]
...
exten _72XX => Dial(IAX2/officeB/${EXTEN})
    same => n,Congestion()
    same => n,Hangup()

; Office B - iax.conf

[officeA]
type=friend
host=x.x.x.x
trunk=yes
secret=welcome
context=incoming_officeA
qualify=yes
disallow=all
allow=ulaw
allow=alaw

; Office B - extensions.conf

[incoming_officeA]
include => internal-extensions

[internal-extensions]
...
exten => _71XX => Dial(IAX2/OfficeA/${EXTEN})
    same => n,Congestion()
    same => n,Hangup()

This only denies the broadcast address!

SIP trunk is an overused term, but here you only need one of them. You can maintain any distinction by modifying the the digit strings.

Both sides should be host=xx.xx.xx.xx and type=peer. You would normally use symmetric secrets, in which case you need to disable insecure=invite. If using asymmetric secrets, you should use secret and remotesecret, and still disable insecure=invite.

i have tried this as well. Still the call is going on the Same Context.

I dont wanted to IAX

You mean peer, rather than channel. What I was suggesting would only have one peer (one trunk as you call it). You would use the dialplan to route calls differently, and to strip off the routing prefix.

Not wanting to use something is not a valid reason not to use it.

1 Like

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