Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IPTables configuration for Transparent Proxy

Tags:

proxy

iptables

I am confuse why my IPTable does not work in Router. what I'm trying to do is redirect any packets from source ip destined to port 80 and 443 to 192.168.1.110:3128. however when I tried this:

 iptables -t nat -A PREROUTING -s 192.168.1.5 -p tcp --dport 80:443 -j DNAT --to-destination 192.168.1.110:3128

does not work. however when I add this,

iptables -t nat -A POSTROUTING-j MASQUARADE

it works. but the problem with masquarade is I do not get the real ip but instead the ip of the router. I need to get the source ip so my proxy server could record all ip connected to it. can some one tell me how to make it work without making POSTROUTING jump to Masquarade?

like image 802
James G Avatar asked May 15 '12 06:05

James G


People also ask

How do I make squid a transparent proxy?

If you configured Squid as a manual proxy and want to configure Squid as a fully transparent proxy again, complete the following steps: Enter the command store squid proxy default . Restart Squid by entering the command restart squid .

What is transparent network proxy?

A transparent proxy, also known as an inline proxy, intercepting proxy or forced proxy, is a server that intercepts the connection between an end-user or device and the internet. It is called “transparent” because it does so without modifying requests and responses.

Is a transparent proxy a forward proxy?

In transparent forward proxy, you configure your internal network to forward web traffic to the BIG-IP® system with Secure Web Gateway (SWG). This implementation describes an inline deployment . You place the BIG-IP system directly in the path of traffic, or inline, as the next hop after the gateway.


1 Answers

For real transparent proxying you need to use the TPROXY target (in the mangle table, PREROUTING chain). All other iptables-mechanisms like any NAT, MASQUERADE, REDIRECT rewrite the IP addresses of the packet, which makes it impossible to find out where the packet originally was intended to.

The proxy program has to bind() and listen() on a socket like any other server, but needs some specific socket flags (which requires some Linux capabilities (type of permission) or root). – Once connected, there is some way to get the “intended server” from the OS.

Sorry, I’m a little lazy about the details, but searching for “TPROXY” as keyword will get you going quickly!

like image 187
Robert Siemer Avatar answered Sep 21 '22 18:09

Robert Siemer