Fake provider setup

hi. For the sake of a lab test i need to have my system act as a fake provider.
i need the system to have 1000 numbers, that will not route to the outside world, only in my LAN. These numbers will have the following format 0049894874000-999. I need to create some users in sip.conf (eg 8000-8099) that each user will be the trunk from a different PBX. then on each of these numbers route 10 of the aforementioned DIDs. i was thinking of the following config on the provider_asterisk, please make your comments:
extensions.conf

`
exten => 004989487400X,1,Answer()
exten => 004989487400X,n,Wait(1)
exten => 004989487400X,n,Dial(SIP/8000,20)
exten => 004989487400X,n,Busy(3)
`

and for the sip.conf

[8000]
host=dynamic
type=friend
user=8000
secret=8000SuperDooperPasswd
call-limit=2
context=AllCalls
dtmfmode=rfc2833
qualify=yes
disallow=all
allow=alaw
allow=g729
canreinvite=no
deny=0.0.0.0/0.0.0.0
permit=192.168.0.0/255.255.0.0

with that the provider_asterisk will route 10 numbers to the 8000 extension. Then on the client_asterisk they will have to register 8000 and receive all the numbers through the 8000. Same applies for all registrations of extensions from 8000-8099, then all of the 0049894874XXX block of numbers will be routable between the PBXes, right? My question is regarding call routing. PBX A has a registration of 8000 and needs to call a numbers that belongs to 8001. It dials 0049894874011 but it receives error that the number is not in the extensions.
Am i missing something? Is this the correct approach? Also i see that the call from PBX A to the provider_asterisk goes as 8000 and it does not carry any DID.

It will probably help you understand this better if you don’t confuse devices and extension. Replace the 8000 with the MAC address of the phone, and see if it still makes sense.

(On a very cursory glance, I think you are on the right track.)

Hi. I used extension numbers 8XXX since i need the remote PBXes to register on the main PBX. All of themm for testing purposes in a single LAN 172.16.0.0/16
I cannot see why it does not carry the DID when the call is sent to the main PBX. Lets say i have:
-ProviderAsterisk with IP 172.16.0.5 and extensions 8XXX
-PBX_A with IP 172.16.0.6 and a sip trunk 8000@172.16.0.5 and DIDs under that trunks 004989487400X
-PBX_B with IP 172.16.0.6 and a sip trunk 8001@172.16.0.5 and DIDs under that trunks 004989487401X

PBX_B calls PBX_A on 0049894874000 and the number seen on the PBX_A is 8001!. Sip set debug on, does not show anywhere anything regarding the 0049894874XXX numbers. Somewhere i am doing something wrong, but i cannot find what.

You have not set the callerid of device 8001.

Just add : callerid = Extension 8001 <0049894874XXX>

Then when you call you should see the wanted clip/cli

Thanks a lot for the reply.
I thought of that, but each extension has more than one numbers (DDIs).
How do i do that, please?

Then you have to assign the callerid dynamic…

By adding a line in the dialplan like…

exten => 004989487400X,1,Answer()
same => n,Wait(1)
same => n,Set(CALLERID(all)=004989487400x)
same => n,Dial(SIP/8000,20)
same => n,Busy(3)

Dont know what you want to send as callerid… You just have to set it.

So this is for the provider_asterisk. In case where then DIDs are not sequential how do i write the code you mentioned? As default caller ID on the outgoing calls has to be the first number in range. Is there a way the extensions behind the trunk 8000 to send their DID as long as it is one from the ones provided in the dialplan? So i trunk for pbx_A (8000) has numbers 004989487400x then when the extensions call, by default to have the 0049894874000. If each extension places a call to be able to make the call and show one of the DIDs from the 0049894874000-9 range that is allowed for this trunk.

Use the RAND function…

exten => 004989487400X,1,Answer()
same => n,Wait(1)
same => n,Set(randomnumber=${RAND(0,9)})
same => n,Set(CALLERID(all)=004989487400${randomnumber})
same => n,Dial(SIP/8000,20)
same => n,Busy(3)

