There’s functionally two parts to this question:

 

  1. How to change a number
  2. How to select a random number

 

For selection of the number it’s probably easiest to rely on DB lookup. With one column as the original number and another column as the possible replacement numbers, then just select with an order by random to get the replacement number.

 

As far as changing the number, it can depend on specifically what number you’re trying to change.  The RURI can be changed just by setting $rU.  Values in the To: or From: headers should be changed with the functions from the UAC module so that replies can have the original values restored.  For other miscellaneous headers like P-Asserted-Identity, just remove the old header and append a new one.

 

Regards,

Kaufman

 

 

From: Ali Taher <ataher@vanrise.com>
Sent: Wednesday, August 2, 2023 1:20 AM
To: Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org>
Subject: [SR-Users] change A number using a pool of numbers

 

CAUTION: This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

 

Hello,

 

I’m looking to change the A number (from number) to a number selected randomly from a pool of existing numbers (hundreds) and then relay the call to a certain gateway.

 

What is the best and more efficient way to do it in kamailio?

 

Thanks in advance