[SR-Users] NAT issues with Kamailio + Asterisk with 2 NICs

Sergio Charrua sergio.charrua at voip.pt
Mon Dec 12 02:06:54 CET 2022


Hi all!

Got a random issue with NAT which I really have no clue how to solve.

Setup is as follows:
- Client A sends SIP INVITE through Public IP 1.2.3.4, where a Cisco
Firewall forwards NATed data to a Kamailio instance (acting as a SIPProxy
with dispatcher) listening with internal address 192.168.0.1 on port 5060.
RTPEngine is in the same server and address too.
- Kamailio will forward the invite to Asterisk NIC 1 (192.168.0.2) which
will do some provisioning and accounting stuff and redirect the call (if
authorized) to Client B's public IP address (all clients are outside the
network, reachable via WWW) using NIC 2 (192.168.1.2) and public address
4.3.2.1.

The issue is that from time to time, calls will not have audio.
Here is what I have found:
- when Client A sends INVITE, Asterisk NIC 1 will reply SIP 183 with SDP IP
Address set to the internal IP of NIC 1 (192.168.0.2)
- when Asterisk forwards call to Client B public IP address the SDP IP
address is 192.168.1.2 (NIC 2)

And I think the issue is the SDP address is wrong: when Asterisk forwards
call to Client B, the SDP address should be the public IP 4.3.2.1 but it
sends 192.168.1.2.
And when Asterisk replies to Kamailio the SDP is 192.168.0.1.

Correct me if I am wrong but i think the solution should be:
- when Kamailio receives a reply from Asterisk to be forwarded to Client A,
it should modify the SDP address to public IP 1.2.3.4
- when Asterisk forwards call to Client B, the sip.conf should have the
parameter externip set to the public IP 4.3.2.1

Questions:
- are my analysis & solution correct?
- is there an example of the above setup where I could get some ideas?
- how do I set Kamailio to modify the SDP address for me?  Any examples?

Thanks in advance.

*Sérgio Charrua*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20221212/f4513fc7/attachment.htm>


More information about the sr-users mailing list