Æðelstan
Æðelstan

Reputation: 852

Winsock / BSD Sockets - Accept TCP connections with destination IP different from local IP

I am forwarding some outgoing TCP traffic on LAN (eventually UDP as well) to a local (transparent) proxy server before sending them out on the internet. The packets are forwared correctly it seems, I can see the SYN's in Wireshark.

The problem is that accept() bound to a port X doesn't accept a connection with destination port X and a destination IP different from the proxy server's own IP it seems, which was something I expected.

Is there a way around this in Winsock or in Linux sockets? How can I achieve the accept() or similar?

Upvotes: 3

Views: 356

Answers (1)

Zaboj Campula
Zaboj Campula

Reputation: 3360

Linux sockets have the option IP_TRANSPARENT. See the linux man page ip:

IP_TRANSPARENT (since Linux 2.6.24)

Setting this boolean option enables transparent proxying on this socket. This socket option allows the calling application to bind to a nonlocal IP address and operate both as a client and a server with the foreign address as the local endpoint. ...

As far as I know the option is not available for windows sockets.

Upvotes: 3

Related Questions