Hi,
  I am using the example "gw-pstn" from Getting started.  I followed
the guide to setup mediaproxy for handle NAT function.  However, I
can't make call between Internal IPphone to PSTN.  Anyone can help me
to analyze why it doesn't work.

After using mediaproxy, I found that some data are stored in the table
"Location" compared not using mediaproxy.  The field "contact"
contains "sip:[EMAIL PROTECTED]:port" and the field "received"
contains "sip:externalIP:port".  Is it correct after using mediaproxy?

I have a look for the log from ngrep and some extra parameters "rport
and receieved" in the header.

When I try to make a call from internal IP phone to PSTN, the error
"500 FQDN in SDP Media cannot be resolved.".  I think it is still a
NAT problem and it seems to use the internal IP instead of external
IP.  As the same time, Cisco shows (no route to destination (3)).

When I try to make a call from PSTN to internal IP phone, the error "
Too Many Hops", which is the error message in the openser.cfg file,
shown.  I do think it is the same reason as the above case.

Below are the log from ngrep during making a call.  openser.cfg and
mediaproxy.ini are also listed below.  Please help to figure it out
the problem.  Many thanks!

>>>>>>>>>>>>>-------start of the log ( make a call from internal IP
phone to PSTN) ---------
interface: eth1 (INTERFACE_IP/255.255.255.240)
filter: (ip) and ( port 5060 )
#
U NAT_PUBLIC_IP:5060 -> OPENSER_PUBLIC_IP:5060
INVITE sip:[EMAIL PROTECTED] SIP/2.0.
Via: SIP/2.0/UDP 10.0.0.63:5060;branch=z9hG4bKwgnpocaCevAIebRx.
Max-Forwards: 70.
User-Agent: Koncept KE10XX v4.32.05 00-09-45-0a-fc-57.
From: "36418497" <sip:[EMAIL PROTECTED]>;tag=EInGXmoIRNHvq87x.
To: "934163634" <sip:[EMAIL PROTECTED]>.
Call-ID: [EMAIL PROTECTED]
Contact: <sip:[EMAIL PROTECTED]:5060>.
CSeq: 1 INVITE.
Supported: 100rel, replaces.
Content-Type: application/sdp.
Content-Length: 290.
.
v=0.
o=36418497 63608336 94989291 IN IP4 10.0.0.63.
s=SIP CALL.
c=IN IP4 10.0.0.63.
t=0 0.
m=audio 6000 RTP/AVP 18 3 0 8 4 101.
a=rtpmap:18 G729/8000.
a=rtpmap:3 GSM/8000.
a=rtpmap:0 PCMU/8000.
a=rtpmap:8 PCMA/8000.
a=rtpmap:4 G723/8000.
a=rtpmap:101 telephone-event/8000.
a=fmtp:101 0-15.

#
U OPENSER_PUBLIC_IP:5060 -> NAT_PUBLIC_IP:5060
SIP/2.0 100 trying -- your call is important to us.
Via: SIP/2.0/UDP
10.0.0.63:5060;branch=z9hG4bKwgnpocaCevAIebRx;rport=5060;received=NAT_PUBLIC_IP.
From: "36418497" <sip:[EMAIL PROTECTED]>;tag=EInGXmoIRNHvq87x.
To: "934163634" <sip:[EMAIL PROTECTED]>.
Call-ID: [EMAIL PROTECTED]
CSeq: 1 INVITE.
Server: OpenSer (1.0.0 (i386/linux)).
Content-Length: 0.
Warning: 392 OPENSER_PUBLIC_IP:5060 "Noisy feedback tells:  pid=30084
req_src_ip=NAT_PUBLIC_IP req_src_port=5060
in_uri=sip:[EMAIL PROTECTED]
out_uri=sip:[EMAIL PROTECTED] via_cnt==1".
.

#
U OPENSER_PUBLIC_IP:5060 -> CISCO_PUBLIC_IP:5060
INVITE sip:[EMAIL PROTECTED] SIP/2.0.
Record-Route: <sip:[EMAIL PROTECTED]:5060;nat=yes;ftag=EInGXmoIRNHvq87x;lr=on>.
Via: SIP/2.0/UDP OPENSER_PUBLIC_IP;branch=z9hG4bKf09e.6b2c5156.0.
Via: SIP/2.0/UDP
10.0.0.63:5060;rport=5060;received=NAT_PUBLIC_IP;branch=z9hG4bKwgnpocaCevAIebRx.
Max-Forwards: 69.
User-Agent: Koncept KE10XX v4.32.05 00-09-45-0a-fc-57.
From: "36418497" <sip:[EMAIL PROTECTED]>;tag=EInGXmoIRNHvq87x.
To: "934163634" <sip:[EMAIL PROTECTED]>.
Call-ID: [EMAIL PROTECTED]
Contact: <sip:[EMAIL PROTECTED]:5060>.
CSeq: 1 INVITE.
Supported: 100rel, replaces.
Content-Type: application/sdp.
Content-Length: 315.
.
v=0.
o=36418497 63608336 94989291 IN IP4 10.0.0.63.
s=SIP CALL.
c=IN IP4 OPENSER_PUBLIC_IPOPENSER_PUBLIC_IP.     #it is very strange
as it displayed 2 IPs together!
t=0 0.
m=audio 3502435024 RTP/AVP 18 3 0 8 4 101.
a=rtpmap:18 G729/8000.
a=rtpmap:3 GSM/8000.
a=rtpmap:0 PCMU/8000.
a=rtpmap:8 PCMA/8000.
a=rtpmap:4 G723/8000.
a=rtpmap:101 telephone-event/8000.
a=fmtp:101 0-15.

