Only allow 10 and 7 digit numbers?

Does anyone have a way to only allow 10 or 7 digit numbers? While freepbx and my inbound routes do a great job of filtering numbers, the annoying spammers are now using 2,3,4,5 or 6 digit numbers randomly to get past my measures.

I would appreciate any feedback on this and if possible a hint on how to structure or format a way to fix this. As far as I am concerned, if you do not have a 7 or 10 digit number, your call is not valid.

Thanks in advance.


It has some great ideas.

Thanks, I had a look over that, but seems more into outbound. I think I may have figured it out temporarily using inbound routes and allowing 7 and 10 digit numbers only.

did # 555-555-1234
caller id # _XXXNXXXXXX

and I hope this will work for the 7 digit, not that number should come through on a 7 digit, but I added it anyway.

did # 555-555-1234
caller id # _NXXXXXX

All routed to my time conditioned ring groups. Hope it will work ok, several inbound tests are working so far, I can’t duplicate a 7 digit of course. Might even drop the 7 digit, as no CID comes in a 7 digit string anyway. Probably not fool proof, but as of now, it is the only thing I can think of.

Only reason I thought of this, my inbound dids was set to allow anynumbers, now just allowing the 10 digit string “SHOULD” stop any other weird numbers getting in. They will just get a number out of service message… lol

The link was for generally using regex’es in Asterisk/FreePBX, and a little “religious” in nature, FreePBX is perhaps not as Regex friendly as it could be. But just change the concept for inbound if you want, it will still work.

Cool, will play around… :slight_smile: Thanks.