Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

To begin with, I'm a linux newb. I have setup a squid proxy on my home network and it is working fine. I went through couple of tutorials to get this working. My setup is: Internet->Modem->Router-My devices (including squid proxy server).

Following are the iptables changes I made in my router:

My Proxy IP 192.168.1.130

iptables -t mangle -A PREROUTING -p tcp --dport 80 -s 192.168.1.130 -j ACCEPT
iptables -t mangle -A PREROUTING -p tcp --dport 80 -j MARK --set-mark 3 
ip rule add fwmark 3 table 2 
ip route add default via 192.168.1.130 dev br0 table 2 

Changes made to iptables on proxy server:

iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128

I'm having a hard time understanding how my router is routing http traffic to the proxy server, here is what I'm understanding from it (very little -.-)

iptables -t mangle -A PREROUTING -p tcp --dport 80 -s 192.168.1.130 -j ACCEPT

With that command, the router will accept tcp packets coming from my proxy server destined to port 80, however I don't understand the destination port 80 part of it because I'm redirecting incoming tcp packets over 80 to 3128 on my proxy machine.

iptables -t mangle -A PREROUTING -p tcp --dport 80 -j MARK --set-mark 3

With that command, the firewall will mark all tcp packets destined to port 80 with 3 (I have no clue what I'm talking about).

ip rule add fwmark 3 table 2

Does that add mark 3 to table 2?

ip route add default via 192.168.1.130 dev br0 table 2

That matches the marked tcp packets and routes them through my proxy?

iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128

All incoming tcp packets destined to port 80 on interface eth0 will be redirected to port 3128 on the proxy server.

Please help me understand what the process. Thanks.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.