Asterisk SIP user vs peer
Asterisk SIP 'users' and 'peers' are have been the source of much confusion for Asterisk users.
With newer versions of Asterisk the concept of SIP 'users' will be phased out.
Quotes from Kevin Fleming of Digium on Asterisk Mailing list Dec 23, 2005:
As of Asterisk 1.2, there is no reason to actually use 'user' entries
any more at all; you can use 'type=peer' for everything and the behavior
will be much more consistent.
All configuration options supported under 'type=user' are also
supported under 'type=peer'.
The difference between friend and peer is the same as defining _both_ a
user and peer, since that is what 'type=friend' does internally.
The only benefit of type=user is when you _want_ to match on username
regardless of IP the calls originate from. If the peer is registering to
you, you don't need it. If they are on a fixed IP, you don't need it.
'type=peer' is _never_ matched on username for incoming calls, only
matched on IP address/port number (unless you use insecure=port or higher).
With newer versions of Asterisk the concept of SIP 'users' will be phased out.
Quotes from Kevin Fleming of Digium on Asterisk Mailing list Dec 23, 2005:
As of Asterisk 1.2, there is no reason to actually use 'user' entries
any more at all; you can use 'type=peer' for everything and the behavior
will be much more consistent.
All configuration options supported under 'type=user' are also
supported under 'type=peer'.
The difference between friend and peer is the same as defining _both_ a
user and peer, since that is what 'type=friend' does internally.
The only benefit of type=user is when you _want_ to match on username
regardless of IP the calls originate from. If the peer is registering to
you, you don't need it. If they are on a fixed IP, you don't need it.
'type=peer' is _never_ matched on username for incoming calls, only
matched on IP address/port number (unless you use insecure=port or higher).


Comments
333Re: Multiple registers with the same SIP provider
The solution for me:
type=friend
fromuser=something
trustrpid=yes
I have multiple sip trunk, which are distinguashed by the fromuser. For right callerid presentation I use username from the Remote-Party-Id header. For this i use trustrpid setting.
333Re: Multiple registers with the same SIP provider
Basically all I had to do was to look at the "To" field in the SIP headers and the number of the account from which the call was coming in was there. I changed extensions.conf like this:
Now if a call comes from account with <number1> extension <ext1> rings, and if the call comes from account with <number2> then extension <ext2> rings.
333Re: Multiple registers with the same SIP provider
333Re: Multiple registers with the same SIP provider
333Re: Multiple registers with the same SIP provider
333RE: Multiple registers with the same SIP provider
general
bindport=5060
bindaddr=0.0.0.0
context=default
disallow=all
allow=gsm
allow=ilbc
allow=ulaw
allow=alaw
srvlookup=yes
register => 3377:???????@2x2.2x3.x56.2x6
register => 3378:???????@2x2.2x3.x56.2x6
3377
type=friend
host=dynamic
defaultip=192.168.1.12
username=3377
secret=3377
context=default
dtmfmode=rfc2833
mailbox=3377
callerid="SPA1" <3377>
nat=no
3378
type=friend
host=dynamic
defaultip=192.168.1.12
username=3378
secret=3378
context=default
dtmfmode=rfc2833
mailbox=3378
callerid="SPA2" <3378>
nat=no
provider_line1
type=peer
host=2x2.2x3.x56.2x6
username=3377
secret=???????
context=testA
fromuser=3377
fromdomain=2x2.2x3.x56.2x6
nat=no
provider_line2
type=peer
host=2x2.2x3.x56.2x6
username=3378
secret=???????
context=testB
fromuser=3378
fromdomain=2x2.2x3.x56.2x6
nat=no
provider-in
type=peer
host=2x2.2x3.x56.2x6
context=default
insecure=invite
nat=no
The result is that SIP SHOW PEERS gives me
myserver*CLI> sip show peers
Name/username Host Dyn Nat ACL Port Status
provider-in 2x2.2x3.x56.2x6 5060 Unmonitored
provider_line2/3378 2x2.2x3.x56.2x6 5060 Unmonitored
provider_line1/3377 2x2.2x3.x56.2x6 5060 Unmonitored
3378/3378 192.168.1.12 D 5061 Unmonitored
3377/3377 192.168.1.12 D 5060 Unmonitored
5 sip peers 5 online , 0 offline
Where you can see everything is in the reverse order of sip.conf.
I am guessing here that * works down this list and applies the first rule it can...
333RE: Multiple registers with the same SIP provider
provider.tld ; incoming and outgoing
type=peer
host=2x2.2x3.x56.2x6
username=3378
secret=???????
context=testB
fromuser=3378
fromdomain=2x2.2x3.x56.2x6
insecure=invite
nat=no
Havent really tested it in depth but pretty sure it was one of the things I had tried in arriving at the solution below.
333
333Re: Multiple registers with the same SIP provider
sipphone-inbound
type=user
host=proxy01.sipphone.com
context=incoming-sipphone
With just this entry in sip.conf and my 3 register => statements in sip.conf I get calls in to my extensions file where they are matched against Sipphone's fake number (begins with 1747...)
Unfortunatley I can no longer send outbound calls to Sipphone as I had to remove the following outbound entry in sip.conf:
sipphone-outbound
context=incoming-sipphone
type=peer
indecure=very
host=proxy01.sipphone.com
username=17476489138
fromuser=17476489138
secret=XXXXXXX
fromdomain=proxy01.sipphone.com
The sip.conf entry above was catching all the inbound INVITE messages from Sipphone and asking them to authenticate themselves (407) after which the call would disapear.
I signed up with Draytel for my outbound calls.
I hope we get a better soultion to thie problem from someone....
333Multiple registers with the same SIP provider
I have 3 different accounts with the same SIP provider. That leads me to have 3 different "register" commands on my sip.conf file.
If i issue the SIP SHOW PEERS command I can see the 3 accounts registered, but they are all registered with the same IP/PORT, as my SIP provider sends all the calls from the same IP/PORT (I guess that's pretty normal).
Then, if somebody calls me, no matter which one of the 3 telephone numbers they dialed, the incoming call always match the first register found on my Asterisk box. This is a big problem on my case since I need to know exactly which number the caller person has dialed.
My first thought was that user/password would be great to solve this issue, but now I'm a bit confused.
Any suggestions or ideas on how to re-configure Asterisk to handle this case correctly?