Let's say I have an Asterisk system with a bunch of connections: there are phones (who register itself with *) and providers (who wish to establish SIP trunks to put a lot of calls over, with different Caller IDs).

Here is my vision about how calls should be placed over an authenticated SIP trunk: remote end of SIP trunk should send INVITE's with From field set to it's identity (username for authentication) and Contact field set to what should be Caller ID for this call.

Is that true?

Why I believe this should be true: now, I can not specify username/secret and host=<IP> -- for remote end to register I need to say host=dynamic. So, I can setup "pseudo-trunk" as a bunch of extensions, or I need to setup trunk with host and no authentication. No authentication is bad.

So, is the above true? And will asterisk match peers by looking at From field and use Caller ID from Contact field?

If that is not true --- how an authenticated SIP trunk should work?


2 Answers 2


Read "asterisk the future of telephony" o'rellys book

it have all sip protocol nice described.

your qestion can be solved as




on both side and no register string


  • I believe, it can not be solved like this. It is actually about something else? Let's say remote end has it's asterisk behind NAT? -- I will receive a lot of "noise" from that IP. Won't I?
    – brownian
    May 12, 2012 at 12:36
  • In general case I do not know what's at the remote side, not always asterisk, not always with no NAT. That's why I am asking "how it (being authenticated) should work".
    – brownian
    May 12, 2012 at 12:47
  • please read orelly book. you just missing alot of thing. authentification will not depend of nat or peer type at all.nat=yes will just send packets not to advertised port, but to port from which packet got.
    – arheops
    May 13, 2012 at 4:38
  • you are answering another question, i still believe. OK, let me put it in another words: how From and Contact fields should be filled in INVITEs over a SIP trunk (one login/pass, a lot of phones)?
    – brownian
    May 13, 2012 at 9:53
  • That depend of call scenario. You can check that by setup asterisk and do from console "sip set debug on".or reading doc online,book i refer u have example
    – arheops
    May 19, 2012 at 17:05

So, the above (about From and Contact) may be true, but not required to be true. Will it work or not may depend on actual peers sonfigurations.

When * receives INVITE request with "wild" From (a number that is "not assigned" to any peer), it responses with Unauthorized, adding authentication header with no any username field (in contrast: when * receives INVITE with a "valid" peer name in From, so it can match peer for incoming call, it includes username in authentication header).

This response should be enough to authenticate: the client sends "the same" INVITE with the same From and Contact, and with Authorization header with a valid username field. Asterisk then matches incoming peer on given username value.

Actually, any phone can behave like this; so there is no distinct difference between "SIP phone" and "SIP peer" in SIP. RFC 3261 does not contain a single "trunk" word.

ps. Please, if someone will explain things better, I will be glad (and, for sure, accept better answer).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.