วันพุธที่ 11 พฤษภาคม พ.ศ. 2554

การ Config Squid.conf

การ Config Squid.conf

1. การจำกัดเวลาลูกข่ายใช้อินเตอร์เน็ต

acl acl_net src 172.17.8.0/24 // วงที่ออกเน็ตได้
acl acl_client src 172.17.8.10 // IP ที่ต้องการห้ามออกเน็ตเป็นเวลา
acl acl_time time MTWHF 17:00-23:59
acl acl_time2 time MTWHF 0:00-7:00
http_access deny acl_client acl_time
http_access deny acl_client acl_time2
http_access allow acl_net

(M จันทร์ T อังคาร W พุธ H พฤหัส F ศุกร์ A เสาร์ S อาทิตย์)

2. การบล็อค MSN

คำตอบ ให้เพิ่ม เข้าไปใน squid.conf ส่วนของ ACCESS CONTROL

acl chatMSN req_mime_type -i ^application/x-msn-messenger$

http_reply_access deny chatMSN

acl msn1 req_mime_type -i ^application/x-msn-messenger$ //รุ่น 6.3
acl msn2 url_regex -i gateway.dll // รุ่น 7.X +

http_access deny msn1
http_access deny msn2

หรือถ้าต้องการblock เป็นเวลา สามารถกำหนดดังนี้

acl msn1 rep_mime_type -i ^application/x-msn-messenger$
acl msn2 url_regex -i gateway.dll
acl morning time M T W H F 9:00-12:00
acl lunch time M T W H F 13:00-17:00
http_access deny msn1 morning
http_access deny msn1 lunch
http_access deny msn2 morning
http_access deny msn2 lunch

3. Block site (Domain)

acl block_url url_regex ‘etc/squid/blacklists’ //สร้างไฟล์ blacklist.txt

http_access deny block_url

(พิมพ์ชื่อ Domain ที่ต้องการบล๊อคส่ในแฟ้มที่สร้าง)

4. Block Key word

acl keyword url_regex -i messenger hi5 chat

http_access deny keyword

5. Block MP3 Download

acl download urlpath_regex -i \.mp4$ \.wav$ \.iso$

http_access deny download

6. การจำกัด bandwidth Download

acl blockfile url_regex -i ftp .exe .mp3 .vqf .tar.gz .gz .rpm .zip .rar .avi .mpeg .mpe .mpg .qt .ram

.rm .iso

acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl lan src 192.168.1.0/255.255.255.0 #กลุ่ม IP LAN ภายใน
http_access allow lan
http_access deny all

delay_pools 1
delay_class 1 1
delay_parameters 1 2500/2500 # จำกัดไม่เกิน 2.5 kbyte หากต้องการไม่เกิน 5.0 kbyte ก็เปลี่ยนเป็น 5000/5000 ไม่เกิน จะจำกัดเท่าไหร่ก็เปลี่ยนเอาเลยครับ
delay_access 1 allow blockfile

7. การ download จาก ตัวอักษรหรือคำจาก website
acl magic_words url_regx -i .exe
delay_pools 1
delay_class 1 1
delay_parameters 1 4000/4000
delay_access 1 allow magic_words

(magic_world เป็นตัวแปลบออกว่าถ้ามีนามสกุล .exe (ส่วน -i คือ ตัวบอกว่าเป็น case-insensitive) ให้ download มาด้วยความเร็วไม่เกิน 32 Kbit/sec ก็ประมาณ 4 Kbyte/sec )

8. กำหนดให้ขนาด bandwidth ให้กับUser ภายใน network
acl all src 0.0.0.0/0.0.0.0
delay_pool_count 1
delay_class 1 2
delay_parameters 1 12500/12500 2500/2500
delay_access 1 allow all

( อธิบายว่า มี Lease Line ขนาด 128K และต้องการจะเหลือไว้สักนิด สำหรับ SMTP server ซึ่งเป็น IP จริงไม่ได้ต่อผ่านกับ gateway ตัวนี้ และให้ใช้สำหรับ NAT ภายใน องค์กร 100Kbit/sec เพื่อให้ทุกคน share กันใช้เท่าๆกัน และต้องการจะให้แต่ละคนใช้ Bandwidth ได้ไม่เกิน 2.5 Kbyte/sec )