#
U CISCO_PUBLIC_IP:5060 -> OPENSER_PUBLIC_IP:5060
SIP/2.0 100 Trying.
Via: SIP/2.0/UDP
OPENSER_PUBLIC_IP;branch=z9hG4bKf09e.6b2c5156.0,SIP/2.0/UDP
10.0.0.63:5060;rport=5060;received=NAT_PUBLIC_IP;branch=z9hG4bKwgnpocaCevAIebRx.
From: "36418497" <sip:[EMAIL PROTECTED]>;tag=EInGXmoIRNHvq87x.
To: "934163634" <sip:[EMAIL PROTECTED]>;tag=2D902FF8-1CD1.
Date: Sat, 17 Dec 2005 06:12:17 GMT.
Call-ID: [EMAIL PROTECTED]
Server: Cisco-SIPGateway/IOS-12.x.
CSeq: 1 INVITE.
Allow-Events: telephone-event.
Content-Length: 0.
.

#
U CISCO_PUBLIC_IP:5060 -> OPENSER_PUBLIC_IP:5060
SIP/2.0 183 Session Progress.
Via: SIP/2.0/UDP
OPENSER_PUBLIC_IP;branch=z9hG4bKf09e.6b2c5156.0,SIP/2.0/UDP
10.0.0.63:5060;rport=5060;received=NAT_PUBLIC_IP;branch=z9hG4bKwgnpocaCevAIebRx.
From: "36418497" <sip:[EMAIL PROTECTED]>;tag=EInGXmoIRNHvq87x.
To: "934163634" <sip:[EMAIL PROTECTED]>;tag=2D902FF8-1CD1.
Date: Sat, 17 Dec 2005 06:12:17 GMT.
Call-ID: [EMAIL PROTECTED]
Server: Cisco-SIPGateway/IOS-12.x.
CSeq: 1 INVITE.
Require: 100rel.
RSeq: 5664.
Allow-Events: telephone-event.
Contact: <sip:[EMAIL PROTECTED]:5060>.
Record-Route: <sip:[EMAIL PROTECTED]:5060;nat=yes;ftag=EInGXmoIRNHvq87x;lr=on>.
Content-Type: application/sdp.
Content-Disposition: session;handling=required.
Content-Length: 184.
.
v=0.
o=CiscoSystemsSIP-GW-UserAgent 6412 5565 IN IP4 CISCO_PUBLIC_IP.
s=SIP Call.
c=IN IP4 CISCO_PUBLIC_IP.
t=0 0.
m=audio 16398 RTP/AVP 18.
a=rtpmap:18 G729/8000.
a=fmtp:18 annexb=yes.

#
U OPENSER_PUBLIC_IP:5060 -> NAT_PUBLIC_IP:5060
SIP/2.0 183 Session Progress.
Via: SIP/2.0/UDP
10.0.0.63:5060;rport=5060;received=NAT_PUBLIC_IP;branch=z9hG4bKwgnpocaCevAIebRx.
From: "36418497" <sip:[EMAIL PROTECTED]>;tag=EInGXmoIRNHvq87x.
To: "934163634" <sip:[EMAIL PROTECTED]>;tag=2D902FF8-1CD1.
Date: Sat, 17 Dec 2005 06:12:17 GMT.
Call-ID: [EMAIL PROTECTED]
Server: Cisco-SIPGateway/IOS-12.x.
CSeq: 1 INVITE.
Require: 100rel.
RSeq: 5664.
Allow-Events: telephone-event.
Contact: <sip:[EMAIL PROTECTED]:5060>.
Record-Route: <sip:[EMAIL PROTECTED]:5060;nat=yes;ftag=EInGXmoIRNHvq87x;lr=on>.
Content-Type: application/sdp.
Content-Disposition: session;handling=required.
Content-Length: 184.
.
v=0.
o=CiscoSystemsSIP-GW-UserAgent 6412 5565 IN IP4 CISCO_PUBLIC_IP.
s=SIP Call.
c=IN IP4 OPENSER_PUBLIC_IP.
t=0 0.
m=audio 35024 RTP/AVP 18.
a=rtpmap:18 G729/8000.
a=fmtp:18 annexb=yes.

