วันพฤหัสบดี, เมษายน 20, 2549

squid tip

สำหรับวง Lan หรือเล่นคนเดียว brock d/l ได้ 100 % และยัง brock www ได้อีกแต่ต้องสร้าง url.conf ไว้ใน C:/squid/etc/ แล้วใน url.conf ให้ใส่ชื่อที่ต้องการ brock คำใน www เข้าไปได้เลย เช่น sex xxx fuck

http_port 8080
icp_port 3130
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
cache_mem 42 MB <<< เอาแรมในเครื่อง หาร 3 นะครับ
cache_replacement_policy heap GDSF
memory_replacement_policy heap GDSF
maximum_object_size 4096 KB
minimum_object_size 0 KB
cache_dir ufs C:/squid/cache 128 16 256 <<< ท่าใครคิดว่าเครื่องส่งถ่ายข้อมูลดี ก็เพิ่ม ได้นะครับ
cache_access_log C:/squid/var/logs/access.log
cache_store_log C:/squid/var/logs/store.log
cache_log C:/squid/var/logs/cache.log
mime_table C:/squid/etc/mime.conf
pid_filename C:/squid/squid.pid
buffered_logs on
logfile_rotate 7
ie_refresh on
reference_age 2 hours <<< ส่วนนี้ใส่ไว้ 2 ชม. เพื่อให้ referen cache มั้งครับทุก 2 ชม. แล้วแต่ใครจะตั้งเท่าไหร่ตามใจท่าน
refresh_pattern -i \.(gif|jpg|jpeg|png|bmp|tif|xbm|tiff)$ 604800 20% 2419200 <<< ส่วนนี้เป็นการเพิ่ม buffer ให้พวกนามสกุล jpg gif อะไรพวกนี้ที่อยากให้โหลดเร็วขึ้น
refresh_pattern ^http:// 4320 20% 43200 <<< อันนี้เป็นส่วนของ www
refresh_pattern ^ftp: 4320 20% 43200 <<< อันนี้เป็นส่วนของ ftp
refresh_pattern . 86400 20% 2419200 <<< อันนี้เป็นส่วนของ .
acl all src 0.0.0.0/0.0.0.0
acl localhost src 127.0.0.1/255.255.255.255
acl localnet src 192.168.0.0/255.255.255.0
acl manager proto cache_object
acl lock url_regex 'C:/squid/etc/url.conf'
http_access deny lock
acl download urlpath_regex -i \.exe$ \.zip$ \.rar$ \.mp3$
http_access deny download
acl Safe_ports port 80 443 210 70 21 1025-65535
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access allow localhost
http_access allow localnet
http_access deny !Safe_ports
http_access deny CONNECT
http_access deny all
icp_access allow all
dns_nameservers 203.121.130.39 <<< ส่วนนี้คือค่า DNS ของ ISP ที่เราใช้อยู่ท่าใช้เน็ต 2 ISP ก็ใส่ไป 2แถว
dns_nameservers 203.113.93.1
cache_effective_user squid
cache_effective_group squid
cache_mgr Administrator
visible_hostname Jasda
delay_pools 2 <<< 4 บรรทัดนับจากนี้ไปเป็นการจำกัดแบนวิทให้กับคนที่ใช้ www ผ่าน squid
delay_class 1 2
delay_access 1 allow all <<< allow all นี้คือทั้งหมดนะครับ
delay_parameters 1 -1/-1 5000/5000 <<< อันนี้จำกัดไว้ที่ 50 kbps

******************************************************************จบ********************************************************* ปล ท่าเอาไปใช้อย่าลืมลบ <<< คำที่เขียนต่อท้ายด้วยหละ
หมายเหตุท่าจาให้ squid จำกัดแบนวิท ได้ต้องใช้ squid เวอร์ชั่น squid-2.5.STABLE5-NT-bin-DELAYP.zip ด้วยนะครับ หา d/l ได้ที่ http://www.serassio.it/ ครับ
ส่วนร้านใครที่เปิดให้ d/l ได้แต่อยากจะกำจัด แบนวิท ในการ d/l ก็ทำได้ครับโดยการทำตามนี้เลยครับ

acl zip url_regex -i (\.zip$|\.exe$|\.rar$)
delay_pools 2
delay_class 1 2
delay_access 1 allow all !zip
delay_parameters 1 -1/-1 5000/5000

อันนี้จาจำกัดเฉพาะ zip exe rar ให้ d/l ได้ 50 kbps ครับ

