Tuesday, May 6, 2014

Transparently proxifying certain machines in the network

I use an Ubuntu box as a wifi access point/router in my home network. I wanted to transparently proxify certain machines on the network (mainly my Kindle paperwhite --long story!). I finally managed to do it like this:

sudo iptables -t nat -A PREROUTING -m mac --mac-source "MAC-ADDRESS" -p tcp --dport 80 -j REDIRECT --to-port 33128
 In which MAC-ADDRESS is the mac address of the machine I want to proxify. A squid instance is listening on 33128. I had to change this line in my squid configuration:

http_port 33128
to this:

http_port 33128 transparent
so that squid handles transparent proxy-ing correctly.

I'm using iptables version 1.4.21 on Ubuntu 14.04, and squid version 2.7.

No comments:

Post a Comment