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

Smile Authen 192.168.0.1

ผมพึ่งลง ClearOS + Smile Authen ครั้งแรกครับ 

ตอนแรกที่ลง Chilli แจก IP 10.0.1.xx ผมต้องการให้ Chilli แจก IP 192.168.0.xx 
จึงเข้าไปแก้ไฟล์ /etc/chilli/config เป็นตามนี้ครับ

# -*- /bin/sh -*-
#
# Coova-Chilli Default Configurations. 
# To customize, copy this file to /etc/chilli/config
# and edit to your liking. This is included in shell scripts
# that configure chilli and related programs before file 'config'. 


###
# Local Network Configurations


HS_WANIF=eth0 # WAN Interface toward the Internet
HS_LANIF=eth1 # Subscriber Interface for client devices
HS_NETWORK=192.168.0.0 # HotSpot Network (must include HS_UAMLISTEN)
HS_NETMASK=255.255.255.0 # HotSpot Network Netmask
HS_UAMLISTEN=192.168.0.1 # HotSpot IP Address (on subscriber network)
HS_UAMPORT=3990 # HotSpot Port (on subscriber network)

# HS_DYNIP=
# HS_DYNIP_MASK=255.255.255.0
# HS_STATIP=
# HS_STATIP_MASK=255.255.255.0
# HS_DNS_DOMAIN=
HS_DNS1=61.19.22.155
# HS_DNS2=

###
# HotSpot settings for simple Captive Portal
#
HS_NASID=nas01
HS_UAMSECRET=ht2eb8ej6s4et3rg1ulp
HS_RADIUS=127.0.0.1
HS_RADIUS2=127.0.0.1
HS_RADSECRET=testing123
HS_UAMALLOW=192.168.0.0/24

# Put entire domains in the walled-garden with DNS inspection
# HS_UAMDOMAINS=".paypal.com,.paypalobjects.com"

# Optional initial redirect and RADIUS settings
# HS_SSID=<ssid> # To send to the captive portal
# HS_NASMAC=<mac address> # To explicitly set Called-Station-Id
# HS_NASIP=<ip address> # To explicitly set NAS-IP-Address

# The server to be used in combination with HS_UAMFORMAT to 
# create the final chilli &#39;uamserver&#39; url configuration.
HS_UAMSERVER=192.168.0.1

# Use HS_UAMFORMAT to define the actual captive portal url.
# Shell variable replacement takes place when evaluated, so here
# HS_UAMSERVER is escaped and later replaced by the pre-defined 
# HS_UAMSERVER to form the actual "--uamserver" option in chilli.
HS_UAMFORMAT=http://\$HS_UAMSERVER/sam/hotspotlogin.php

# Same principal goes for HS_UAMHOMEPAGE.
HS_UAMHOMEPAGE=http://\$HS_UAMLISTEN:\$HS_UAMPORT/prelogin

# This option will be configured to be the WISPr LoginURL as well
# as provide "uamService" to the ChilliController. The UAM Service is
# described in: http://coova.org/wiki/index.php/CoovaChilli/UAMService
#
HS_UAMSERVICE=http://\$HS_UAMSERVER/sam/hotspotlogin.php


