Extention caller id over sip trunk between two freepbx

hi ! i have installed two freepbx server with a sip trunk on them.
the first server got a isdn trunk and extentions for local users,all is working good !
the second one has extensions for users connecting on internet and an outgoing route to sip trunk on first server.
users on the second server can call to external on isdn but the extention callerid has no effect …
and i can’t route incoming call on specific did to the extention…

this is the sip trunk peer detail :
host=192.168.X.X
username=XXXXXXX
secret=XXXXXXXXX
type=friend
qualify=yes
context=from-internal
insecure=very
sendrpid=yes
trustrpid=yes

does someone has and idea?

Do both servers have a SIP trunk? Are they the same provider? Or are they connected via iax?

both servers are connected via a SIP trunk.and only the first server is connected to a provider via dadhi.

in fact,did routed from first server to second server are routed by second one to outband route.
i changed context on second server :
The context=from-trunk applies calls using inbound rules.
The context=from-internal applies calls using outbound rules.

but why extentions’ Outbound CID on second server that call forwarding first server has no effect?

Why are you setting defaultuser (under its deprecated name)? That overrides the From header user. If you need it, you should probably use sendrpid and trustrpid, to allow something other than the from header to be used for caller ID. You do not need it Asterisk to Asterisk, if you use type=peer.

Why have you got insecure=port,invite, in its deprecated form? I doubt that you need port, and as you have control of the configuration at both ends, you should be able to use static addresses and set the secret the same at each end.

In most caes, type=friend can cause more problems than type=peer, particularly when used on extensions.

This is based on general Asterisk principles. As you are directly manipulating the entry, already, I assume it won’t conlfict with FreePBX.