#
U NAT_PUBLIC_IP:5060 -> OPENSER_PUBLIC_IP:5060
PRACK sip:[EMAIL PROTECTED]:5060 SIP/2.0.
Via: SIP/2.0/UDP 10.0.0.63:5060;branch=z9hG4bK6CCN6qgnaIMWA8ww.
Route: <sip:[EMAIL PROTECTED]:5060;nat=yes;ftag=EInGXmoIRNHvq87x;lr=on>.
Max-Forwards: 70.
User-Agent: Koncept KE10XX v4.32.05 00-09-45-0a-fc-57.
From: "36418497" <sip:[EMAIL PROTECTED]>;tag=EInGXmoIRNHvq87x.
To: "934163634" <sip:[EMAIL PROTECTED]>;tag=2D902FF8-1CD1.
Call-ID: [EMAIL PROTECTED]
Contact: <sip:[EMAIL PROTECTED]:5060>.
CSeq: 2 PRACK.
RAck: 5664 1 INVITE.
Content-Length: 0.
.

#
U OPENSER_PUBLIC_IP:5060 -> CISCO_PUBLIC_IP:5060
PRACK sip:[EMAIL PROTECTED]:5060 SIP/2.0.
Record-Route: <sip:OPENSER_PUBLIC_IP;ftag=EInGXmoIRNHvq87x;lr=on>.
Via: SIP/2.0/UDP OPENSER_PUBLIC_IP;branch=z9hG4bKc09e.ba203413.0.
Via: SIP/2.0/UDP
10.0.0.63:5060;received=NAT_PUBLIC_IP;branch=z9hG4bK6CCN6qgnaIMWA8ww.
Max-Forwards: 69.
User-Agent: Koncept KE10XX v4.32.05 00-09-45-0a-fc-57.
From: "36418497" <sip:[EMAIL PROTECTED]>;tag=EInGXmoIRNHvq87x.
To: "934163634" <sip:[EMAIL PROTECTED]>;tag=2D902FF8-1CD1.
Call-ID: [EMAIL PROTECTED]
Contact: <sip:[EMAIL PROTECTED]:5060>.
CSeq: 2 PRACK.
RAck: 5664 1 INVITE.
Content-Length: 0.
.

#
U CISCO_PUBLIC_IP:5060 -> OPENSER_PUBLIC_IP:5060
SIP/2.0 200 OK.
Via: SIP/2.0/UDP
OPENSER_PUBLIC_IP;branch=z9hG4bKc09e.ba203413.0,SIP/2.0/UDP
10.0.0.63:5060;received=NAT_PUBLIC_IP;branch=z9hG4bK6CCN6qgnaIMWA8ww.
From: "36418497" <sip:[EMAIL PROTECTED]>;tag=EInGXmoIRNHvq87x.
To: "934163634" <sip:[EMAIL PROTECTED]>;tag=2D902FF8-1CD1.
Date: Sat, 17 Dec 2005 06:12:18 GMT.
Call-ID: [EMAIL PROTECTED]
Server: Cisco-SIPGateway/IOS-12.x.
CSeq: 2 PRACK.
Content-Length: 0.
.

#
U OPENSER_PUBLIC_IP:5060 -> NAT_PUBLIC_IP:5060
SIP/2.0 200 OK.
Via: SIP/2.0/UDP
10.0.0.63:5060;received=NAT_PUBLIC_IP;branch=z9hG4bK6CCN6qgnaIMWA8ww.
From: "36418497" <sip:[EMAIL PROTECTED]>;tag=EInGXmoIRNHvq87x.
To: "934163634" <sip:[EMAIL PROTECTED]>;tag=2D902FF8-1CD1.
Date: Sat, 17 Dec 2005 06:12:18 GMT.
Call-ID: [EMAIL PROTECTED]
Server: Cisco-SIPGateway/IOS-12.x.
CSeq: 2 PRACK.
Content-Length: 0.
.

#
U NAT_PUBLIC_IP:15061 -> OPENSER_PUBLIC_IP:5060
................
#
U OPENSER_PUBLIC_IP:5060 -> NAT_PUBLIC_IP:5060
....
#
U OPENSER_PUBLIC_IP:5060 -> NAT_PUBLIC_IP:15061
....
#
U OPENSER_PUBLIC_IP:5060 -> 210.22.7.147:2185
....
#
U OPENSER_PUBLIC_IP:5060 -> NAT_PUBLIC_IP:15060
....
#
U CISCO_PUBLIC_IP:5060 -> OPENSER_PUBLIC_IP:5060
SIP/2.0 500 FQDN Query in SDP Media cannot be resolved.
Via: SIP/2.0/UDP
OPENSER_PUBLIC_IP;branch=z9hG4bKf09e.6b2c5156.0,SIP/2.0/UDP
10.0.0.63:5060;rport=5060;received=NAT_PUBLIC_IP;branch=z9hG4bKwgnpocaCevAIebRx.
From: "36418497" <sip:[EMAIL PROTECTED]>;tag=EInGXmoIRNHvq87x.
To: "934163634" <sip:[EMAIL PROTECTED]>;tag=2D902FF8-1CD1.
Date: Sat, 17 Dec 2005 06:12:18 GMT.
Call-ID: [EMAIL PROTECTED]
Server: Cisco-SIPGateway/IOS-12.x.
CSeq: 1 INVITE.
Allow-Events: telephone-event.
Content-Length: 0.
.

