Correct configurations for sip trunk and network

I am a beginner in asterisk.
i have tried to config a sip trunk and extensions.

local network clients work perfectly.
but :
sip trunk does not pass dtmf, and aslo can’t record (rtp packest is only from server to client)
remote client (with nat) failed to trasfer rtp (rtp address in local ip address of client)

can anybody help me to config it?
thanks.

my pjsip.conf is attached:

[transfort-udp]
type=transport
protocol=udp
bind=0.0.0.0


[6001]
type=endpoint
context=from-internal
disallow=all
allow=ulaw
auth=6001
aors=6001


[6001]
type=auth
auth_type=userpass
password=1234
username=6001

[6001]
type=aor
max_contacts=1
;===============TRUNK
[mytrunk]
type=identify
endpoint=mytrunk
match=xxx.xxx.xxx.xxx

[mytrunk]
type=peer
outbound_auth=mytrunk
server_uri=sip:xxx.xxx.xxx.xxx
dtmfmode=rfc2833
dtmf=rfc2833
allow=ulaw
allow=G729
[mytrunk]
type=aor
contact=sip:xxx.xxx.xxx.xxx:5060

[mytrunk]
type=endpoint
context=from-trunk
disallow=all
allow=ulaw
outbound_auth=mytrunk
aors=mytrunk

This is bogus and won’t do anything. There is no type=registration, so I don’t think there will be any incoming calls.

At a guess you are behind a NAT router, but haven’t told Asterisk how to find your public address.