Register bulk users

I am trying to setup Asterisk so it can accept internal user registrations from 22210000000 - 22299999999. As you notice 222 is prefix, following with some random number from 10000000 - 99999999. Multi-hour googling doesn’t give me answer on where and how can I configure this.

I tried to specify wildcard in sip.conf but it doesn’t register users.

[105]
type=friend
username=105XX
secret=105
host=dynamic
context=internal

The username goes in the square brackets. You must enumerate every one, although you can use templates to avoid repeating most of the lines (you should still use a different secret for each one and you may want to use regexten.

[105] type=friend username=[222XXXXXXXX] secret=105 host=dynamic context=internal

Do you mean I have to add millions of sections? :smile: If not, could you please give some example, hint of configuration?

Update:
I don’t think I have to use different secret, because I have an example of Asterisk setup, that accepts range of usernames and single password. Unfortunately I don’t have configuration for that setup.

you can simply use any scripting language to generate sip accounts .

<?php $myFile = "generated_sip.conf"; $fh = fopen($myFile, 'w') or die("can't open file"); for($i=22210000000;$i<=22299999999;$i++) { $stringData = "[$i]\n"; $stringData .= "type=friend\n"; $stringData .= "username=[$i]\n"; $stringData .= "secret=ss{$i}ss\n"; $stringData .= "host=dynamic\n"; $stringData .= "context=internal\n"; fwrite($fh, $stringData); } fclose($fh); ?>

save it in sipgen.php and run it ( chmod 755 gensip.php and ./sipgen.php )
then you will have generated_sip.conf . you need to include it in your sip.conf .
I dont know why you need these bunch of sip accounts . maybe It is better to use ARA and generate sip account per user request in database .

I mean a section for each device. If you have millions of devices, I suspect you will have other problems.

There is no technical requirement to have different passwords, but common sense requires that you do have different passwords, which should not be algorithmically related (although they could be encrypted versions of the other data using a secret key, stored offline).

The fact that you are asking how to do something completely unreasonable makes me think you need to describe the goal, rather than your proposed partial solution. I suspect you are actually trying to solve a problem the wrong way.

What is the significance of the 105?

[quote=“omid_mohajerani”]you can simply use any scripting language to generate sip accounts .

<?php $myFile = "generated_sip.conf"; $fh = fopen($myFile, 'w') or die("can't open file"); for($i=22210000000;$i<=22299999999;$i++) { $stringData = "[$i]\n"; $stringData .= "type=friend\n"; $stringData .= "username=[$i]\n"; $stringData .= "secret=ss{$i}ss\n"; $stringData .= "host=dynamic\n"; $stringData .= "context=internal\n"; fwrite($fh, $stringData); } fclose($fh); ?>

save it in sipgen.php and run it ( chmod 755 gensip.php and ./sipgen.php )
then you will have generated_sip.conf . you need to include it in your sip.conf .
I dont know why you need these bunch of sip accounts . maybe It is better to use ARA and generate sip account per user request in database .[/quote]

Thanks, I used your solution.

[quote=“david55”]I mean a section for each device. If you have millions of devices, I suspect you will have other problems.

There is no technical requirement to have different passwords, but common sense requires that you do have different passwords, which should not be algorithmically related (although they could be encrypted versions of the other data using a secret key, stored offline).

The fact that you are asking how to do something completely unreasonable makes me think you need to describe the goal, rather than your proposed partial solution. I suspect you are actually trying to solve a problem the wrong way.

What is the significance of the 105?[/quote]

David,

The goal was following. I have web based support call button, which is registering on asterisk with every new call. So I randomly set username from web. Actually I made some 1000 extensions, instead of millions and it looks reasonable in order not to repeat usernames.

Thanks for your support and cheers

This might be an unusual case where allowguest=yes would be right. That assumes you only take incoming calls.