This is the extensions.conf file:
[globals]
INTERNAL_DIAL_OPT=,30
[Hints]
exten = _11XX,hint,PJSIP/${EXTEN}
[Dialing-Errors]
exten = _X.,1,Verbose(1, "User ${CALLERID(num)} dialed an invalid number.")
same = n,Playback(pbx-invalid)
same = n,Hangup()
[Internal-Setup]
exten = _X.,1,NoOp()
same = n,Set(CDR_PROP(disable)=1)
same = n,Goto(Internal-Main,${EXTEN},1)
[Internal-Main]
include = Hints
include = Dial-Users
include = Dialing-Errors
[Dial-Users]
exten = _11XX,1,Verbose(1, "User ${CALLERID(num)} dialed ${EXTEN}.")
same = n,Set(SAC_DIALED_EXTEN=${EXTEN})
same = n,Gotoif($[${DEVICE_STATE(PJSIP/${EXTEN})} = BUSY]?dialed-BUSY,1:)
same = n,Dial(PJSIP/${EXTEN}${INTERNAL_DIAL_OPT})
same = n,Goto(dialed-${DIALSTATUS},1)
exten = dialed-NOANSWER,1,NoOp()
same = n,Voicemail(${SAC_DIALED_EXTEN}@example,u)
same = n,Hangup()
exten = dialed-BUSY,1,NoOp()
same = n,Voicemail(${SAC_DIALED_EXTEN}@example,b)
same = n,Hangup()
exten = dialed-CHANUNAVAIL,1,NoOp()
same = n,Playback(pbx-invalid)
same = n,Hangup()
exten = _dialed-.,1,Goto(dialed-NOANSWER,1)
exten = h,1,Hangup()
exten = o,1,Goto(1111)
[Local]
include = Internal-Setup
In the pjsip.conf:
;================================ ENDPOINT TEMPLATES ==
[endpoint-internal](!)
type = endpoint
context = Local
;disallow = all
allow = !all,alaw,ulaw,h264
direct_media = no
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
trust_id_outbound = yes
device_state_busy_at = 1
dtmf_mode = info
media_use_received_transport = yes
[auth-userpass](!)
type = auth
auth_type = userpass
[aor-single-reg](!)
type = aor
max_contacts = 1
qualify_frequency = 60
[1101](endpoint-internal)
auth = 1101
aors = 1101
callerid = PC <1101>
[1101](auth-userpass)
password = ****
username = 1101
[1101](aor-single-reg)
[1102](endpoint-internal)
auth = 1102
aors = 1102
callerid = MOBILE <1102>
[1102](auth-userpass)
password = ****
username = 1102
[1102](aor-single-reg)
For Kamailio:
# Minimal configuration
# Load modules
loadmodule "tm.so"
loadmodule "sl.so"
loadmodule "rr.so"
loadmodule "maxfwd.so"
loadmodule "textops.so"
loadmodule "rtpproxy.so"
loadmodule "dispatcher.so"
loadmodule "nathelper.so"
# Global parameters
cfgengine "native"
fork=yes
children=4
log_facility=LOG_LOCAL1
# RTPProxy settings
modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:22222")
# Dispatcher settings
modparam("dispatcher", "list_file", "/etc/kamailio/dispatcher.list")
# Main request routing logic
route {
# Max forward check
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483", "Too Many Hops");
exit;
}
# Record routing for stateful processing
record_route();
# Load balance using dispatcher
if (!ds_select_dst("1", "4")) {
sl_send_reply("500", "No destination");
exit;
}
# Engage RTPProxy for RTP traffic
if (is_method("INVITE")) {
rtpproxy_answer();
} else if (is_method("BYE")) {
#end_media_session();
unforce_rtp_proxy();
}
# Forward the request
t_relay();
}
The result of “pjsip show endpoints”:
Endpoint: 1101/1101 Not in use 0 of 1
InAuth: 1101/1101
Aor: 1101 1
Contact: 1101/sip:1101@192.168.1.2:5060;x-ast-or 8c0483a009 Avail 0.844
Endpoint: 1102/1102 Not in use 0 of 1
InAuth: 1102/1102
Aor: 1102 1
Contact: 1102/sip:1102@192.168.1.2:5060;x-ast-or cee3a343cd Avail 0.644