Need Config for unknown DID, do not answer

I need to not answer an incoming sip trunk call whose DID is not known to Asterisk.

By this I mean, do not answer and play a message and hangup, but do not answer at all and return a SIP 404 (I don’t have that DID).

I have not been able to come up with the correct configuration to do this. Please advise.

Thank you

Use a separate context to handle incomming calls from SIP Trunk. In that context, list all the DID’s that you have. At the end you use a catchall dialplan rule (_X.) that executes Congestion() or Hangup(). Check details about Hangup application if you want Asterisk to reply with a specific SIP message. An example of DialPlan would be:


exten => DID1,1,Application
exten => DID1,n,Application

exten => DID2,1,Application
exten => DID2,n,Application

exten => _X.,1,Hangup()

every attempt to use congestion or hangup answers the call before responding. I need to not answer the call. Will your suggestion do that?

Show us your dialplan.

Hangup will definitely not answer the call. I am pretty sure that Congestion will not do so either.

To create a 404, you should hangup with Hangup(1).

Ok, I will try again. I am using FreePBX and modifying extensions.custom.conf with the code.

I have not been able to find a programmers handbook for Asterisk to explain the format of code and how the compiler treats context labels and repeat entries, etc.

By default FreePBX answer all number with ss-noservice, if you want to hangup you need to change the trunk context or the inbound route pointing to your custom context and finally if all of that failed you have one more option: override the dialplan using the extensions_override_freepbx.conf file but that is harder than change the context of your trunk.

Yup. This sounds suspiciously like something I heard about from another location.

On the chance that is is, I’ll say that this isn’t an Asterisk issue, it’s a configuration issue, and the configuration is driven by FreePBX. Asterisk, including version 11, operates just fine.

How about this as a documentation issue (or lack of). Amont others, the terms answer and hangup seem to be used for a number of possible responses to calls, which confuses me greatly. Where is the designed behavior written up. Almost all of what I can find is just hope to set up Asterisk and is limited in scope.

Also, “Asterisk works just fine” is not a definition of anything.

The help I am seeking is to understand what Asterisk is doing when I have configure the trunk (in this case using FreePBX) and a call comes in with an unconfigured DID. If it is not doing what I need (don’t answer the call and respond with a SIP 404) how do I “configure” it to do that?

So far, what I am getting is not anything I can translate into a solution or is a suggestion of where I can go to find the detailed solution.

I am grateful for peoples help but, so far, the community support forum is not working.

If you are familiar with asterisk config my above sentence should be very clear, but since you are using freepbx I guess you have lack of knowledge about vanilla asterisk, freepbx handle very different the dialplan and it handle all via the GUI. If you want to have 100% control of asterisk uninstall freepbx and create the dialplan from scratch.

Said that, if you want step by step guide you should move this thread to the job forum.

Again your best solution is change the context of your trunk per example ext-did.

For more information and help check the FreePBX’s wiki.

For a start, trunks are FreePBX concepts, not Asterisk ones. SIP doesn’t make a clear distinction between what FreePBX calls trunks and what it calls extensions (Asterisk uses extension in a different sense from FreePBX).

For support on FreePBX, you should use the forums at

Because it is a GUI, it may well not be possible to do what you want, except by completely bypassing it, e.g. with the special context.