###
# Features not activated per-default (default to off)
#
# HS_RADCONF=off # Get some configurations from RADIUS or a URL (&#39;on&#39; and &#39;url&#39; respectively)
#
HS_ANYIP=on # Allow any IP address on subscriber LAN
#
# HS_MACAUTH=on # To turn on MAC Authentication
#
# HS_MACAUTHDENY=on # Put client in &#39;drop&#39; state on MAC Auth Access-Reject
#
# HS_MACAUTHMODE=local # To allow MAC Authentication based on macallowed, not RADIUS
#
# HS_MACALLOW="..." # List of MAC addresses to authenticate (comma seperated)
#
# HS_USELOCALUSERS=on # To use the /etc/chilli/localusers file
#
# HS_OPENIDAUTH=on # To inform the RADIUS server to allow OpenID Auth
#
# HS_WPAGUESTS=on # To inform the RADIUS server to allow WPA Guests
#
# HS_DNSPARANOIA=on # To drop DNS packets containing something other
# # than A, CNAME, SOA, or MX records
#
# HS_OPENIDAUTH=on # To inform the RADIUS server to allow OpenID Auth
# # Will also configure the embedded login forms for OpenID
#
# HS_USE_MAP=on # Short hand for allowing the required google
# # sites to use Google maps (adds many google sites!)
#
###
# Other feature settings and their defaults
#
# HS_DEFSESSIONTIMEOUT=0 # Default session-timeout if not defined by RADIUS (0 for unlimited)
#
# HS_DEFIDLETIMEOUT=0 # Default idle-timeout if not defined by RADIUS (0 for unlimited)
#
# HS_DEFBANDWIDTHMAXDOWN=0 # Default WISPr-Bandwidth-Max-Down if not defined by RADIUS (0 for unlimited)
#
# HS_DEFBANDWIDTHMAXUP=0 # Default WISPr-Bandwidth-Max-Up if not defined by RADIUS (0 for unlimited)

###
# Centralized configuration options examples

# HS_RADCONF=url # requires curl
# HS_RADCONF_URL=https://coova.org/app/ap/config

# HS_RADCONF=on # gather the ChilliSpot-Config attributes in
# # Administrative-User login
# HS_RADCONF_SERVER=rad01.coova.org # RADIUS Server
# HS_RADCONF_SECRET=coova-anonymous # RADIUS Shared Secret 
# HS_RADCONF_AUTHPORT=1812 # Auth port
# HS_RADCONF_USER=chillispot # Username
# HS_RADCONF_PWD=chillispot # Password


###
# Standard configurations
#
HS_MODE=hotspot
HS_TYPE=chillispot
# HS_RADAUTH=1812
# HS_RADACCT=1813
# HS_ADMUSR=chillispot
# HS_ADMPWD=chillispot


###
# Post-Auth proxy settings
#
# HS_POSTAUTH_PROXY=<host or ip>
# HS_POSTAUTH_PROXYPORT=<port>

# Directory specifying where internal web pages can be served
# by chilli with url /www/<file name>. Only extentions like .html
# .jpg, .gif, .png, .js are allowed. See below for using .chi as a
# CGI extension.
HS_WWWDIR=/etc/chilli/www

# Using this option assumes &#39;haserl&#39; is installed per-default
# but, and CGI type program can ran from wwwsh to process requests
# to chilli with url /www/filename.chi
HS_WWWBIN=/etc/chilli/wwwsh

# Some configurations used in certain user interfaces
#
HS_PROVIDER=Coova
HS_PROVIDER_LINK=http://www.coova.org/


###
# WISPr RADIUS Attribute support
#

HS_LOC_NAME="My HotSpot" # WISPr Location Name and used in portal

# WISPr settings (to form a proper WISPr-Location-Id)
# HS_LOC_NETWORK="My Network" # Network name
# HS_LOC_AC=408 # Phone area code
# HS_LOC_CC=1 # Phone country code
# HS_LOC_ISOCC=US # ISO Country code

HS_DYNIP=192.168.0.0
HS_DYNIP_MASK=255.255.255.0
HS_STATIP=192.168.0.0
HS_STATIP_MASK=255.255.255.0


พอ Restart เครื่อง ปรากฏว่าเครื่อง Client ได้รับ IP จาก Chilli ตามที่ต้องการ แต่ไม่สามารถออกเน็ตได้
Ping 192.168.0.1 ไม่เจอครับ

ปัญหานี้ควรแก้ยังไงดีครับ

