Search squid archive

Re: Change tcp_outgoing_address every hour, best way to do this?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ah - this is what I was "looking" for....makes me wonder...i might change my setup :)

So tcp_outgoing_address supports ACL's tagged to it, so you could have something like....

acl morning time 06:00-11:59
acl afternoon time 12:00-18:00
acl night time 18:00-06:00

tcp_outgoing_address 1.2.3.4 morning # IP used in the morning
tcp_outgoing_address 1.2.3.4 afternoon # IP used in the afternoon
tcp_outgoing_address 1.2.3.4 night # IP used in the night

Cheers,

Pieter

On Tue, 13 Oct 2009, Henrik Nordstrom wrote:

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



[Index of Archives]     [Linux Audio Users]     [Samba]     [Big List of Linux Books]     [Linux USB]     [Yosemite News]

  Powered by Linux