#
U OPENSER_PUBLIC_IP:5060 -> CISCO_PUBLIC_IP:5060
ACK sip:[EMAIL PROTECTED] SIP/2.0.
Via: SIP/2.0/UDP OPENSER_PUBLIC_IP;branch=z9hG4bKf09e.6b2c5156.0.
From: "36418497" <sip:[EMAIL PROTECTED]>;tag=EInGXmoIRNHvq87x.
Call-ID: [EMAIL PROTECTED]
To: "934163634" <sip:[EMAIL PROTECTED]>;tag=2D902FF8-1CD1.
CSeq: 1 ACK.
User-Agent: OpenSer (1.0.0 (i386/linux)).
Content-Length: 0.
.

#
U OPENSER_PUBLIC_IP:5060 -> NAT_PUBLIC_IP:5060
SIP/2.0 500 FQDN Query in SDP Media cannot be resolved.
Via: SIP/2.0/UDP
10.0.0.63:5060;rport=5060;received=NAT_PUBLIC_IP;branch=z9hG4bKwgnpocaCevAIebRx.
From: "36418497" <sip:[EMAIL PROTECTED]>;tag=EInGXmoIRNHvq87x.
To: "934163634" <sip:[EMAIL PROTECTED]>;tag=2D902FF8-1CD1.
Date: Sat, 17 Dec 2005 06:12:18 GMT.
Call-ID: [EMAIL PROTECTED]
Server: Cisco-SIPGateway/IOS-12.x.
CSeq: 1 INVITE.
Allow-Events: telephone-event.
Content-Length: 0.
.

#
U NAT_PUBLIC_IP:5060 -> OPENSER_PUBLIC_IP:5060
ACK sip:[EMAIL PROTECTED] SIP/2.0.
Via: SIP/2.0/UDP 10.0.0.63:5060;branch=z9hG4bKwgnpocaCevAIebRx.
Route: <sip:[EMAIL PROTECTED]:5060;nat=yes;ftag=EInGXmoIRNHvq87x;lr=on>.
Max-Forwards: 70.
User-Agent: Koncept KE10XX v4.32.05 00-09-45-0a-fc-57.
From: "36418497" <sip:[EMAIL PROTECTED]>;tag=EInGXmoIRNHvq87x.
To: "934163634" <sip:[EMAIL PROTECTED]>;tag=2D902FF8-1CD1.
Call-ID: [EMAIL PROTECTED]
Contact: <sip:[EMAIL PROTECTED]:5060>.
CSeq: 1 ACK.
Content-Length: 0.
.

#
U OPENSER_PUBLIC_IP:5060 -> NAT_PUBLIC_IP:5060
SIP/2.0 500 FQDN Query in SDP Media cannot be resolved.
Via: SIP/2.0/UDP
10.0.0.63:5060;rport=5060;received=NAT_PUBLIC_IP;branch=z9hG4bKwgnpocaCevAIebRx.
From: "36418497" <sip:[EMAIL PROTECTED]>;tag=EInGXmoIRNHvq87x.
To: "934163634" <sip:[EMAIL PROTECTED]>;tag=2D902FF8-1CD1.
Date: Sat, 17 Dec 2005 06:12:18 GMT.
Call-ID: [EMAIL PROTECTED]
Server: Cisco-SIPGateway/IOS-12.x.
CSeq: 1 INVITE.
Allow-Events: telephone-event.
Content-Length: 0.
.

#
U NAT_PUBLIC_IP:5060 -> OPENSER_PUBLIC_IP:5060
ACK sip:[EMAIL PROTECTED] SIP/2.0.
Via: SIP/2.0/UDP 10.0.0.63:5060;branch=z9hG4bKwgnpocaCevAIebRx.
Route: <sip:[EMAIL PROTECTED]:5060;nat=yes;ftag=EInGXmoIRNHvq87x;lr=on>.
Max-Forwards: 70.
User-Agent: Koncept KE10XX v4.32.05 00-09-45-0a-fc-57.
From: "36418497" <sip:[EMAIL PROTECTED]>;tag=EInGXmoIRNHvq87x.
To: "934163634" <sip:[EMAIL PROTECTED]>;tag=2D902FF8-1CD1.
Call-ID: [EMAIL PROTECTED]
Contact: <sip:[EMAIL PROTECTED]:5060>.
CSeq: 1 ACK.
Content-Length: 0.
.