=================================================================
2. ผมมีการ์ดแลนอีก 1 ตัว ต้องการแยกวงของเครื่อง Client ออกจากกัน ต้อง Config ยังไงบ้างครับ
เท่าที่ลอง Search ดู ต้องสร้าง ไฟล์ config ของ chilli ขึ้นมาใหม่อีกตัว แล้วสั่งรัน service เพิ่ม
ซึ่งลองแล้วมันไม่ทำงานครับ ;D

ถ้าท่านใดพอมีวิธีหรือเจอกระทู้เก่า ๆ เกี่ยวกับเรื่องนี้ช่วยแนะนำด้วยครับ (Search แล้วหาไม่เจอจริง ๆ ครับ)

//////////////////////////////////////////////////////////////////////
ลองดู rc.firewall.local อีกที่นึงครับ

My_Local_Net=
/////////////////////////////////////////////////////////
ปกติถ้าแก้ไฟล์ config ก่อน install ก็ไม่น่ามีปัญหานะครับ เพราะผมก็เจอปัญหาเหมือนคุณ ผมก็เลยลองลงใหม่ โดยก่อนลงผมได้แก้ config ที่อยู่ใน Folder SmileAuthenServer_V1.0b


แก้ไฟล์ config ดังนี้
mynet = '10.0.1.0\/24' วงแลนที่ท่านใช้อยู่ หรือที่ต้องการ พูดง่าย ๆ กลุ่ม ip ของเครื่อง Client นั่นเอง
myHS_NETWORK='10.0.1.100' เราต้องการให้ chill จ่าย ip ให้กับเครื่อง client ตั้งแต่ไอพีเบอร์อะไรก็ใส่ตรงนี้ครับ
myHS_NETMASK='255.255.255.0' วงของไอพีที่ต้องการ
myuamlisten = '10.0.1.1' ไอพีขา lan (eth1)


จากนั้นก็ทำการลงเลยครับ
โดยมีขั้นตอนดังนี้คือ
./config
./install
ถ้าลงไปแล้วอยากจะแก้ก็ไปแก้ได้ที่นี่ครับ /etc/chilli/hs.conf

ปล.ถ้าคุณใช้ IE ในการ access จะไม่สามารถเข้าได้นะ (สำหรับผมไม่ได้ ไม่ทราบว่าท่านอื่นได้ไหม) ผมใช้ Firefox ok ครับ ลองดูนะครับ อธิบายผิดพลาดตรงไหนชี้แนะด้วยนะครับ มือใหม่ครับ แต่ปัญหานี้พึ่งจะแก้ได้

วันพฤหัสบดีที่ 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 ตามที่ท่า นๆ แจกกันมันไม่บีบครับผมอัฟมันก็วิ่ง เต้มเส้นดีครับอัฟแพทเกมส์นะ แต่เส้นเดียวเขาก้ทำใบพาดไว้อยุ่นะครับส่วนมากจะไม่บี

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

# 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 ตามที่ท่า นๆ แจกกันมันไม่บีบครับผมอัฟมันก็วิ่ง เต้มเส้นดีครับอัฟแพทเกมส์นะ แต่เส้นเดียวเขาก้ทำใบพาดไว้อยุ่นะครับส่วนมากจะไม่บี

การกำหนดความเร็วใน Squid หรือการกำหนดความเร็วดาวน์โหลด

Credit: คุณ Free play
จาก link นี้ครับ http://www.thaiadmin.org/board/index.php?topic=75489.0 เจอในเว็บเราเอง
หลักการง่ายๆครับ คือ จำกัด bandwidth ของการใช้งานอินเตอร์เน็ต

แบบแรก​ : ​กำ​หนดการ​ 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

แบบสอง​ : ​กำ​หนด​ให้​ขนาด​ bandwidth ​ให้​กับ​คนที่​ใช้​ภาย​ใน​ network

   acl a_ll 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 a_ll

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

แบบสาม​ : ​กำ​หนดขนาด​ 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 (หน่วย​ไม่​ผิดนะครับ​ ​ถ้า​เป็น​ Kbyte ​เอา​ 8 ​หาร​จะ​เป็น​ Kbit ​ครับ)








