Prevent local DIDs from leaving the FreePBX system

Hello all, first post, your patience appreciated.

I recently set up FreePBX 2.11.0.43 with a bunch of DIDs and a SIP trunk. Everything seem to be working ok so far, thanks for making life easier on this area. However, if I pick up a local extension phone and call one of the DIDs on this box, the call seem to be going all the way out via the SIP trunk and then return via the DID provider. Is this the expected behaviour or is there something that I might have missed? My understanding was, even if I dial the DID, it should stay within the box, and not bother about the trunks or routes since this is available locally, and ring the extension it was supposed to ring if the call came from outside. Would appreciate if someone could please clarify and point me to the right direction.

Also, I intend to set up yet another box to a different branch office, and intend to have these two boxes connected via IAX. Given that the other office will also have a bunch of DIDs, I would much prefer to have the calls to the DIDs between the two boxes routed via the IAX trunk rather than having to go out via other trunks and then return to the box. If I understand correctly, all I need to do is set up a route with the correct DID to pass the calls to the other box. Is my assumption correct?

Again, your support in helping to understand these and pointers to the correct direction is highly appreciated.

Thanks
SK

Build a loopback trunk to 127.0.0.1 and route such calls through it.
Same concept as when the two locations have different ip’s

Thanks Dico for your suggestion. I’ll give that a try and see how it goes.

Regards
SK