-   Linux - Networking (
-   -   Squid / IPTables configuration: Dynamic IP Address provided by ISP (

vikram_cvk 11-03-2009 07:53 AM

Squid / IPTables configuration: Dynamic IP Address provided by ISP
I have a network with a broadband connection with dynamic ip address(external ip address provided by the ISP). How do I configure the squid proxy as the isp ip addresses is changing everytime we login. Please click on the following link to view our network diagram

What should be the appropriate IPTABLES commands to enable squid.

Following is our squid.conf file
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
hosts_file /etc/hosts
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
acl all src
acl manager proto cache_object
acl localhost src
acl to_localhost dst
acl purge method PURGE
cache_mem 1024 MB
http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
acl lan src
http_access allow localhost
http_access allow lan
http_access deny all
http_reply_access allow all
icp_access allow all
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
coredump_dir /var/spool/squid

chappel 11-03-2009 08:57 PM

I'm not a Squid expert, but I found this tutorial which may be helpful:

The pertinent section is a clever bit of piping that grabs the IP address dynamically as squid starts:

EXTIP="`/sbin/ifconfig ppp0 | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'`"
(you'll probably want to change the 'ppp0' bit to 'eth0', or whatever your external interface is)

There appears to be an assumption that the IP address only changes on a system restart; if there is a chance of your connection getting logged out and the IP address changing while squid is still running, you may require some additional scripting to detect the change and restart the squid service so the new address can take effect.

I hope this helps.


kaushalpatel1982 11-06-2009 08:59 AM

You have not mentioned whether you use squid as browser proxy or transperent. For browser you need not to configure any thing. it will just need to configure browser settings.

For transperent proxy:

#iptables -t nat -I PREROUTING -s <Your network> -p tcp --dport 80 -j REDIRECT --to-port <PROXY PORT>
#iptables -t nat -I POSTROUTING -s <your network> -o ppp0 -j MASQUERADE

I hope this will resolve your problem. Best of Luck

All times are GMT -5. The time now is 06:00 PM.