Incoming call from multiple trunk

I use Asterisk for test automation to generate calls.
Asterisk connects to system with multiple extensions(see details in config).

I try to originate a call from A to B where both A and B are registered from my Asterisk setup.

If insecure=invite, port included in sip.conf, I can originate the call, but on the incoming call will be handled by the first channel that has been registered from my Asterisk. E.g.

I have 3 numbers registered, A,B and C. I originate a call from B to C. Incoming call being handled by A.
I have 2 numbers registered, A and B. I originate the call from A to B. Incoming call being handled by A

If I remove insecure=invite,port than I get the following error message



[May 29 17:30:02] WARNING[1707][C-00000034]: chan_sip.c:17292 check_auth: username mismatch, have <ph nr of A leg>, digest has <>

[May 29 17:30:02] NOTICE[1707][C-00000034]: chan_sip.c:26355 handle_request_invite: Failed to authenticate device "418" <sip:418@host.name>;tag=3F53436E-5B0D71FA0000686B-834F4700

The question is, how to config properly asterisk?

See full extensions and sip.conf

[general]
qualify=yes
tcpenable=yes
canreinvite=no
allowguest=no
srvlookup=yes

register => [uname2]@[host.name]:[pwd2]@[host.name]/[phnr2]
register => [uname]@[host.name]:[pwd]@[host.name]/[phnr]



[[phnr2]]
type=peer
context=CT-[phnr2]
callerid=[phnr2]
trustpid=no
sendrpid=no
canreinvite=no
fromdomain=[host.name]
fromuser=[uname2]
username=[uname2]
defaultusername=[uname2]
insecure=invite,port
disallow=all
allow=ulaw, alaw, gsm
host=[host.name]
secret=[pwd2]
nat=no


[[phnr]]
type=peer
context=CT-[phnr]
callerid=[phnr]
trustpid=no
sendrpid=no
canreinvite=no
fromdomain=[host.name]
fromuser=[uname]
username=[uname]
defaultusername=[uname]
insecure=invite,port
disallow=all
allow=ulaw, alaw, gsm
host=[host.name]
secret=[pwd]
nat=no

#################################### Extensions.conf ##################################
[CT-[phnr2]]
exten => [phnr2],1,NoOp('This is an ARI Test')
same =>      n,Stasis(ST-[phnr2])
same =>      n,Hangup()

[CT-[phnr]]
exten => [phnr],1,NoOp('This is an ARI test')
same =>      n,Stasis(ST-[phnr])
same =>      n,Hangup()


You need to configure the equivalent of Asterisk type=user on the peer. If that is not possible, you will have to bind each one to a different IP address on the Asterisk machine.

I am wondering if it is possibly to tell to Asterisk, which port should be used on Asterisk side for specific peer?

Or, with other words, what is the different between bindport and port?

I haved replicated my problem on a separated environment.
Over here I have two Asterisk server, See configs. First is the one that recievie the reqistrations, the second one will reqister.

If I change the config on the first server to type=user, than I have just receive the following error message:
Forbidden - wrong password on authentication for REGISTER for ‘A001’ to ‘192.168.110.22’

Could you take a look, what else do I miss?

[general]
        qualify=yes
[A001]
        type=friend
        context=incoming
        allow=ulaw,alaw
        secret=Abcd12345!
        host=dynamic
        insecure=invite,port
        
[A002]
        type=friend
        context=incoming
        allow=ulaw,alaw
        secret=Abcd12345!
        host=dynamic
        insecure=invite,port

############## extensions.conf #####################        
[incoming]
exten => 1000,1,Dial(SIP/A001)
same => n, hangup
exten => 2000,1,Dial(SIP/A002)
same => n, hangup


############## server 2 ######################
[general]
	tlsenable=yes
	tlsdontverifyserver=yes
	tlscertfile=/etc/asterisk/keys/asterisk.pem
	tlscafile=/etc/asterisk/keys/ca.crt
	tlscipher=ALL
	tlsbindaddr=0.0.0.0

	qualify=yes
	tcpenable=yes
	canreinvite=no
	allowguest=no
	srvlookup=yes
	externip=89.100.27.2
	
	register => A001:Abcd12345!@192.168.110.22/1000
	register => A002:Abcd12345!@192.168.110.22/2000
		
[1000]
	type=peer
	context=A002EXT
	allow=ulaw,alaw
	secret=Abcd12345!
	host=192.168.110.22
	dtmfmode=rfc2833
	insecure=invite,port
	canreinvite=no
	username=A001
	fromuser=A001
	fromdomain=192.168.110.22

[2000]
	type=peer
	context=A002EXT
	allow=ulaw,alaw
	secret=Abcd12345!
	host=192.168.110.22
	dtmfmode=rfc2833
	insecure=invite,port
	canreinvite=no
	username=A002
	fromuser=A002
	fromdomain=192.168.110.22

################ Extensions.conf from second server######


[A002EXT]
exten => 1000,1,Stasis(ST-1000)
same => n, hangup

exten => 2000,1,Stasis(ST-2000)
same => n, hangup

Why do you need to register? Use static addresses both sides.

1 Like

Hi David,

Sorry, I did not really catch the point on your question: Why do you need to register?
Could you explain please?

Why can’t you just specify the peer’s address at both ends.

Registration is about finding the address, not about security.

I have no option to modify anything on the far end. This is a test automaiton set up, and the Asterisk act as multiple client.