[Kamailio-Users] NAT Problems

Ross Beer ross_beer at hotmail.com
Thu Jul 31 13:49:36 CEST 2008


I am having problems with a NAT device. I have an asterisk server that is hosted on a public IP and when I connect my Snom phones to it directly audio passes correctly both ways. When I introduce Kamailio 1.3 into the mix I get one way audio.
 
I have fixed the SDP and contacts etc and everything appears to be ok with the sip packet. I would be very grateful for any ideas what the problem could be.
 
Outgoing calls from Kamailio -> asterisk -> PSTN work fine.
 
Thank you for your help in advance, it is much appreciated.
 
 
=================== config =======================
 
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483","Too Many Hops");
exit;
};
if (msg:len >= 2048 ) {
sl_send_reply("513", "Message too big");
exit;
};
# NAT detection
force_rport();
if(nat_uac_test("3"))
{

fix_nated_contact();
}
if (!method=="REGISTER")
{
record_route();
}
if (loose_route()) {
append_hf("P-hint: rr-enforced\r\n"); 
route(1);
};
if (!uri==myself) {
append_hf("P-hint: outbound\r\n"); 
route(1);
};
if (uri==myself) {
if (method=="REGISTER") 
{
if (!www_authorize("", "subscriber")) {
www_challenge("", "0");
exit;
};


if (isflagset(5)) 
{
# set branch flag -- when someone will call this user
# the INVITE will have branch flag 6 set after lookup("location")
setbflag(6);
 
};

fix_nated_contact();
fix_nated_register();
consume_credentials();
save("location");
exit;
};
if (!lookup("location")) {
sl_send_reply("404", "Not Found");
exit;
};
append_hf("P-hint: usrloc applied\r\n"); 
};

if(method=="MESSAGE")
{
if (!lookup("location"))
{
sl_send_reply("404", "User Offline");
exit;
}
route(4);
}

if (method=="REGISTER")
{
save("location");
}
 
route(1);
}
 
route[1] {
if (subst_uri('/(sip:.*);nat=yes/\1/')){
setbflag(6);
};
if (isflagset(5)||isbflagset(6)) {
route(3);
}
t_on_reply("1");
if (!t_relay()) {
sl_reply_error();
};
exit;
}
 
route[3] {
if (is_method("BYE")) 
{
unforce_rtp_proxy();
} 
else if (is_method("INVITE"))
{
fix_nated_sdp("3");
 
};
if (isflagset(5))
{
search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');
}
t_on_reply("1");
}
route[4]
{
if (!t_relay()) 
{
sl_reply_error();
};
exit;
}
 
 
failure_route[2] {
if (isbflagset(6) || isflagset(5)) 
{
unforce_rtp_proxy();
}
}
onreply_route[1] 
{
fix_nated_contact();
if (((isflagset(5) || isbflagset(6)) && status=~"(183)|(2[0-9][0-9])") || is_method("INVITE")) 
{
fix_nated_sdp("2");
force_rport();
 
}
search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');
}
 
 
 
==================== SIP PACKETS ===========================
INVITE sip:10001*202@**** IP ****;line=e25l7qyi SIP/2.0Record-Route: <sip:*** IP ***;lr=on;ftag=as0a2e0c2e>Via: SIP/2.0/UDP *** IP ***;branch=z9hG4bKb0a1.cf08f082.0v: SIP/2.0/UDP *** IP ***:5060;branch=z9hG4bK2bc03835;rport=5060f: "Name" <sip:*** DOMAIN ***>;tag=as0a2e0c2et: <sip:10001*202@** DOMAIN **>m: <sip:number@**IP**>i: 74391cce38d7c7f7549c863a651b8f81@*** DOMAIN ****CSeq: 102 INVITEUser-Agent: asterisk
Max-Forwards: 69Date: Thu, 31 Jul 2008 11:38:39 GMTAllow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFYk: replacesc: application/sdpl: 422P-hint: usrloc appliedv=0o=root 5390 5390 IN IP4 194.xxx.xxx.xxx
s=sessionc=IN IP4 194.xxx.xxx.xxxb=CT:384t=0 0m=audio 12558 RTP/AVP 0 8 3 101a=rtpmap:0 PCMU/8000a=rtpmap:8 PCMA/8000a=rtpmap:3 GSM/8000a=rtpmap:101 telephone-event/8000a=fmtp:101 0-16a=silenceSupp:off - - - -a=ptime:20a=sendrecvm=video 17918 RTP/AVP 34 103 99a=rtpmap:34 H263/90000a=rtpmap:103 h263-1998/90000a=rtpmap:99 H264/90000a=sendrecv
 
////////////// PHONE REPLY ////////////////////
SIP/2.0 200 OkVia: SIP/2.0/UDP **** IP ****:5060;branch=z9hG4bK19d7ec13;rport=5060Record-Route: <sip:*** IP ***;lr=on;ftag=as486f79a5>From: "*** NUMBER *****" <sip:*** DOMAIN *****>;tag=as486f79a5To: <sip:10001*202@*** DOMAIN *****>;tag=jgdy33ee6nCall-ID: *** ID ***
CSeq: 102 INVITEContact: <sip:*** DOMAIN ****:54686;line=e25l7qyi;nat=yes>;reg-id=1User-Agent: snom370/7.3.7Allow: INVITE, ACK, CANCEL, BYE, REFER, OPTIONS, NOTIFY, SUBSCRIBE, PRACK, MESSAGE, INFOAllow-Events: talk, hold, refer, call-infoSupported: timer, replaces, from-changeContent-Type: application/sdpContent-Length: 508
v=0o=root 1569142945 1569142946 IN IP4 192.168.1.20s=callc=IN IP4 ** EXTERNAL IP ***
t=0 0m=audio 10014 RTP/AVP 0 8 3 101a=rtpmap:0 pcmu/8000a=rtpmap:8 pcma/8000a=rtpmap:3 gsm/8000a=rtpmap:101 telephone-event/8000a=fmtp:101 0-16a=ptime:20a=alt:1 0.9 : user 9kksj== 192.168.1.20 10014a=sendrecvm=video 0 RTP/AVP 34 103 99a=rtpmap:34 H263/90000a=rtpmap:103 h263-1998/90000a=rtpmap:99 H264/90000a=alt:1 0.9 : user 9kksj== 192.168.1.20 10014a=sendrecva=oldmediaip:192.168.1.20
_________________________________________________________________
Find the best and worst places on the planet
http://clk.atdmt.com/UKM/go/101719807/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20080731/6c818d08/attachment.htm>


More information about the sr-users mailing list