9 กำหนดขนาด bandwidth ให้กับ group network
acl a_ll src 0.0.0.0/0.0.0.0
delay_class 1 3
delay_parameters 1 56000/56000 18750/18750 500/500
delay_access 1 allow all
(อธิบายได้ดังนี้ มี Lease Line ขนาด 512K และต้องการเหลือ Bandwidth สำหรับ SMTP ไว้ 8Kbyte/sec ใช้ภายใน network ไม่เกิน 448 Kbit/sec และแบ่งให้แต่ละ class ไม่เกิน 150 Kbit/sec และให้แต่ละ IP ไม่เกิน 4 Kbit/sec )

10. การจำกัดขนาด bandwidth และไม่จำกัดขนาด bandwidth

acl magic_words1 url_regex -i 202.29.14.1
#กำหนด acl กลุ่มที่มีสิทธิ์ทุกอย่าง acl magic_words2 url_regex -i ftp .exe .mp3 .vqf .tar.gz .gz .rpm .zip .rar .avi .mpeg .mpe .mpg .qt .ram .rm .iso .raw .wav .mov #กำหนด acl กลุ่มที่ต้องควบคุม traffic คือไฟล์บางประเภทที่ใหญ่ ๆ
การกำหนดค่า Squid(Delay Pool)
# สำหรับ delay pool ที่คุณต้องการ –enable-delay-pools
delay_pools 2 #กำหนดให้มี 2 pool ที่ต้องใช้
#สมมุติมี link ขนาด 2Mbits ซึ่ง 2 mbits == 256 kbytes ต่อวินาที เราจะจำกัดให้ใช้ได้ไม่เกิน 5 KB/s ต่อโหนด
delay_class 1 2 #กำหนดให้ pool ที่ 1 เป็น class 2 ที่ถูกกำหนดค่าไว้ใน magic_word2 แบบจำกัด
delay_parameters 1 256000/256000 5000/256000
delay_access 1 allow magic_words2 #กลุ่มที่ดาวน์โหนดไฟล์ต่าง ๆ ที่กำนดไว้
delay_access 1 allow rinet #กลุ่มที่มี ip ต้นทางเป็นเครือข่ายภายใน
# -1/-1 หมายความว่าไม่มีการจำกัดขนาดของ traffic.
delay_class 2 2 #กำหนดให้ pool ที่ 2 เป็น class 2 ที่ถูกกำหนดค่าไว้ใน magic_word1 แบบไม่จำกัด
delay_parameters 2 -1/-1 -1/-1
delay_access 2 allow magic_words1

ตัวอย่าง

acl download url_regex -i ftp .rar .wma .exe .mp3 .vqf .tar.gz .gz .rpm .zip .avi .mpeg .mpe .mpg .qt .ram .rm .iso .raw .wav .mov
delay_pools 2
acl day time 09:00-15:59
acl day2 time 16:00-09:00
delay_class 1 2
delay_parameters 1 10000/20000 10000/20000
delay_access 1 allow download day day2
delay_access 1 deny all

delay_class 2 2
delay_parameters 2 -1/-1 -1/-1
delay_access 2 allow localnet localhost !all
delay_access 2 deny !all

11. การบล็อค Port และ เลข IP

acl porttest port 5050 5222 5223
acl block_port port 5050 5222 5223
acl test src 172.27.162.43
http_access deny block_port test
http_access allow all

acl block_port port 5050 5222 5223
acl test src 172.27.162.43
http_access deny block_port test
http_access allow all

acl blockip src “/etc/squid/block.ip” //สร้างแฟ้ม block.ip ใส่เลข IP เข้าไป

12. Block skype Chat

acl skype_user src “/etc/squid/user-skype” //ใส่เลข ip เครื่องที่อนุญาตให้ใช้ได้
acl numeric_IPs url_regex ^[0-9]+.[0-9]+.[0-9]+.[0-9]+:443
acl Skype_UA browser ^skype^
http_access deny skype_user numeric_IPs
http_reply_access deny skype_user numeric_IPs
http_access deny skype_user Skype_UA

ไม่มีความคิดเห็น:

แสดงความคิดเห็น