[SR-Users] Dispatcher with kam & fs behind nat

Alex Balashov abalashov at evaristesys.com
Mon Nov 27 06:08:34 CET 2017


On Mon, Nov 27, 2017 at 12:00:10AM -0500, Daniel Greenwald wrote:

> Should Kam put two record-route headers on, one with PUBLICIP and one
> with PRIVATEIP? How is this accomplished?

Yep, you're exactly on the right track.

For purposes of this discussion, 10.0.0.1 is the internal IP (and also
the IP to which an external IP is NAT'd), 192.0.0.1 is the public
IP, and we're using UDP only.

1) Add two listeners on the same interface, one of which advertises the
public interface and the other of which does not[1], e.g.

   # "External" interface.

   listen=udp:10.0.0.1:5060 advertise 192.0.0.1:5060

   # "Internal" interface. Same network address, but by necessity,
   # different port.

   listen=udp:10.0.0.1:5080

2) Use the following setting to enable double Record-Route, though it's
on by default so if it's not set you can just omit it.

   modparam("rr", "enable_double_rr", 1) 

3) Set mhomed=0[3] as its routing logic will fail you here, and use
$fs[4] to steer initial requests manually, e.g.

   route[INBOUND_INVITE] {
      ...

      $fs = 'udp:10.0.0.1:5080';

      if(!t_relay())
         sl_reply_error();
   }

   route[OUTBOUND_INVITE] {
      ...

      $fs = 'udp:10.0.0.1:5060';

      if(!t_relay())
         sl_reply_error();
   }

Do the same for any other types of _initial_ requests you wish to route
between the interfaces, e.g. if you're passing on REGISTERs, SUBSCRIBE,
etc.

4) Profit. Everything else should fall into place "automagically",
including a) in-dialog requests, by way of the appropriate Route set and
b) replies.

-- Alex

[1] https://www.kamailio.org/wiki/cookbooks/5.0.x/core#listen

[2] https://kamailio.org/docs/modules/5.0.x/modules/rr.html#idp25575876

[3] https://www.kamailio.org/wiki/cookbooks/5.0.x/core#mhomed

[4] https://www.kamailio.org/wiki/cookbooks/5.0.x/pseudovariables#fs_-_forced_socket

-- 
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free) 
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/



More information about the sr-users mailing list