Thanks all, for the discussion!
To clarify, I have two trunking servers that receive 11 digits DIDs from several providers. I have numerous FreePBX servers with trunks to those servers currently set up to accept 11 digits.
I am adding trunks to a few dozen new servers, all of which currently accept 10 digits directly from their current upstream provider. We are porting all DIDs from the current provider on these new servers to one of the existing providers already set up on the trunking servers.
This addition highlighted the need to unify our internal numbering plan, and we decided on 10 digits for clarity’s sake.
I need to ensure there’s no loss of service while we are migrating. Since the new PBXes are already set up to route the 10 digit DIDs, I need a mechanism to get those DIDs, received as 11 digits from the new gaining provider, to 10 digits. Ideally, I would be able to define these new DIDs in the trunking server as 10 digits, while maintaining the existing 11 digit DIDs.
The from-pstn-e164-us context does indeed look for _+1NXXNXXXXXX
. The existing upstream provider on the trunking server doesn’t send the +, but does send the leading 1. I can’t simply strip the 1 on the trunk from the provider, since my current 11 digit DIDs would break.
I haven’t done it before, but it looks like I can write a custom context that would conditionally strip the 1, depending on whether a 10- or 11-digit DID existed.
However, is there a reason why my initial suggested approach wouldn’t work? That is, to create a new trunk from the trunking server to itself, with a manipulation rule that strips the leading 1, and set that trunk as the destination on a DID with the pattern _1NXXNXXXXX
.
For posterity’s sake, here’s a slightly more concise way of exporting DIDs/extensions:
mysql asterisk --batch -e "SELECT extension,destination,description FROM incoming;" | sed '1 s/\t/,/g; 2,$ s/.*/1&"/; s/\t/,"/; s/\t/","/'
I’d do it on one line, but fwconsole bi
doesn’t like to read from STDIN (and using -
as a filename doesn’t work either).