acl บรรทัดแรกบอกสควิดว่า ไฟลล์แบบไหนไม่คุม D/L
บรรทัด ที่มี 5000/5000 เป็นตัวกำหนด ความเร็วD/L สูงสุด ; 5000=5kชุดแรก
คือแต่ละเครื่อง ; 5000ชุดสองกำหนดแต่ละเครื่องรวมกันไม่เกิน5000=5k
ถ้ากำหนดไว้ 5000/5000 ยังไงก้อD/Lไม่เกิน5เค
ถ้ากำหนดไว้ 3000/5000 ก้อแต่ละเครื่อง3k ไม่เกิน5k






block ราย บุคคล



คร่าวๆนะครับ
ทำ transparent proxy ถ้าหากต้องการบล็อก download ไปเลยก็กำหนด acl โดยประมาณตามนี้ครับ (ตัดมาบางส่วน ติ๊ต่างว่าคนถามเข้าใจเรื่องพวกนี้พอควร)
acl mynet src xxx.xxx.xxx..xxx/xxx.xxx.xxx.xxx ----- xxx แทนด้วย ip/subnet mask
acl daytime time 09:00-16:30 MTWHFAS
acl download urlpath_regex \.exe$ \.EXE$ \.zip$ \.ZIP$ \.rar$ \.RAR$ \.mp3$ \.MP3$ \.mov$ \.MOV$ \.mpg$ \.MPG$ \.mpeg$ \.MPEG$ \.avi$ \.iso$ \.AVI$
....
....

http_access deny download daytime
http_access allow mynet

ส่วนถ้าหากต้องการอนุญาติให้บางคนโหลดได้หรืออยู่นอกเหนือกฏต่างก็ กำหนด

acl allowall src "/etc/squid/allow.ip" ---- เก็บหมายเลขไอพีที่ต้องการอนุญาติ
acl mynet src xxx.xxx.xxx..xxx/xxx.xxx.xxx.xxx ----- xxx แทนด้วย ip/subnet mask
acl daytime time 09:00-16:30 MTWHFAS
acl download urlpath_regex \.exe$ \.EXE$ \.zip$ \.ZIP$ \.rar$ \.RAR$ \.mp3$ \.MP3$ \.mov$ \.MOV$ \.mpg$ \.MPG$ \.mpeg$ \.MPEG$ \.avi$ \.iso$ \.AVI$
....

http_access allow allowall
http_access deny download daytime
http_access allow mynet





------------------------------------------------------------------------
วิธีการ block เวบที่ไม่พึงประสงค์ทั้งหมด ใน linux RH XX ทำได้ดังนี้ครับ

1. พิมพ์บัญชีดำ รายชื่อเวบที่ไม่ต้องการให้เข้าไป (ในที่นี้สมมติ) suwanun.txt ในไฟล์มีข้อความ
#<=================>
http://www.sexy.com/
http://www.ddd.com/game/*
http://......................ฯลฯ
<=================>

2. แก้ไขไฟล์ squid.conf ในหัวส่วนต่อไปนี้ acl และ http_access

#<==================>
acl lockschool url_regex '/etc/squid/suwanun.txt' ( บรรทัดนี้ เอาไว้บนสุดของ acl ...... เลยนะครับ)
http_access deny lockschool ( บรรทัดนี้เอาไว้บนสุดของ http_access.........)
<====================>

3. copy ไฟล์ suwanun.txt ไปไว้ที่ ไดเรคตอรี่ /etc/squid/ (ตามที่ระบุใน path อาจพิมพ์โดยตรงด้วย pico ใน path ดังกล่าวก็ได้ครับ)

4. เครื่องลูกทุกเครื่องให้ fix IP เพราะง่ายต่อการตรวจสอบภายหลัง

หมายเหตุ
1 'lockschool' เป็นการตั้งชื่อ acl (ตั้งเป็นชื่ออะไรก็ได้ตามถนัด) แต่เวลาอ้างใน http_access deny ก็ต้องอ้างตามชื่อที่เราตั้งไว้

ทำ 4 ข้อที่กล่าวข้างต้นก็พอเพียงแล้วนะครับ โดยบัญชีรายชื่อเวบไม่พึงประสงค์เพิ่มลงไนไฟล์ suwanun.txt ได้ตลอดเวลา