exit
21 received, 0 dropped
<<<<<<<<<<<<<<<<<<<-------end of the log ( make a call from internal
IP phone to PSTN) ---------

>>>>>>>>>>>>>>>>>>>-------start of the log (make a call from PSTN to
internal IP phone) -----------
interface: eth1 (203.193.46.224/255.255.255.240)
filter: (ip) and ( port 5060 )
#
U OPENSER_PUBLIC_IP:5060 -> NAT_PUBLIC_IP:15061
....
#
U OPENSER_PUBLIC_IP:5060 -> NAT_PUBLIC_IP:15060
....
#
U CISCO_PUBLIC_IP:56976 -> OPENSER_PUBLIC_IP:5060
INVITE sip:[EMAIL PROTECTED]:5060 SIP/2.0.
Via: SIP/2.0/UDP  CISCO_PUBLIC_IP:5060.
From: <sip:[EMAIL PROTECTED]>;tag=2DA393B0-1816.
To: <sip:[EMAIL PROTECTED]>.
Date: Sat, 17 Dec 2005 06:33:27 GMT.
Call-ID: [EMAIL PROTECTED]
Supported: timer,100rel.
Min-SE:  1800.
Cisco-Guid: 3722686073-1845301722-2197529880-1469017633.
User-Agent: Cisco-SIPGateway/IOS-12.x.
Allow: INVITE, OPTIONS, BYE, CANCEL, ACK, PRACK, COMET, REFER,
SUBSCRIBE, NOTIFY, INFO.
CSeq: 101 INVITE.
Max-Forwards: 15.
Remote-Party-ID:
<sip:[EMAIL PROTECTED]>;party=calling;screen=yes;privacy=off.
Timestamp: 1134801207.
Contact: <sip:[EMAIL PROTECTED]:5060>.
Expires: 180.
Allow-Events: telephone-event.
Content-Type: application/sdp.
Content-Length: 304.
.
v=0.
o=CiscoSystemsSIP-GW-UserAgent 366 9285 IN IP4 CISCO_PUBLIC_IP.
s=SIP Call.
c=IN IP4 CISCO_PUBLIC_IP.
t=0 0.
m=audio 18044 RTP/AVP 3 18 4 2 15.
a=rtpmap:3 GSM/8000.
a=rtpmap:18 G729/8000.
a=fmtp:18 annexb=yes.
a=rtpmap:4 G723/8000.
a=fmtp:4 annexa=yes.
a=rtpmap:2 G726-32/8000.
a=rtpmap:15 G728/8000.

#
U OPENSER_PUBLIC_IP:5060 -> CISCO_PUBLIC_IP:5060
SIP/2.0 100 trying -- your call is important to us.
Via: SIP/2.0/UDP  CISCO_PUBLIC_IP:5060.
From: <sip:[EMAIL PROTECTED]>;tag=2DA393B0-1816.
To: <sip:[EMAIL PROTECTED]>.
Call-ID: [EMAIL PROTECTED]
CSeq: 101 INVITE.
Server: OpenSer (1.0.0 (i386/linux)).
Content-Length: 0.
Warning: 392 OPENSER_PUBLIC_IP:5060 "Noisy feedback tells:  pid=30091
req_src_ip=CISCO_PUBLIC_IP req_src_port=56976
in_uri=sip:[EMAIL PROTECTED]:5060
out_uri=sip:[EMAIL PROTECTED]:5060 via_cnt==1".
.

#
U OPENSER_PUBLIC_IP:5060 -> CISCO_PUBLIC_IP:5060
SIP/2.0 483 Too Many Hops.
Via: SIP/2.0/UDP  CISCO_PUBLIC_IP:5060.
From: <sip:[EMAIL PROTECTED]>;tag=2DA393B0-1816.
To: <sip:[EMAIL PROTECTED]>;tag=b5ab8e75af536221ca172f8fc39505eb.bdf6.
Call-ID: [EMAIL PROTECTED]
CSeq: 101 INVITE.
Server: OpenSer (1.0.0 (i386/linux)).
Content-Length: 0.
Warning: 392 OPENSER_PUBLIC_IP:5060 "Noisy feedback tells:  pid=30091
req_src_ip=OPENSER_PUBLIC_IP req_src_port=5060
in_uri=sip:[EMAIL PROTECTED]:5060
out_uri=sip:[EMAIL PROTECTED]:5060 via_cnt==16".
.