Hi. thanks for the reply. I am not asking for a random number. i am asking to set as default number the first number of the DDIs. In case they decide to send from their extension a particular DDI, allow it only if it is in the trunk, otherwise send the default number.

I am having a hard time understanding what you want.

Typically endpoints have a single caller ID.

IE
Bob: 5551233

Jack: 5551247

If Jack places any calls the caller ID would be Jacks caller ID.

In what case would you want Jack to have a different caller ID?

In what case would Jack want to have a different caller ID?

I have 4 systems (A, B, C, D), all in the same subnet 192.168.0.0/24
-A is on IP 192.168.0.2 and it needs to play the role of a SIP provider. A has extension numbers 8XXX.
-B is on IP 192.168.0.3 and it has a registration to A with username 8000, passwd whatever, host 192.168.0.2
-C is on IP 192.168.0.4 and it has a registration to A with username 8001, passwd yadayada, host 192.168.0.2
-D is on IP 192.168.0.5 and it has a registration to A with username 8002, passwd foofoo, host 192.168.0.2

On A i would like to route fake DIDs to each extension. So it will be:
-004989487400-9 will be send to 8000
-004989487410-9 will be send to 8001
-004989487420-9 will be send to 8002
Each extension has 10 DIDs routed. That’s fine up to now and it works. a call from A to -004989487410 goes to B and is handled from asterisk B.
In B’s extensions.conf i have a global parameter where i set the outgoing DID based on source. Similar to C and D.

Problem A
The problem is the opposite when someone from asterisk B sends a call to trunk 8000, the call arrives on asterisk A, without any DID from the range 00498948740X. B needs to call C on 004989487410. Call goes to A but it does not get routed anywhere since it does not have any DID carried with!

Problem B
Once we have everything in place and numbers are routed correctly, i need each trunk to send as outgoing numbers only the numbers on the trunk. So if a user from B tries to send 00441234556 to reject that and send out the default number of the trunk (004989487400). Similar for each other trunk but with different default number. The default number for each trunk is the first from the list of the routed numbers to each extension.
-For B is 004989487400
-For C is 004989487410
-For D is 004989487420

Any ideas please?

Just set the callerid you want to be used before the dial command…

If there has to be intelligence on which cli to use, you have to build it.

Hi. thanks a lot for the replies. I am asking for a direction on how to build that intelligence, please.

Ok, maybe Im lost, but in your explanation you are talking about DID that is not carried…

“Call goes to A but it does not get routed anywhere since it does not have any DID carried with!”

You do know that the DID is the number called and the CLI is the calling number…

But maybe Im reading it totaly wrong.

Providing the intelligence is hard when your problem is not clear, at least to me it is not.

For your problem B, you could have a db with a table with records and cli’s
ie: 8000,cli 1
8000,cli2
etc…

When 8000 calls, check the send cli with the cli’s in the database, when matched the cli is allowed, else not.

For Problem A you need to verify that the dialed number is showing up on 192.168.0.2.

Your Dial string on 192.168.0.3 should be something like Dial(PJSIP/${EXTEN}@8000) and your endopoint definition on 192.168.0.2 for 8000 should put the call in an appropriate context where it can reach the extensions on your other servers.

[8000]
type=endpoint
context=local-servers

[local-servers]
exten => _00498948740Z,1,Dial(PJSIP/${EXTEN}@8000)
exten => _00498948741Z,1,Dial(PJSIP/${EXTEN}@8001)
exten => _00498948742Z,1,Dial(PJSIP/${EXTEN}@8002)

Assuming you have everything set up properly you should then be able to reach any of the numbers in the context.

For Problem B you need to control that in the dialplan on your 192.168.0.3,192.168.0.4, and 192.168.0.5 servers You could do it with any of the expression tests that Asterisk supports.

[to-provider]
exten => _X.,1,NoOP()
 same => n,ExecIf($[${REGEX(00498948740[0-9],${CALLERID(NUM))} = 0]Set(CallerID(NUM)=004989487400)
 same => n,Dial(PJSIP/${EXTEN}@8000)