SIP client / registration string - wrong context


I’m running Asterisk 1.8.4 on CentOS (from Digium repos). I need to register to a SIP server only to receive calls. Words in UPPERCASE are replaced with my personal values.


user = LOGIN
secret = PASSWORD
type = user
context = MY-CONTEXT

With this config Asterisk registers successfully, but calls received are placed in wrong context - “default” instead of MY-CONTEXT. Actually whole definition of [foo] seems to have no meaning. Without it everything works the same way.

  1. How to set the context for calls received from a SIP server that I register to? (what am I doing wrong)
  2. Is there any link between register string from [general] and client definition? There should be…
  3. The whole idea of “register string” is unclear to me. All data is doubled. An option “register = yes” in client definition would be sufficient, wouldn’t it?

Did you route your DID ?

foo should be NUMBER or type should be peer.

Also, for security reasons, allowguest should be no. You are getting to default because anonymous callers are being allowed and you don’t have a valid entry to match the legitimate ones.

You may find the other side can’t be bothered to authenticate, in which case you may need to use insecure=invite. Don’t do this unless you need it and do not us the port parameter of insecure unless you have specific reasons to believe you need it.

Note type=peer is a better solution than changing foo. foo is actually matched against the from address, so may not be NUMBER.

When I set to “type = peer” and “insecure = invite” it works - call goes to context MY_CONTEXT. However, changing foo to NUMBER with “type = user” does not work. Getting:


with “allowguest = no”.

As I understand, type peer means it will be matched on IP address, while type user is matched on username from registration. I can’t use type peer because I will have multiple registrations on the same server (about 20), all for receiving calls only.

SIP and Asterisk don’t handle that case well. What you will probably need to do is to use a single entry for all incoming calls, then separate them into different contexts in the first level dialplan.

It is better to have a single DID trunk in the true sense, than try to use multiple non-DID (but often misnamed) DID trunks.

My impression is that your sort of problem often comes from using services intended for direct use from SIP telephone, but actually accessing it from a PABX.

quick question… doesnt the fact of adding /NUMBER to the register statement redirect the calls to the extension corresponding to NUMBER ? hence, not being defined, going to defaults ?

The match is done on the from address, not the to address, and only for users or friends. The number on the register is the extension number that will be used in the selected context.

Also, it was only going to default because of the allowguest setting, causing it to use the context from the general section, defaulting to default.

Thanks. I made one peer for all registrations. Actually it’s 3 peer definitions because my HOSTNAME: is resolved to 3 IPs (DNS load balancing), and from these 3 IPs I receive calls. I guess it’s not possible to do it with one peer definition (to prevent from DNS data changes), is it?

My scenario:
I had 20 telephones that registered directly to HOSTNAME. Now I want to use my own PBX. Outbound calls are routed via new (cheaper) trunk. I also get from the trunk 1000 telephone numbers to use. Since I want old telephones’ outbound calls go via new trunk I need them to register to my PBX, not HOSTNAME. In order to receive calls on those telephones PBX needs to register to HOSTNAME.

I still have one little problem, probably not related to registrations. I make a call from GSM to one of old telephones. It goes to HOSTNAME, then to my Asterisk, then to a VoIP gateway. With one type of VoIP gateways - Linksys PAP2T - everything’s OK. With the other type - MaxCom BRV102 - I can hear voice on local phone but not on GSM. Actually for 1 second I can but after that there’s silence. When I sniffer packets on router and Asterisk I see that voice packets start going HOSTNAME <-> Asterisk <-> VoIP gateway, and immediately switch to direct connection HOSTNAME <-> VoIP gateway (no packets thorough Asterisk). Strange that this connection works in one way (I can hear voice on local phone). Asterisk has public IP, VoIP gateway private (EDIT: gateway with public IP works the same). Do you know what can be the reason?