#
U CISCO_PUBLIC_IP:56976 -> OPENSER_PUBLIC_IP:5060
ACK sip:[EMAIL PROTECTED]:5060 SIP/2.0.
Via: SIP/2.0/UDP  CISCO_PUBLIC_IP:5060.
From: <sip:[EMAIL PROTECTED]>;tag=2DA393B0-1816.
To: <sip:[EMAIL PROTECTED]>;tag=b5ab8e75af536221ca172f8fc39505eb.bdf6.
Date: Sat, 17 Dec 2005 06:33:27 GMT.
Call-ID: [EMAIL PROTECTED]
Max-Forwards: 15.
Content-Length: 0.
CSeq: 101 ACK.
.

exit
7 received, 0 dropped
<<<<<<<<<<<<-------start of the log (make a call from PSTN to internal
IP phone) -----------


>>>>>>>>>---------start of the openser.cfg ----------------------
# $Id: gw-pstn.cfg 9 2005-08-19 15:30:55Z /CN=Greger V.
Teigre/[EMAIL PROTECTED] $
debug=3
fork=yes
log_stderror=no

listen=OPENSER_IP
port=5060
children=4

dns=no
rev_dns=no
fifo="/tmp/openser_fifo"
fifo_db_url="mysql://openser:[hidden]/openser"
log_facility=LOG_LOCAL0
alias=owthkems01.mydomain.com

loadmodule "/usr/local/lib/openser/modules/mysql.so"
loadmodule "/usr/local/lib/openser/modules/sl.so"
loadmodule "/usr/local/lib/openser/modules/tm.so"
loadmodule "/usr/local/lib/openser/modules/rr.so"
loadmodule "/usr/local/lib/openser/modules/maxfwd.so"
loadmodule "/usr/local/lib/openser/modules/usrloc.so"
loadmodule "/usr/local/lib/openser/modules/registrar.so"
loadmodule "/usr/local/lib/openser/modules/auth.so"
loadmodule "/usr/local/lib/openser/modules/auth_db.so"
loadmodule "/usr/local/lib/openser/modules/uri.so"
loadmodule "/usr/local/lib/openser/modules/uri_db.so"
loadmodule "/usr/local/lib/openser/modules/mediaproxy.so"
loadmodule "/usr/local/lib/openser/modules/nathelper.so"
loadmodule "/usr/local/lib/openser/modules/textops.so"
loadmodule "/usr/local/lib/openser/modules/avpops.so"
loadmodule "/usr/local/lib/openser/modules/domain.so"
#loadmodule "/usr/local/lib/openser/modules/permissions.so"
loadmodule "/usr/local/lib/openser/modules/xlog.so"

modparam("auth_db|permissions|uri_db|usrloc",
        "db_url", "mysql://openser:[hidden]/openser")
modparam("auth_db", "calculate_ha1", 1)
modparam("auth_db", "password_column", "password")

modparam("nathelper", "rtpproxy_disable", 1)
modparam("nathelper", "natping_interval", 0)

modparam("mediaproxy","natping_interval", 30)
modparam("mediaproxy","mediaproxy_socket", "/var/run/mediaproxy.sock")
modparam("mediaproxy","sip_asymmetrics","/usr/local/etc/ser/sip-clients")
modparam("mediaproxy","rtp_asymmetrics","/usr/local/etc/ser/rtp-clients")

modparam("usrloc", "db_mode", 2)

modparam("registrar", "nat_flag", 6)

modparam("rr", "enable_full_lr", 1)

#The default INVITE timer will be allowed 27 seconds to connect.
#If we are going to call a PSTN destination then we will set the 'inv_timeout'
#AVP to a higher value in order to allow additional timer for the call to
#connect.  This is show in the PSTN route handler.
modparam("tm", "fr_inv_timer", 27)
modparam("tm", "fr_inv_timer_avp", "inv_timeout")

#modparam("permissions", "db_mode", 1)
#modparam("permissions", "trusted_table", "trusted")

