Squid acl Multiple Ips Script



The following shell script will help you to add multiple IPs to squid configuration, you need to add all the IP address which you like to configure in squid in a file called “iplist” and then execute the following script. Make sure you take a backup of your squid.conf file before executing this script.


awk '{printf "acl ip""%s \t%s\n",NR, "myip" " " $0}' iplist >> /etc/squid/squid.conf

awk '{printf "tcp_outgoing_address" " " $0 " " "ip%s \t%s\n",NR,$5}' iplist >> /etc/squid/squid.conf

/etc/init.d/squid restart

so that the acl will look something like the following.

acl ip1       myip xx.xx.xx.x1
tcp_outgoing_address xx.xx.xx.x1 ip1 
acl ip1       myip xx.xx.xx.x2
tcp_outgoing_address xx.xx.xx.x2 ip2

That’s it. You are done. 🙂

One comment

  1. Free Stuff says:

    Hi, i think that i saw you visited my weblog so i came to ?eturn the favor?I am attempting to find things to enhance my web site!I suppose its ok to use some of your ideas!!

Leave a Reply

Protected by WP Anti Spam