Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have just setup a squid proxy server. The server have two interfaces. eth0 connects to the router and eth1 is connected to a switch where all the other machines connect. The server also have a DHCP server. I have setup Squid3 on the machine and when I configure my browser to use that proxy (I network settings if I set the IP and the port), things work. But I need it as a transparent proxy where I don't have to setup the browser and all the requests will pass through the proxy.

It can be done by just setting the IPtable rules right? Some articles talk about changing sysctl.conf. I have tried the Iptable rules from a lot of tutorials and none worked. Please give me a working rule to add. Thank you.

PS : The server is Ubuntu 12.10

PS2 : If you can, please tell me how to add those rules for ufw

share|improve this question

1 Answer 1

You should change the following to match your configuration:

eth1 : LAN interface
eth0 : WAN interface
Squid PORT : 8028

Below are the settings for Squid in transparent mode.

# NAT
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT

# Redirect
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 8028 -j REDIRECT --to-port 80 
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j DNAT --to IPaddress:8028
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 8028
share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.