route {

       #xlog("L_INFO","SIP Request: method [$rm] from [$si] [$sp] to
[$Ri] [$Rp]\n");
        # -----------------------------------------------------------------
        # Sanity Check Section
        # -----------------------------------------------------------------
        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483", "Too Many Hops");
                return;
        };

        if (msg:len > max_len) {
                sl_send_reply("513", "Message Overflow");
                return;
        };

        # -----------------------------------------------------------------
        # Record Route Section
        # -----------------------------------------------------------------
        if (method=="INVITE" && client_nat_test("3")) {
                # INSERT YOUR IP ADDRESS HERE
                record_route_preset("OPENSER_IP:5060;nat=yes");
        #} else if (method=="ACK") {    
                #zzz
        #       record_route(); 
        } else if (method!="REGISTER") {        
                record_route(); 
        };

        # -----------------------------------------------------------------
        # Call Tear Down Section
        # -----------------------------------------------------------------
        if (method=="BYE" || method=="CANCEL") {
                end_media_session();
        };

        # -----------------------------------------------------------------
        # Loose Route Section
        # -----------------------------------------------------------------
        if (loose_route()) {

                if (has_totag() && (method=="INVITE" || method=="ACK")) {

                        if (client_nat_test("3")||search("^Route:.*;nat=yes")){
                                setflag(6);
                                use_media_proxy();
                        };
                };

                route(1);
                return;
        };

        # -----------------------------------------------------------------
        # Call Type Processing Section
        # is_uri_host_local will determine if the domain portion of the
        # Request URI is a domain that our SIP proxy is responsible for.
        # -----------------------------------------------------------------
        if (!is_uri_host_local()) {
                #xlog("L_INFO","SIP route4: line 121\n");
                #if (is_from_local() || allow_trusted()) {
                        route(4);
                        route(1);
                #} else {
                        #sl_send_reply("403", "Forbidden");
                #};
                return;
        };

        if (method=="CANCEL") {
                route(1);
                return;
        } else if (method=="INVITE") {
                route(3);
                return;
        } else  if (method=="REGISTER") {
                route(2);
                return;
        };

        lookup("aliases");
        if (uri!=myself) {
                route(4);
                route(1);
                return;
        };

        if (!lookup("location")) {
                sl_send_reply("404", "User Not Found");
                return;
        };

        route(1);
}

route[1] {

        # -----------------------------------------------------------------
        # Default Message Handler
        # -----------------------------------------------------------------

        # when dealing with NATed clients we must correctly handle reponse
        # messages that may be heading back to the client.  These
        # response messages are accessible in SER by using a reply_route
        # block
        t_on_reply("1");

        if (!t_relay()) {

                if (method=="INVITE" || method=="ACK") {
                        end_media_session();
                };

                sl_reply_error();
        };
}

route[2] {

        # -----------------------------------------------------------------
        # REGISTER Message Handler
        # -----------------------------------------------------------------

        sl_send_reply("100", "Trying");

        if (!search("^Contact:[ ]*\*") && client_nat_test("7")) {
                setflag(6);
                fix_nated_register();
                force_rport();
        };

        if (!www_authorize("","subscriber")) {
                www_challenge("","0");
                return;
        };

        if (!check_to()) {
                sl_send_reply("401", "Unauthorized");
                return;
        };

        consume_credentials();

        if (!save("location")) {
                sl_reply_error();
        };
}

route[3] {

        xlog("L_INFO","SIP : line 212\n");
        # -----------------------------------------------------------------
        # INVITE Message Handler
        # -----------------------------------------------------------------

        #if (!allow_trusted()) {

                #if (!proxy_authorize("","subscriber")) {
                        #proxy_challenge("","0");
                        #return;
                #} else if (!check_from()) {
                        #sl_send_reply("403", "Use From=ID");
                        #return;
                #};

                #consume_credentials();
        #};

        if (client_nat_test("3")) {
                setflag(7);
                force_rport();
                fix_nated_contact();
        };

        #if (uri=~"^sip:1[0-9]{10}@") {
        #       strip(1);
        #};

        lookup("aliases");
        if (uri!=myself) {
                route(4);
                route(1);
                return;
        };

        #if (uri=~"^sip:011[0-9]*@") {          # International PSTN
                #route(4);
                #route(5);
                #return;
        #};

        if (!lookup("location")) {
                if (uri=~"^sip:9[0-9]{8}@") {   # Domestic PSTN
                        route(4);
                        route(5);
                        return;
                };

                sl_send_reply("404", "User Not Found");
                return;
        };

        route(4);
        route(1);
}

route[4] {

        # -----------------------------------------------------------------
        # NAT Traversal Section
        # -----------------------------------------------------------------

        #xlog("L_INFO","SIP route4: line 274\n");
        if (isflagset(6) || isflagset(7)) {
                xlog("L_INFO","SIP : line 275 use_media_proxy\n");
                use_media_proxy();
        };
}

route[5] {

        # -----------------------------------------------------------------
        # PSTN Handler
        # -----------------------------------------------------------------

        rewritehost("203.193.46.242"); # INSERT YOUR PSTN GATEWAY IP ADDRESS
        #xlog("L_INFO","SIP route5: line 287\n");

        avp_write("i:45", "inv_timeout");

        route(4);
        route(1);
}

onreply_route[1] {

        if ((isflagset(6) || isflagset(7)) &&
            (status=~"(180)|(183)|2[0-9][0-9]")) {

                if (!search("^Content-Length:[ ]*0")) {
                        use_media_proxy();
                };
        };

        if (client_nat_test("1")) {
                fix_nated_contact();
        };
}
<<<<<<<<<<<<--------------end of openser.cfg------------------

>>>>>>>>>>>------------start of mediaproxy.ini----------------
;
; Configuration file for MediaProxy
;

