<div dir="ltr">Hi all,<div>I've been recently testing kamailio support for proxy protocol which was introduced by <a href="https://github.com/kamailio/kamailio/issues/1757">https://github.com/kamailio/kamailio/issues/1757</a>. As reported by others, even if kamailio is able to decode the proxy protocol and get the client's original IP address, it is unable to send SIP messages to the client which initiated the connection through the HA load balancer (nginx in my case). After investigation I've found that there is no alias added to the tcp connection aliases list for the tuple CLIENT_IP:CLIENT_PORT/LOCAL_KAMAILIO_IP:KAMAILIO_PORT. This means that when trying to forward a message to the originating client kamailio won't use the existing connection with the load balancer/proxy but will try to establish a new connection. The fact is that the function which parses the proxy header overwrites the dst ip/port of the connection with the "Destination IP" and "Destination Port" fields of the proxy header (<a href="https://github.com/kamailio/kamailio/blob/f677dea597db6ceaa66a2755dd6e9e738855dc35/src/core/tcp_main.c#L989">https://github.com/kamailio/kamailio/blob/f677dea597db6ceaa66a2755dd6e9e738855dc35/src/core/tcp_main.c#L989</a> for v2, <a href="https://github.com/kamailio/kamailio/blob/f677dea597db6ceaa66a2755dd6e9e738855dc35/src/core/tcp_main.c#L1071">https://github.com/kamailio/kamailio/blob/f677dea597db6ceaa66a2755dd6e9e738855dc35/src/core/tcp_main.c#L1071</a> for v1). This fields contain the IP/port of the Load Balancer, not the kamailio IP/Port, and kamailio will fail to find a tcp connection toward the client's src IP since the Load Balancer IP is not a kamailio's local socket.</div><div>I think that the destination IP of the connection shouldn't be rewritten with the load balancer IP, unless I'm missing something.</div><div>Hopefully I've been clear enough explaining the issue :)</div><div>If you agree with the analysis I can prepare a PR for it.</div><div><br></div><div>Have you all a great weekend,</div><div><br></div><div>Federico Cabiddu</div><div><br></div></div>