Recently I have setup a squid server for our office.

I have computer (A) with

  • two ethernet cards, one for internet and the second one for local network
  • It has Ubuntu server OS with squid-server and dhcp3-server installed
  • I have added few iptable rules to work like a router and redirect all http traffic to 3128 port
This link is my reference.

Everything worked fine for 2 days. All of a sudden internet speed went down drastically. When I connected the internet cable to my laptop to test the internet speed it was fine. Again when I reconnected it back to computer A everything was normal. This happened 4 times in a week. Could anyone here please help me why the internet speed is going down and it becomes normal when I reconnect the cable.

Rebooting the system (computer A) didn't make a difference. I have changed iptables so that http traffic doesn't redirect to 3128 port any further, still no change in the internet speed. I think the problem is not with squid but with something else. Here are my iptable rules





PROXYSERVERS=(Atlanta Baltimore Boston Chicago Dallas Denver Houston KansasCity LosAngeles Miami NewYork Philadelphia Phoenix SanAntonio SanDiego SanJose Seattle Washington)

iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X

modprobe ip_conntrack
modprobe ip_conntrack_ftp

echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -P INPUT DROP

iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

iptables -A INPUT -i $INTERNET -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables --table nat --append POSTROUTING --out-interface $INTERNET -j MASQUERADE
iptables --append FORWARD --in-interface $LAN_IN -j ACCEPT

iptables -A INPUT -i $LAN_IN -j ACCEPT
iptables -A OUTPUT -o $LAN_IN -j ACCEPT

while [ $I -lt $SERVERLEN ]; do
    iptables -t nat -A PREROUTING -i $LAN_IN -p tcp -d ${PROXYSERVERS[$I]}.wonderproxy.com --dport 80 -j ACCEPT 
    let I++
iptables -t nat -A PREROUTING -i $LAN_IN -p tcp --dport 80 -j DNAT --to $SQUID_SERVER:$SQUID_PORT

iptables -A INPUT --protocol tcp --dport 80 -j ACCEPT
iptables -A INPUT --protocol tcp --dport 443 -j ACCEPT
iptables -A INPUT --protocol tcp --dport 22 -j ACCEPT

iptables -A INPUT -j LOG
iptables -A INPUT -j DROP
  • Have you investigated a possible performance or capacity issue on the Squid proxy? I'm wondering if you looked at things like memory usage, load average, etc. Does internet access return to normal speed when you reboot the Squid box? – Adam Thompson Mar 29 '12 at 8:50
  • @AdamThompson I have added extra information to the question. please have look. I need to bypass http requests when our end users use proxies (wonderproxy) in their browsers. That's why a while loop. – Ranjith Kumar Mar 29 '12 at 11:08

I would also look for a DNS issue, just in case...

  • I'm a programmer and I'm new to this. Could you please guide me through what kind of dns issue it might be or give me some references where I can learn. Thanks – Ranjith Kumar Apr 2 '12 at 6:26
  • Look in /etc/resolv.conf: are those DNS servers always working properly? When squid seems not to work, issue some "nslookup www.google.it" commands and check if the answers make sense. To better locate the issue, I would also try disabling the dhcp server. – marcoc Apr 4 '12 at 7:21

You could try flushing the Squid cache when speed drops to check if the issue is related to the cache getting too big for your box :

squid -k shutdown
mv /var/squid/cache /var/squid/cache.old
squid -z
rm /var/squid/cache.old

(Replace /var/squid/cache by whatever your Squid cache directory is)

That should clean up your cache, and allow you to make sure that your performance issue has nothing to do with the box if that doesn't fix the problem. Otherwise, it means you may need more memory (Squid's performance depends directly on available memory) on your box.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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