[Dispatcher]
;
; Section for configuring the proxy dispatcher
;
; The following options are available here:
;
; start         Boolean value that specifies if to start the dispatcher.
;               Default value: Yes
;
; socket        Path to the UNIX socket where the dispatcher receives
;               commands from SER. This should match the value for
;               mediaproxy_socket in ser.cfg
;               Default value: /var/run/proxydispatcher.sock
;
; group         Put the socket in this group and make it group writable.
;               Default value: ser
;
; defaultProxy  Default mediaproxy to use in case the From/To domains
;               involved in the call don't define any.
;               Valid values for this are:
;
;                - None
;                    don't use any default proxies. domains without
;                    mediaproxy SRV records won't work
;                - /path/to/unix/socket
;                    use a single MediaProxy server identified by the given
;                    UNIX socket path
;                - IP_or_hostname[:port]
;                    use a single MediaProxy server identified by its network
;                    address. The network address consists of an IP address
;                    or a hostname and an optional port number separated by
;                    a double colon. If port is missing 25060 will be assumed.
;                    Examples:
;                       10.0.0.1    (connect to 10.0.0.1 on port 25060)
;                       10.0.0.1:90 (connect to 10.0.0.1 on port 90)
;                       mp1.mydomain.com
;                       mp1.mydomain.com:7000
;                - domain://domain_name
;                    Use all MediaProxies defined by domain_name, honoring
;                    their priority and weight to create a cluster of proxies
;                    with fallback and load balancing capabilities.
;
;               Default value: /var/run/mediaproxy.sock
;
;start = yes
;socket = /var/run/proxydispatcher.sock
;group = ser
;defaultProxy = /var/run/mediaproxy.sock

[MediaProxy]
;
; Section for configuring the MediaProxy server
;
; The following options are available here:
;
; start         Boolean value that specifies if to start the RTP proxy server.
;               Default value: Yes
;
; socket        Path to the UNIX socket where MediaProxy receives
;               commands from the dispatcher or SER.
;               Default value: /var/run/mediaproxy.sock
;
; group         Put the socket in this group and make it group writable.
;               Default value: ser
;
; listen        Network address where MediaProxy receives commands from
;               a remote dispatcher.
;               Valid values for this are:
;
;                - None
;                    don't listen for network connections at all
;                - address[:port]
;                    listen on the specified address and port
;                    address can be an IP a hostname or the keyword Any
;                    (in which case it will listen on 0.0.0.0). If address is
;                    a hostname, that should map in DNS to an IP address
;                    present on the machine through an A record.
;                    If port is missing assume 25060.
;
;               Default value: None
;
; allow         List of addresses that are allowed to connect to this
;               MediaProxy server and send commands.
;               They are specified as a comma separated list of entries, with
;               each entry being specified in the CIDR network/mask notation
;               (ex. 10.0.0.0/8)
;
;               In addition simple IP addresses or hostnames are allowed, in
;               which case the mask is considered to be 32.
;
;               In addition to network ranges/addresses 2 keywords can be used
;               for this option:
;                  None   to specify that none is allowed to connect (not very
;                         useful but this is the default for security reasons)
;                  Any    to specify that anyone is allowed to connect
;                         (dangerous!)
;
;               Example: allow = 10.0.0.0/24, home-pc.mydomain.com, 1.2.3.4
;
;               Default value: None
;
; proxyIP       IP address to use to talk to the phones. If not specified, the
;               first found will be used. However first found usually means
;               first defined in /etc/hosts which may not be what you want.
;               If you find that the address that's automatically selected is
;               not the one you want, you can specify the right one using this
;               option. The address must be one that's present on one of the
;               host's interfaces.
;
; portRange     The range of ports to use for proxying the rtp streams.
;               This option is specified as minport:maxport with minport and
;               maxport being even numbers in the range 1024-65536
;               Default value: 35000:65000
;
; TOS           Unless you know what TOS means, leave this option alone.
;               The TOS value can be specified either as a decimal number or
;               as a hex number in the 0xnn format.
;               Default value: 0xb8
;
; idleTimeout   Expire idle sessions after this much time.
;               Default 60 seconds
;
; holdTimeout   Expire calls on hold after this much time.
;               Default value is 3600 seconds
;
; forceClose    Forcibly close a RTP session after this many seconds even if
;               it's still active. If forceClose is 0, then a session is never
;               closed no matter how long it lasts.
;               Default value: 0
;
;start = yes
;socket = /var/run/mediaproxy.sock
;group = ser
;listen = None
;allow = None
;proxyIP = 10.0.0.1
;portRange = 35000:65000
;TOS = 0xb8
;idleTimeout = 60
;holdTimeout = 3600
;forceClose = 0
accounting = off

[Accounting]
user = dbuser
password = dbpass
host = dbhost
database = radius
table = radacct
<<<<<<<<<<<-----------end of mediaproxy.ini-------------

_______________________________________________
Users mailing list
[email protected]
http://openser.org/cgi-bin/mailman/listinfo/users

Reply via email to