Wrong Context Selection

Environment:
Asterisk 10
Asterisk real-time

I have a trunk defined , with context as “trunk-context”,
and SIP users context as “user-context”. Lets say, i have a SIP user as 1000 , now if any call is terminated through trunk having similar CallerID as 1000 (which is 1000), it results call routing to “user-context” , instead of going to “trunk-context”… Perhaps Asterisk looks at the user identity and found it to be its internal user/peer, and put it in respective context.

Any one have any idea how to prevent it ? , i.e, trunk call should always route to its own context.

Make everything type=peer.

Great! That worked as desired !!
What is the story behind this?

peer matches on address. friend matches on either address or SIP user name.

You may have a security vulnerability if your internal devices are not being challenged for a password.

Thanks David!
Good to know that.