Kasım 17, 2008 | In: Yazgaç
Squid’i Transparent Bridge Olarak Çalıştırmak
5651 sayılı Kanunun getirdiği yasal zorunluklardan dolayı, şirketimizde internete proxy kullanmadan çıkan kullanıcıların internet trafiğinin loglanması zorunlu hale geldi. Bu duruma çözüm olarak squidi transparent bridge modda çalıştırmanın uygun olacağını düşündük ve bununla ilgili araştırmalardan sonra squidi transparent bridge proxy olarak çalıştırdım. Bu süreçte, yaşadığım tecrübeleri burdan paylaşmak istiyorum.
Yapılan işi kısaca özetlemek gerekirse; Çift network interface’i olan Linux makinamızı bridge modda çalıştırıp, üzerinden akan Layer 2 trafikten HTTP olanları, makinenin kendi üzerine çekerek Netfilter ile işleyip, Squid ile loglamaktır.
Linux’u bridge modda çalıştırabilmek için öncelikle bridge-utils paketini sistemimize yüklememiz gerekir. etho ve eth1 interfacelerini bridge arayüzüne dahil ediyoruz.
ifconfig eth0 0.0.0.0 up ifconfig eth1 0.0.0.0 up brctl addbr br0 brctl addif br0 eth0 brctl addif br0 eth1 ifconfig br0 192.168.1.1 netmask 255.255.255.0 up Daha sonra ebtables paketini sisteme kurup aşağıdaki kuralları yazıyoruz. ebtables -t broute -A BROUTING -p IPv4 --ip-protocol 6 --ip-destination-port 80 -j redirect --redirect-target ACCEPT Yukarıdaki kural ile bridge üzerinden akan HTTP trafiğini,sanki kendi makinemize yönlendirilmiş bir trafik gibi içeri alıyoruz. iptables -t nat -A PREROUTING -i br0 -p tcp --dport 80 -j REDIRECT --to-port 3128 80 portundaki trafiği 3128 nolu porta redirect ediyoruz. Squid 3 versiyonu için /etc/squid.conf dosyası aşağıdaki gibi düzenlendi: http_port 3128 transparent hierarchy_stoplist cgi-bin ? acl QUERY urlpath_regex cgi-bin \? cache deny QUERY acl apache rep_header Server ^Apache access_log /var/log/squid/access.log squid hosts_file /etc/hosts refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern . 0 20% 4320acl 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 SSL_ports port 443 563 # https, snews acl SSL_ports port 873 # rsync acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 563 # https, snews acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl Safe_ports port 631 # cups acl Safe_ports port 873 # rsync acl Safe_ports port 901 # SWAT acl purge method PURGE acl CONNECT method CONNECT 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 http_access allow localhost acl lan src 192.168.1.0/24 http_access allow localhost http_access allow lan
- acl all src 0.0.0.0/0.0.0.0
http_reply_access allow all icp_access allow all visible_hostname suseproxy.domainadi.com always_direct allow all coredump_dir /var/spool/squid Önemli Not: Squid transparent modda HTTPS trafiğini işleyemiyor.
- http_access allow all
