Re: [squid-users] Change tcp_outgoing_address every hour, best way to do this?

From: Henrik Nordstrom <henrik_at_henriknordstrom.net>
Date: Tue, 13 Oct 2009 19:48:11 +0200

tis 2009-10-13 klockan 11:19 -0500 skrev Andres Salazar:
> Hello,
>
> Iam wanting to pass the option of tcp_outgoing_address when I run the
> command to refresh or reload the config file. This so that every hour
> I can rorate with a cron the IP that squid uses to browse the
> internet.
>
> Is this possible? Or is there a better way then to create dozens of
> config files with the only difference being the IP?

I would set up a included squid.conf snippet with 24
tcp_outgoing_address settings (one per hour, selected by acl) and update
this file nightly to assign a new set of IP addresses for the next day.

generate_random_outgoing.sh

#!/bin/sh
top=`dirname $0`
HOUR=0
cat $1 | sort -R | while [ $HOUR -lt 24 ] && read ip; do
  printf "acl hour_%d time %02d:00-%02d:59\n" $HOUR $HOUR $HOUR
  printf "tcp_outgoing_address %s hour_%d\n" $ip $HOUR
  HOUR=`expr $HOUR + 1`
done

Usage:
generate_random_outgoing.sh /path/to/file_with_ipaddresses.txt >/path/to/etc/squid/random_outgoing.conf
squid -k reconfigure

and in squid.conf

include /path/to/etc/squid/random_outgoing.conf

Regards
Henrik
Received on Tue Oct 13 2009 - 17:48:18 MDT

This archive was generated by hypermail 2.2.0 : Wed Oct 14 2009 - 12:00:02 MDT