Incoming call routes from another asterisk server

I have an asterisk machine running with public ip that handles multiple DID’s for my family. Each DID is routed to the desired extension and works great.
I have a second machine running FreePBX over asterisk for my company use which receives calls through the first system via sip and is on a local network with hostname domain. This system also works well.
I am now trying to add a second DID, a direct line for vendors or installers to call the office, as the main DID is directed to and IRV and then a queue.
I have checked and my provider passes call with RURI to me.
The problem lies in routing the lines. The first DID has always been caught by the ANY route and handled from there, now the second DID is caught by the same route.
I have tried changing between iax, sip and pjsip. I have also tried adding and removing caller id for the trunk as well as on the 1st machine. I have made inbound routes for the DID’s with and without the leading 1, and also with the extension number on the first machine. Most anything I find online is sending the callers id which works already with sip and pjsip.
I have also adjusted between friend and peer, and tried from trunk, pstn, and sip-external.
Is there a way to change the way the first system sends the call or the way the second system receives the call?

FreePBX specific questions are best handled at https://community.freepbx.org/

When structuring inbound routes in fpbx, you need to specify exactly the DID thats used in the SIP INVITE. You can see the DID in the CDR in the DID column when the call goes through the any/any route.

Routes are FreePBX constructs, so you need the FreePBX forum. IVRs, as specific implementations, are also FreePBX constructs. Asterisk has components from which you can construct IVRs, but no IVR construct, as such.

RURI means nothing to me and Google doesn’t help.

PS I hate the way the VoIP industry has hijacked the term Direct In Dialling, and even uses it where there is only one number available. Real DID lines always come with multiple numbers. When you say you are adding a second DID, I think you are really saying you are adding a second account, but this time with only one number.

@david551 RURI is short hand for Request URI in SIP.

DID in CDR show “s”.

I am using the term DID as a single number. Sorry, I’m a contractor so not up to date on all terminology, just trying to learn a little more to get the results I want.

If I send calls from provider to system 2, I can route the calls just like I can with system 1. but from system 1 to system 2 all calls go to the Any inbound route.

If I understand this correctly, I need to adjust the handling of incoming calls on system 2 rather than adjust the sending of calls from system 1?

As already noted, you need the FreePBX forum as there are no “routes”, and therefore no “ANY” route in Asterisk. There is also no DID field in CDRs, only a called extension.

How are you connecting the two systems? As I understand it, with FreePBX you should be using an “intra-company trunk”.

On re-reading the question, it is not clear to me what part of the description relates to the office and which part to the home system.

Seeing “s” as the user in the request URI (what FreePBX perceives, by default, as a “DID”) suggests that the office is registering with the home system. It is much better if you do intra-company trunks with fixed addresses at both ends. However, chan_pjsip allows you to set the user, to something other than “s”, using the contact_user option, and there are equivalent mechanisms in the register string for the, obsolescent, chan_sip. Typically you should be using a VPN, which should allow you to used fixed addresses.

You can also add custom headers, that can be used to distinguish calls.

Ok, I understand the asterisk has no routes now. I will also post question to FreePBX community.

I currently have system 2 “FreePBX, dedicated server in office behind NAT” registering via sip just like a softphone to system 1 “asterisk, running on remote dedicated server with public IP”.
I will read up on headers and try to set a user for pjsip and see if that helps.

Thank you for your reply.