Getting source destination from iptables after REDIRECT

I am writing a proxy application for general use.

I want to use this as a transparent proxy, where my initial plan is to use iptables with the REDIRECT rule for all connections to my proxy server.

The problem here, of course, is that my application proxy is losing information about the intended destination.

Is it possible to query iptables to retrieve the originally assigned recipient? Any other possible solution to this problem is also welcome!

+5
source share
1 answer

Perhaps this is what you were looking for?

http://www.network-builders.com/iptables-redirect-original-destination-ip-t69515.html

SO_ORIGINAL_DST TCP.
/proc/net/ip _conntrack.

#include <linux/netfilter_ipv4.h>

struct sockaddr_in addr;
bzero((char *) &addr, sizeof(addr));
addr.sin_family = AF_NET;
socklen_t addr_sr = sizeof(addr);
getsockopt(fd, SOL_IP, SO_ORIGINAL_DST, &addr, &addr_sz );

, python.

+7

All Articles