LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Squid / IPTables configuration: Dynamic IP Address provided by ISP (http://www.linuxquestions.org/questions/linux-networking-3/squid-iptables-configuration-dynamic-ip-address-provided-by-isp-766479/)

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 http://www.dotweb.in/share-both.jpg

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 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl purge method PURGE
acl CONNECT method CONNECT
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 192.168.0.1 192.168.2.0/24
http_access allow localhost
http_access allow lan
http_access deny all
http_reply_access allow all
icp_access allow all
visible_hostname myclient.hostname.com
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: http://www.aboutdebian.com/proxy.htm

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.

ch

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 07:23 AM.