อันนี้ตัวอย่างที่สอง Credit: web linuxthai จาก link นี้ http://www.linuxthai.org/forum/index.php?topic=971.0

#delay-pools

acl my_local url_regex -i jamnet 192.168.100.200
acl my_unlimit time SMTWHFA 11:00-18:00
acl my_download url_regex "/etc/squid/delaylists.txt"


delay_pools 2

delay_class 1 2
delay_parameters 1 -1/-1 -1/-1
delay_access 1 allow my_local
delay_access 1 allow !my_unlimit
delay_access 1 deny my_unlimit

delay_class 2 2
delay_parameters 2 256000/256000 45000/45000
delay_access 2 allow my_download

# end Delay-pools

จากนั้นไปสร้างไฟล์ ชื่อ delaylists.txt  ไว้ที่ /etc/squid/
ในไฟล์ delaylists.txt ก็ใส่ .mp3 .zip .exe เมื่อมีการโหลดไฟล์นามสกุลพวกนี้ มันก็จะวิ่งแค่ ไม่เกิน 45k ในเวลา
11-18  นาฬิกา นอกจากนั้นก็วิ่งเต็มสปีดคับ


acl my_local url_regex -i jamnet 192.168.100.200
อันนี้เป็นการกำหนดให้เวบที่มีบางส่วนเช่น http://...jamnet.../  กับ http://192.168.100.200/  เป็นกลุ่มใช้ในการกำหนดกลุ่มเข้าถึงชื่อ  my_local  ใส่ชื่ออย่างนี้น่าจะแสดงว่า เป็นเวบเซิรฟเวอร์ในเครือข่ายตัวเอง และ
delay_access 1 allow my_local 
ดูจากกฏการอนุญาตแล้ว เป็นการอนุญาตให้เข้าถึงเวบที่กล่าวถึงนี่แบบไม่ต้องจำกัดความเร็ว  สองบรรทัดนี่ไม่ต้องใส่ก็ได้


delay_access 1 allow !my_unlimit
# อันนี้คื่อการอนุญาตให้ใช้การจำกัดเความเร็วแบบที่ 1 (ในที่นี้คือไม่จำกัดความเร็ว) ในช่วงเวลาที่นอกเหนือจากเวลาของ my_unlimit (การกำหนดชื่อกับการรนำมาใช้งานขัดกันนิดหน่อย)


delay_access 1 deny my_unlimit
# อันนี้คือไม่อนุญาตให้ใช้การจำกัดความเร็วแบบที่ 1 นี้ในช่วงเวลาที่กำหนดของ my_unlimit   จะไม่ใส่ก็ได้เพราะมีข้างบนแล้ว แต่ปกติจะใส่ delay_access 1 deny all ปิดท้ายแทนเพื่อให้เข้าใจง่าย

ตรง
acl my_download url_regex "/etc/squid/delaylists.txt" ถ้ามีน้อยๆ ใส่แบบนี้ก็ได้
acl my_download url_regex .mp3 .mp4 .zip .exe .wmv .wma .avi .3gp .rar

delay_pools 2   # อันนี้หมายถึงให้มีการจำกัดความเร็ว 2 แบบ

delay_class 1 2   #อันนี้กำหนดว่าแบบที่ 1 เป็นชนิดคลาส 2  ก็คือ
          # คลาส 1  กำหนดด้วยพารามิเตอร์เดียว คือ ความเร็วรวม
          # คลาส 2 กำหนดด้วยพารามิเตอร์สองตัวคือ ความเร็วรวม กับกำหนดความเร็วให้เน็ตเวิร์คบิท 25-32(ip/25-ip/32)ก็คือแต่ละเครื่อง
       #คลาส 3 มี3ตัวคือ  ความเร็วรวม ความเร็วกลุ่ม ip/17-ip/24(ก็คือแต่ละเครือข่าย) กับความเร็วกลุ่ม ip/25-ip/32 ก็คือแต่ละเครื่อง

