วันพฤหัสบดีที่ 21 กุมภาพันธ์ พ.ศ. 2556

วิธีจำกัดความเร็วเน็ตแต่ละ IP ครับ

# Delay pool_setup additional by Sontaya (512/256 Kbps)
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
acl bcsc_local url_regex -i 192.168
acl bcsc_admin src 192.168.1.8 192.168.1.49 192.168.1.50 192.168.1.99 192.168.1.11 192.168.1.12 192.168.1.42 192.168.1.250 192.168.1.251
acl bcsc_download url_regex -i ftp .3gp .dat .dct .div .divx .dss .exe .gz .img .iso .mp3 .mp4 .mov .mpe .mpga .mpg .mpeg .mds .nrg .ogg .rar .swf .tar .tgz .vob .vox .vqf .wav .wmv .wma .zip .7z


acl bcsc_unlimit_bandwidth time MTWHFAS 09:00-19:00
acl bcsc_upload url_regex -i .com .avi .mpg .iso .wav .wma .dat .cda .wm .mid .midi .mp3
delay_pools 3
delay_class 1 2
delay_parameters 1 -1/-1 -1/-1
delay_access 1 allow bcsc_local
delay_access 1 allow !bcsc_unlimit_bandwidth
delay_access 1 allow bcsc_admin
delay_class 2 2
delay_parameters 2   256000/256000 256000/512000
delay_access 2 allow bcsc_download
delay_class 3 2
delay_parameters 3   20480/20480 20480/40960
delay_access 3 allow bcsc_upload
delay_access 2 deny !bcsc_unlimit_bandwidth
delay_access 2 allow bcsc_admin


# ----------------------------------------------------------------------------

อธิบาย

# กำหนด acl (Access Control List)  type แบบ url_regex
# เพื่อกำหนดการควบคุม โดยใช้การดูจาก URL
#
# acl ที่ 1 เราตั้งชื่อว่า bcsc_local ใช้สำหรับเก็บ URL ที่เราจะไม่จำกัด Bandwidth ในที่นี้คือวงแลนของเรา
#
acl bcsc_local url_regex -i 192.168

# สร้าง acl ที่ 2 ชื่อ bcsc_admin สำหรับบ้างเครื่องที่เราไม่ต้องการจำกัด Bandwidth ทุกเวลา
#
acl bcsc_admin src 192.168.1.49 192.168.1.50 192.168.1.99 192.168.1.100 192.168.1.8 192.168.1.11 192.168.1.12 192.168.1.42 192.168.1.250 192.168.1.251

# ต่อมาสร้าง acl ที่ 3 ชื่อ bcsc_download ไว้เก็บ URL ที่เราต้องการจำกัด Bandwidth
# ไม่ว่าจะเป็น ftp หรือ ไฟล์นามสกุลต่างๆ ที่เรากำหนดขึ้น (พิมพ์ให้อยู่ในบรรทัดเดียวกัน)
#
acl bcsc_download url_regex -i ftp .3gp .dat .dct .div .divx .dss .exe .gz .img .iso .mp3 .mp4 .mov .mpe .mpga .mpg .mpeg .mds .nrg .ogg .rar .swf .tar .tgz .vob .vox .vqf .wav .wmv .wma .zip .7z

# สร้าง acl ที่ 4 ชือ bcsc_unlimit_bandwidth  สำหรับกำหนดช่วงเวลาว่า จะทำการจำกัด Bandwidth ช่วงเวลาใดบ้าง
# กำหนดช่วงเวลาเป็น 9 โมงเช้า ถึง 1 ทุ่ม แล้วนอกนั้นจะโหลดอะไรก็เต็มที่เลย
#
acl bcsc_unlimit_bandwidth time MTWHFAS 09:00-19:00

# สร้าง acl ที่ 5ชื่อ upload เพื่อไว้เก็บ URL หรือไฟล์นามสกุลต่างๆ ที่ต้องการจำกัด Bandwidth
#
acl bcsc_upload url_regex -i .com .avi .mpg .iso .wav .wma .dat .cda .wm .mid .midi .mp3

# สร้าง delay_pool สำหรับกำหนดค่าหน่วงเวลา หรือ delay โดยเราจะกำหนดเอาไว้ 3 pool
# pool ที่ 1 สำหรับ bcsc_local,  pool ที่ 2 สำหรับ bcsc_admin, pool ที่ 3 สำหรับ bcsc_download
#
delay_pools 3

# pool ที่ 1 เรากำหนดให้ใช้ delay_class แบบที่ 2 (สังเกตุจะมีเลข -1/-1 อยู่ 2 ชุด)
# ชุดแรก หมายถึง Bandwidth รวมทั้งวงเน็ตเวิร์ค ที่เราอนุญาตให้โหลด
# ชุดสอง หมายถึง Bandwidth ของแต่ละเครื่อง ที่เราอนุญาตให้โหลด
#
delay_class 1 2

# -1/-1 หมายถึง ไม่จำกัด Bandwidth (เพราะว่า pool นี้ เรากำหนดให้ bcsc_local)
#
delay_parameters 1 -1/-1 -1/-1

# อนุญาต acl
delay_access 1 allow bcsc_local
delay_access 1 allow !bcsc_unlimit_bandwidth
delay_access 1 allow bcsc_admin



# pool ที่ 2 ก็กำหนดให้ใช้ delay_class แบบที่ 2 เช่นกัน
#
delay_class 2 2

