Hi,
I'm trying to use Kamailio as an outbound proxy behind a NAT (all clients and kamailio itself are behind the same NAT):
UACs -> Kamailio -> NAT router -> PBX (hosted, public server)
I figured I could detect the external source port used by the router by periodically sending an OPTIONS request to the public server, then capture the rport value in the reply, and use that port as an input to set_advertised_port. Because I'm doing this periodically, it should have the added value of keeping the NAT mapping alive. Otherwise, I should be able to detect it, as the rport value will change.
I managed to periodically send the OPTIONS request, read the rport value on the reply message and store it on a pseudovariable using:
$var(rport) = $sel(v.rport);
But when I try to use that value to set the advertised port, I get an error, as if set_advertised_port only accepted literal values:
if( $var(rport) != 0) { set_advertised_port($var(rport)); }
Not starting Kamailio: invalid configuration file! -e 0(4692) : <core> [cfg.y:3591]: parse error in config file /usr/local/etc/kamailio/kamailio.cfg, line 504, column 24-34: syntax error 0(4692) : <core> [cfg.y:3594]: parse error in config file /usr/local/etc/kamailio/kamailio.cfg, line 504, column 35: bad argument, string expected ERROR: bad config file (2 errors)
So, am I missing something or does set_advertised_port actually only accept literal values?
Thanks Neven Boric