------------------------------------------------------------------------------
สำหรับ SquidGuard ตัวนี้เป็นนำฐานข้อมูล .db มาใช้เก็บเว็บที่ไม่ต้องการและ สามารถเรียกตรวจสอบเวบที่มีอยู่ในฐานข้อมูลอย่างรวดเร็ว ซึ่งจะแตกต่างจากการใช้การ block โดยการเก็บรายชื่อเว็บแบบธรรมดา ซึ่งจะมีตรวจสอบเว็บที่ช้าถ้าหากมีรายชื่อเว็บในปริมาณที่มาก มาดูกันว่าการลงแบบนี้มีขั้นตอนอย่างไรบ้างครับ

1. ดาวน์โหลด squidGuard-1.2.0-3.i386.rpm
2. ดาวน์โหลด squidGuard-1.2.0-3.src.rpm
3. ติดตั้ง squidGuard-1.2.0-3.i386.rpm

[root@NicNack squidstuff]# rpm -Uvh --nodeps ./squidGuard-1.2.0-3.i386.rpm
Preparing... ########################################### [100%]
1:squidGuard ########################################### [100%]


4. ติดตั้ง squidGuard-1.2.0-3.src.rpm

root@NicNack squidstuff]# rpm -Uvh ./squidGuard-1.2.0-3.src.rpm
1:squidGuard ########################################### [100%]


[root@NicNack squidstuff]# cd /usr/src/redhat/SOURCES/
[root@NicNack SOURCES]# ls
blacklists.tgz squidGuard.conf squidguard.logrotate
squidGuard-1.2.0.tar.gz squidguard.crond update_squidguard_blacklists



[root@NicNack SOURCES]# tar -zxvf ./squidGuard-1.2.0.tar.gz
[root@NicNack SOURCES]# cd squidGuard-1.2.0
[root@NicNack squidGuard-1.2.0]#./configure
[root@NicNack squidGuard-1.2.0]# make
[root@NicNack squidGuard-1.2.0]# cd src
[root@NicNack src]# cp ./squidGuard /usr/sbin/squidGuard
cp: overwrite `/usr/sbin/squidGuard'? y

5. แก้ไขไฟล์ squid.conf
[root@NicNack src]# vi /etc/squid/squid.conf
เพิ่มบรรทัดต่อไปนี้
redirect_program /usr/sbin/squidGuard -c /etc/squid/squidGuard.conf
redirect_children 5

6. การ update ไฟล์ เข้าไปที่ /var/squidGuard/blacklists ใช้ pico หรือ vi จัดการเพิ่มหรือลบเว็บที่ต้องการจากนั้นใช้คำสั่ง
[root@NicNack src]# /usr/sbin/update_squidguard_blacklists เพื่อแปลงเป็นฐานข้อมูล .db เช่น url เป็น url.db ครับ

7. แก้ไขไฟล์ squidGuard.cgi ใน /var/www/cgi-bin ดังนี้ครับ
7.1 ลบข้อความที่อยู่หลัง #! /usr/bin/perl ออก
7.2 ตรง# CONFIGURABLE OPTIONS: เปลี่ยน yourdomain เป็นตามที่ต้องการ สร้างไฟล์หรือดาวน์ไฟล์ที่ชื่อ blocked.gif มาเก็บไฟล์ในห้อง /var/www/html/images (อาจเปลี่ยนชื่อรูปภาพเป็นชื่ออื่นก็ได้)
$image = "/images/blocked.gif"; # RELATIVE TO DOCUMENT_ROOT
$redirect = "http://www.yourdomain/images/blocked.gif"; # "" TO AVOID REDIRECTION
$proxy = "www.yourdomain"; #
$proxymaster = "webmaster@yourdomain"; #

และ

%logo->{"default"}->{"url"}
= "http://www.yourdomain/images/blocked.gif";
%logo->{"default"}->{"href"}
= "http://www.yourdomain/";
8. ในการ redirect สามารถเข้าไปเปลี่ยนที่ SquidGuard.conf ใน /etc/squid ครับ

วันเสาร์, เมษายน 08, 2549

Keyword

1. MUST This word, or the terms "REQUIRED" or "SHALL", mean that the definition is an absolute requirement of the specification.

2. MUST NOT This phrase, or the phrase "SHALL NOT", mean that the definition is an absolute prohibition of the specification.

3. SHOULD This word, or the adjective "RECOMMENDED", mean that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course.

4. SHOULD NOT This phrase, or the phrase "NOT RECOMMENDED" mean that there may exist valid reasons in particular circumstances when the particular behavior is acceptable or even useful, but the full implications should be understood and the case carefully weighed before implementing any behavior described with this label.