Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I try to implement transparent proxy with my squid proxy server and iptables on the same machine but somehow it doesn't work although it looks relatively easy from what i have googled through.
From what i read, I simply need the following configurations to build a transparent proxy.
ON squid:
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
$IPT -A INPUT -i lo -j ACCEPT
$IPT -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A INPUT -m state --state NEW -p tcp --dport 3128 -j ACCEPT
$IPT -A INPUT -m state --state NEW -p udp --dport 53 -j ACCEPT
$IPT -A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
$IPT -A INPUT -m state --state NEW -p tcp --dport 8080 -j ACCEPT
$IPT -A INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT
$IPT -A INPUT -m state --state NEW -p tcp --dport 389 -j ACCEPT
$IPT -A INPUT -m state --state NEW -p tcp --dport 22 -j ACCEPT
$IPT -A INPUT -m state --state NEW -p tcp --dport 23 -j ACCEPT
$IPT -A INPUT -m state --state NEW -p udp --dport 21 -j ACCEPT
$IPT -A INPUT -m state --state NEW -p udp --dport 20 -j ACCEPT
$IPT -A INPUT -m state --state NEW -p tcp --dport 20 -j ACCEPT
$IPT -A INPUT -m state --state NEW -p tcp --dport 10000 -j ACCEPT
$IPT -A INPUT -p icmp -j ACCEPT
$IPT -A INPUT -j DROP
$IPT -A OUTPUT -o lo -j ACCEPT
$IPT -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -m state --state NEW -p tcp --dport 3128 -j ACCEPT
$IPT -A OUTPUT -m state --state NEW -p udp --dport 53 -j ACCEPT
$IPT -A OUTPUT -m state --state NEW -p tcp --dport 389 -j ACCEPT
$IPT -A OUTPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
$IPT -A OUTPUT -m state --state NEW -p tcp --dport 8080 -j ACCEPT
$IPT -A OUTPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT
$IPT -A OUTPUT -m state --state NEW -p tcp --dport 23 -j ACCEPT
$IPT -A OUTPUT -m state --state NEW -p udp --dport 21 -j ACCEPT
$IPT -A OUTPUT -m state --state NEW -p udp --dport 20 -j ACCEPT
$IPT -A OUTPUT -m state --state NEW -p tcp --dport 20 -j ACCEPT
$IPT -A OUTPUT -m state --state NEW -p tcp --dport 22 -j ACCEPT
$IPT -A OUTPUT -j DROP
$IPT -A FORWARD -o lo -j ACCEPT
$IPT -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A FORWARD -j DROP
Firstly you need a compiled version of Squid that supports this. Also, if you're using version 2.6 or 3.0 you only need the following in the .conf file:
Code:
http_port 3128 transparent
For previous versions you need:
Code:
http_port 3128
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
As far as iptables goes, something like the following is recommended:
thanks for your reply.
I am running squid-2.5.STABLE14-1.RHEL4.
so i use: http_port 3128
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
and also have corrected ports to port but still no luck...
You can confirm this by checking the Squid log (usually) in /var/log/squid/cache.log
If it started correctly, then you can check whether connections are reaching it by looking in /var/log/squid/access.log
NOTE, that's --to-port, not --to-ports as you have listed.
If you check the iptables manual you'll see it's supposed to be --to-ports (with an "s"), but I wouldn't be surprised if they made it work without the "s" also.
Niceman2005, additionally to the log file information, please post the output of these three commands:
If you check the iptables manual you'll see it's supposed to be --to-ports (with an "s"), but I wouldn't be surprised if they made it work without the "s" also.
Thanks for pointing out the changed syntax win32sux. My firewall scripts (and the Squid FAQ) haven't been updated in a long time. I don't know when it was changed to --to-ports but the old syntax still works.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.