Please help! Need help with dealing with multiple physical locations and 911

Hello. I am very new to asterisk and could use some help.
I have 13 different locations, all spreed out across town…some in neighboring towns.
I have a single asterisk server and single truck provider located at our main office that servers them all.
There is not extension standard or pattern. users will regularly move offices, taking their phone/extension with them.
This is causing a big headache when 911 has been dialed, as the call is being routed to the wrong 911 office.
I can designate a cid for each location with the provider, so no problem there. I think the most consistent way to address this would be by the end points IP address. It looks like res_pjsip_endpoint_identifier_ip will get me the IP.
My problem is that I have no idea how to use it nor change the CID based on the IP when 911 is called.

Any help would greatly be appreciated.

The res_pjsip_endpoint_identifier_ip module isn’t for getting the IP address, but for matching an incoming request to an endpoint based on the IP address. The CHANNEL dialplan function[1] allows you to retrieve the IP address and port (pjsip,remote_addr) of the request in the dialplan. You would need to split it, but it would give you the IP.


Did I understand correctly that moving your office itself is not a problem, but it also changes the police station that you need to call for 911?

I don’t know about you, but in our country any call to the police is always sent to the central office, and the city duty officers themselves contact regional police stations and patrols.
Maybe you can also direct calls to the central office?

That is not how emergency calling in the US works. A call with no identifying information will get routed someplace but that is not going to be a helpful someplace.

Any location providing emergency calling is legally required to validate that the emergency calls are showing the correct location of the caller in the PSAP (Public Safety Answering Point) system.

What @speedy01 is saying is that his users have no technical issues using their specific extension between locations. But their assigned caller ID that is used for a call to a PSAP system needs to be modified programaticly, by asterisk, based on the IP address of their endpoint.


ogogon. I think you misunderstood or I was not very clear. likely i wasn’t clear. we have the central office in town1, but a branch in town2, and another in town3. each town is serviced by a different emergency service provider. Also, I need to ensure that each locations address is sent correctly. for example, if branch3 (in town3), calls 911, than it would resolve to its address and not the central office located in town1…
Of course this only needs to be checked when dialing 911.

@jcolp Thanks for the link. I’ll check it out. Any insight on how I would split it?

You can probably use the CUT[1] dialplan function.


1 Like

here is a rough sample using the FreePBX trunk predial hook to get the IP.

exten => s,1,NoOp()
; Check if outbound route marked emergency
exten => s,n,GotoIf($["${EMERGENCYROUTE}"=="YES"]?emergencyrouteused:skipvalidation)
exten => s,n,Hangup()
; The call was an emegerncy dial, do no processing, but note the log.
exten => s,n(emergencyrouteused),NoOp()
exten => s,n,Log(NOTICE, 911 was dialed by extension ${FROMEXTEN})
exten => s,n,Set(remote_addr=${CHANNEL(pjsip,remote_addr)})
exten => s,n,Set(ip_addr=${CUT(remote_addr,:,1)})
;;Add you logic here to set the CID based on IP.
; stuff here!
; Force the CID on the Trunk and then let the call go.
; debug dump and hangup. obviously remove once all done.
exten => s,n,DumpChan
exten => s,n,Hangup()
; The call was not en emergency, nothing else to do.
exten => s,n(skipvalidation),NoOp()

These are the two variables.

1 Like

I can offer one more solution. On Wikipedia it is written that the PSAP system is able to automatically route to the destination a call from a mobile phone.

You need to equip your offices with SIP-GSM terminals, and send calls to the 911 number through them. Let taxpayer money work for you.

thanks @JaredBusch. We are using freepbx (I cross posted this question there too), so this is very helpful! thank you again.

Why pay for a cellular connection for no reason? This cost, in equipment, monthly fees, and setup time would be excessive compared to a simple (once designed) bit of dialplan.

@JaredBusch @jcolp
I think I’m going to need some hand holding on this. Id happily pay for professional services on this…DM me if either of you are interested…

I work for Sangoma, I do not do consulting.

@jcolp Do you know if this something that Sangoma paid support could help with or do?

I’m not familiar with the support offerings provided for FreePBX, the website may have information.

They would most likely be able to help you, yes.


I have an asterisk server with ~100 extensions, across 2 sites (1 with just 3 extensions and rest on the main site).
Being bit of a control freak, I have all my IPPhones on static IPs which make it easier for me to track down issues.

Not sure if you can have something like that so that you have fixed IPs for all IPPhones and create dialplan based on subnets.
hope this helps and sorry if I am paraphrasing anyone!!

thanks @JaredBusch for pointing me in the right direction. after a bit of reading, trial and error, and a lot of coffee, I think I have a working solution. Thanks again!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.