# โดยค่าที่เรากำหนดนี้ จะคิดเป็น bytes
# ยกตัวอย่าง เลขชุดแรก 256000/ 512000
# หลังจากที่ดาวน์โหลดไปแล้ว ถ้าขนาดไฟล์ที่โหลดมีขนาดเกิน 512000 ไบท์ (หรือว่ามีขนาดมากกว่านั้น 2 ถึง 3 เท่า) ก็จะดาวน์โหลดต่อที่ 256000 ไบท์ต่อวินาที

# วิธีคิดดังนี้ (บริษัทใช้อินเตอร์เน็ต 512/256 Kbps จะแบ่งให้โหลด 256 Kbps ที่เหลืออีก 256 Kbps สำหรับเล่นเว็บ ส่งเมล์ เป็นต้น)
# เว็บสำหรับการคำนวณ http://www.t1shopper.com/tools/calculate/
# Download = 512 Kbps = 64 KB/sec วินาที (512/8)
# 1 KB = 1024 bytes
# 512 KB = ?
# การคำนวณหา bytes
# 512*1024/8 =  65536 bytes
# 65536 bytes / 1024 = 64 KB/sec

# ส่วน Bandwidth ต้องการให้ใช้ downloadแค่ 25 KB/sec ต่อเครื่อง
# 25 KB x 1024 = 256000 bytes  คือค่าที่ต้องใช้
#
delay_parameters 2 256000/256000 256000/512000

# กำหนด allow ให้ bcsc_upload ให้มีการ delay หรือจำกัด Bandwidth
#
delay_access 2 allow bcsc_download

# pool ที่ 3 ก็กำหนดให้ใช้ delay_class แบบที่ 2 เช่นกัน
# การคำนวณหา bytes
# Upload = 256 kbps
# 256*1024/8 = 32768 bytes
# 32768/1024 = 32 Kbps
# Bandwidth รวมทั้งให้อัพโหลดรวมได้เต็มที่ 256 Kbps ความเร็วสูงสุด (ทั้งวงแลน) ก็จะได้ประมาณ 32.0 KB/sec (วินาที)
# ส่วน Bandwidth แต่ละเครื่อง ให้ใช้ upload แค่ 20 KB/sec ต่อเครื่อง
# 20 KB x 1024 = 20480 bytes  คือค่าที่ต้องใช้


delay_class 3 2
delay_parameters 3 20480/20480 20480/40960
delay_access 3 allow bcsc_upload



# กำหนด deny ให้ช่วงที่ไม่ใช่ unlimit_bandwidth  มี Bandwidth เท่าไหร่ ก็อนุญาตให้ใช้เท่านั้น
#
delay_access 2 deny !unlimit_bandwidth
delay_access 2 allow bcsc_admin



***
 นี้เป็นเพียงแนวทางตัวอย่าง คุณสามารถปรับเปลื่ยนให้เข้ากับองค์กรของคุณได้
 
refer : http://www.susethailand.com/suseforum/index.php?topic=390.0









# Delay pool_setup additional by Sontaya (512/256 Kbps)

# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
acl bcsc_local url_regex -i 192.168
acl bcsc_admin src 99.99.99.2 สำหรับตัวที่ไม่ต้องการให้จำกัดแบนวิดมีหลายเครื่องก็ เช่น 192.168.1.2 192.168.1.3 192.168.1.4 เว้นวัค 1 นะครับ
acl bcsc_download url_regex -i ftp .3gp .dat .dct .div .divx .dss .exe .gz .img .iso .mp3 .mp4 .mov .mpe .mpga .mpg .mpeg .mds .nrg .ogg .rar .swf .tar .tgz .vob .vox .vqf .wav .wmv .wma .zip .7z .flv


acl bcsc_unlimit_bandwidth time MTWHFAS 16:01-23:59 ตั้งเวลาได้ตามต้องการ ที่จะจำกัดแบนวิส ยกตัวอย่าง ในนี้ จำกัดตั้งแต่ 16.01-23.59 นาที ถ้าต้องการจำกัดหมดก็ใส่ 00.01-23.59 ครั
acl bcsc_upload url_regex -i .com .avi .mpg .iso .wav .wma .dat .cda .wm .mid .midi .mp3
delay_pools 3
delay_class 1 2
delay_parameters 1 -1/-1 -1/-1
delay_access 1 allow bcsc_local
delay_access 1 allow !bcsc_unlimit_bandwidth
delay_access 1 allow bcsc_admin
delay_class 2 2
delay_parameters 2   912000/650000 200000/200000 คู่หน้า คือเน็ตในร้านของท่าน คู่หลัง คือขนาดแบนวิสที่ต้องการจำกัดครับ เช่นผมตั้งไว่ที่ 200000 คือ 200 k เป็นสปีดก็ 2 เม็กประมาณนี้นะครับ ใช้โปรแกรมอะไรโหลดก็ไม่เกินครับ
delay_access 2 allow bcsc_download
delay_class 3 2
delay_parameters 3   912000/650000 200000/200000 ชุดนี้เหมือนกะชุดบนครับ
delay_access 3 allow bcsc_upload
delay_access 2 deny !bcsc_unlimit_bandwidth
delay_access 2 allow bcsc_admin

# ----------------------------------------------------------------------------
ใส่ไปแล้ว รี service squid 2-3 ครั้ง
#service squid restart

เคดิช https://www.easyzonecorp.net/network/view.php?ID=1306

ถ้ามีเน้ต 2 เส้นแล้วถ้าใช้ fw ตามที่ท่า นๆ แจกกันมันไม่บีบครับผมอัฟมันก็วิ่ง เต้มเส้นดีครับอัฟแพทเกมส์นะ แต่เส้นเดียวเขาก้ทำใบพาดไว้อยุ่นะครับส่วนมากจะไม่บี

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

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