delay_parameters 1 -1/-1 -1/-1 
# อันนี้คือกำหนดค่า(พารามิเตอร์)ให้แบบที่ 1 นี้ คือ ความเร็วรวมไม่จำกัด กับแต่ละเครื่องไม่จำกัด  (-1/-1 หมายถึงไม่จำกัด)


delay_parameters 2 256000/256000 45000/45000
#อันนี้คือกำหนดค่าให้แบบที่ 2 นี้คือ ความเร็วรวม   256kB/s (ถ้าใส่ -1/-1 ก็จะไม่จำกัด)  กับความเร็วแต่เล่ะเครื่อง 45kB/s

delay_access 2 allow my_download
# อันนี้คืออนุญาตให้กลุ่มชื่อ my_download ใช้การจำกัดความเร็วแบบที่ 2  ซึ่งก็คือ url ไหนที่มีคำที่ระบุนั่น จะถูกจำกัดความเร็วแบบที่2 นี้

หมาย เหตุ 1 การตรวจสอบว่า  การเรียก(request) url ใดแล้วมีค่าหรือเงื่อนไข(เวลาหรือชนิดไฟล์)ตรงกับ delay_access แบบแรกที่ตรงนั่น(เรียงจากบนลงล่างและตามแบบที่ 1 ไป 2 ไป ..) ก็จะใช้ค่าความเร็วที่กำหนดตามแบบนั้นๆ แต่ถ้าหากไม่ตรงกับ delay_access ใดเลย ก็จะไม่ใช้ค่าตามแบบใดเลยก็คือไม่ถูกจำกัดความเร็วนั่นเอง

          2 ออฟชั่น delay pool นี่จะใช้ได้ต่อเมื่อ squid ได้คอมไพล์โดยใช้ออฟชั่น --enable-delay-pools ด้วย ถ้าหากนำมาคอมไพล์เองกรุณาตรวจสอบก่อนด้วยครับ  (ถ้าหากไม่ได้ใส่ เวลาใช้คำสั่งเกี่ยวกับ delaypool สควิดจะ error และบอกไม่รู้จักคำสั่งพวกนี้)


ส่วนอันที่สามนี้เป็น Blog อธิบายรวมๆ ลองเอาไปอ่านดู http://kom.homelinux.org/node/221เผื่อจะมีคนเก่งเกิดขึ้นเยอะๆ
######################################################################################

Credit: Nytan Web: http://www.muanglung108.com/main/viewthread.php?tid=53


บริหาร Bandwidht ด้วย Squid Delay pool
พอดีไปเจอมาเลยเอามาฝาก อธิบายได้ละเอียดมาก   ~052 ขอบคุณที่มา 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 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 .aac .ac3 .act .aif .aiff .amr .asf .au .avi .b5t .bin .bwt .cab .ccd .cdi .cue .dat .dct .div .divx .dss .exe .flac .fli .flv .gho .gsm .gz .ifo .img .iso .m4a .mp2 .mp3 .mp4 .mov .mpe .mpga .mpg .mpeg .mds .nrg .ogg .pdi .qt .ra .ram .rar .raw .rcd .rec .rm .rmvb .rmj .rpm .sea .shn .sri .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 .aac .ac3 .act .aif .aiff .amr .asf .au .avi .b5t .bin .bwt .cab .ccd .cdi .cue .dat .dct .div .divx .dss .exe .flac .fli .flv .gho .gsm .gz .ifo .img .iso .m4a .mp2 .mp3 .mp4 .mov .mpe .mpga .mpg .mpeg .mds .nrg .ogg .pdi .qt .ra .ram .rar .raw .rcd .rec .rm .rmvb .rmj .rpm .sea .shn .sri .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

    Thank http://www.susethailand.com/suseforum/index.php?topic=390.0