[SR-Users] Kamailio behind NAT - best practice
Klaus Darilion
klaus.mailinglists at pernau.at
Mon Jan 7 16:45:51 CET 2013
Hi all!
On 04.01.2013 18:57, Ovidiu Sas wrote:
> Hello Klauss,
>
> I use record_route_preset for this kind of scenarios:
> http://kamailio.org/docs/modules/3.3.x/modules_k/rr.html#id2550086
> That was the main reason that I enhanced record_route_preset with the
> second parameter (see the Note on string2).
>
> I haven't tried your idea with two sockets. Let us know if it's working.
> If you need to use the same port on the internal and external
> interface, you could add a new IP to the host and listen on two
> sockets on the same port and force the socket when sending a request
> out.
> listen=udp:10.10.0.2
> listen=udp:10.10.0.3 advertise pu.bl.ic.ip
I did some basic tests (incoming, outgoing, on/off-hold). The service
provider's SIP trunk was an Asterisk with NAT traversal disabled.
Kamailio was NATed 1:1 to the public IP address (exclusively, without
port translation). I tested Kamailio only doing near-end NAT-traversal
(taking care of its own NAT).
I used two IP addresses for the two sockets, but I must works also with
a single IP address and different ports.
Conclusion: works :-)
Following is the setup how I tested it (if you need to add far-end NAT
traversal (SIP clients behind another NAT) then it will more complex).
regards
Klaus
# Service Provider for SIP Trunk: 5.5.5.5
# public IP address of Kamailio/rtpproxy: 3.3.3.3
# rtpproxy binds to 10.10.0.3
listen=udp:10.10.0.2
listen=udp:10.10.0.3 advertise 3.3.3.3:5060
mhomed=0
route[RELAY] {
if (src_ip == 5.5.5.5) {
force_send_socket("10.10.0.2");
rtpproxy_manage("","10.10.0.3");
} else {
force_send_socket("10.10.0.3");
rtpproxy_manage("","3.3.3.3");
}
...
t_relay();
}
onreply_route {
if (src_ip == 5.5.5.5) {
force_send_socket("10.10.0.2");
rtpproxy_manage("","10.10.0.3");
} else {
force_send_socket("10.10.0.3");
rtpproxy_manage("","3.3.3.3");
}
}
More information about the sr-users
mailing list