木曜日, 4月 28, 2011

Proxy設定の自動化

apt-get install dhcp3-server

vi /etc/dhcp3/dhcpd.conf
以下を追記
authoritative;
option wpad code 252 = string;
option wpad "http://192.168.1.253/proxy.pac";

vi /var/www/proxy.pac

function FindProxyForURL(url, host)
{
if (isPlainHostName(host)) {
return "DIRECT";
}
if (isInNet(myIpAddress(), "192.168.1.0", "255.255.255.0")) {
if ((isInNet(dnsResolve(host), "192.168.1.0", "255.255.255.0"))) {
return "DIRECT";
}
else {
return "PROXY 192.168.1.253:3128";
}
}
}

ln -s /var/www/proxy.pac /var/www/proxy.pa

/etc/init.d/apache2 restart
/etc/init.d/dhcp3-server restart

あとは必要か所にdhcp-relayの設定をして終了。

「確認」
tail -f /var/log/apache2/access.log
tail -f /var/log/squid3/access.log