Hello! 

Thanks in advance for any help you can provide.

I have a simple setup here and am struggling a bit with getting a final working solution.


This is just a single direction flow from a SIP provider inbound to servers running HMPelements with CTI integration (sip endpoint).  Essentially a different DN / dial number would go to a different backend server.  There is no registration involved.

The kamailio server therefore needs to sit between the SIP provider and the backend servers, it will be a NAT situation where private RFC1918 addresses will be used on the backend after the server receives it with public IP information.

So that's it.    What is the simplest way to accomplish this?


If it would help - here's what ive done so far:

For the Kamailio server, I have an AWS EC2 instance with a public IP bound/assigned to the main private IP.  During troubleshooting, I've added another private IP to the NIC so that I could throw up another listener.   I was thinking I'd need to accept the SIP on the first listener with the "advertise" directive.  The second listener would not have an advertise directive so perhaps could be used to talk to the backends. 

I defined the WITH NAT and rtp proxy settings (pointing to the first listener below).  The RTP Proxy daemon also knows about the y.y.y.y public address below.

In the kamailio.cfg, I have a listener setup :

listen=udp:172.24.40.28:5060 advertise y.y.y.y:5060
listen=udp:172.24.40.26:5060

then threw in a route(CMS)  in the request route and created the following route block:

route[CMS] {
        #check URI matches phone xxxxxxxxxx
        if (uri=~"^sip:\+1xxxxxxxxxx@") {
                rewritehostport("10.12.18.193:5060");
                forward(uri:host, uri:port);
                exit;
        };

}

I get the SIP delivered to the backend host!  but the INVITE headers are stil pointing to public IPs and the SDP info is not adjusted to be a private IP as well - as follows:
z.z.z.z = sip provider ,  y.y.y.y = public ip (aws ec2 ip). xxxxxxxxx = calling phone, ######## = called phone (matches routeCMS above)


INVITE sip:+1##########@10.12.18.193:5060 SIP/2.0
Record-Route: <sip:y.y.y.y;lr>
Via: SIP/2.0/UDP y.y.y.y:5060;branch=z9hG4bK28b7.56b42fdeec9f10cd13030b3711b16f4d.0
Via: SIP/2.0/UDP z.z.z.z:11000;received=z.z.z.z;rport=11000;branch=z9hG4bKQ2yQKgv7NtKQF
Max-Forwards: 48
From: "" <sip:+1xxxxxxxxxx@z.z.z.z;isup-oli=0>;tag=tUF15gaNg6N6j
To: <sip:+1##########@y.y.y.y>
Call-ID: 9ee7e073-c7fc-46ac-a839-f3c77eaed903
CSeq: 78244364 INVITE
Contact: <sip:mod_sofia@z.z.z.z:11000>
User-Agent: 2600Hz
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REFER, NOTIFY
Supported: path, replaces
Allow-Events: talk, hold, conference, refer
Privacy: none
Content-Type: application/sdp
Content-Disposition: session
Content-Length: 278
X-FS-Core-UUID: 4e0b2928-d913-42c4-9809-f77a36d281be
X-FS-Support: update_display,send_info
P-Asserted-Identity: "" <sip:+1xxxxxxxxx@z.z.z.z>

v=0
o=FreeSWITCH 1705572686 1705572687 IN IP4 z.z.z.z


Thanks much!