Squid 定时规则的使用实例
扫描二维码
随时随地手机看文章
上班時間為09:00~18:00,午休時間12:00~13:00開放自由上網
1.在squid.conf裡加入幾條規則
vim /etc/squid/squid.conf
◎設定休息時間
acl RestTime time 12:00-13:00
◎設定上班時間
acl WorkTime time MTWHF 9:00-18:00
◎設定禁止連線的網域(參考用)
acl Deny_Domain dstdomain .1001ya.com.tw .17funtv.com .51mole.com.tw .6-10.com.tw .6npc.com .6waves.com .941wan.com.tw .Plurk.com .aido.com.tw .battleknight.tw .bitefight.tw .buboo.tw .chinesegamer.net .cmwebgame.com .e72play.com .elex-tech.us .facebook.com .gamelet.com .gamez.com.tw .gindis.com .gladiatus.tw .godgame.com.tw .goldsky.com.tw .hugashaga.com.tw .ikariam.tw .joyct.com .katsuro.tw .kingsage.tw .meropar.tw .miniworld.com.tw .myspace.com .nindou.com.tw .ogame.tw .oldtu.com .playfish.com .po.msn.com.tw .roida.no-ip.org .serverhk.net .shuaing.com .tanoth.tw .timeheros.com .travian.tw .truehero.com.tw .twitter.com .wayi.com.tw .web3go.com.tw .webgame.pchome.com.tw .wlb.com.tw .wowuc.cn .ya7.com.tw .zynga.com
◎設定禁止連線的IP(參考用)
acl Deny_IP dst 114.80.75.220/32 122.116.31.92/32 122.146.203.228/32 123.110.200.35/32 123.55.248.26/32 125.67.235.199/32 168.143.162.64/26 174.120.26.218/32 174.37.227.82/32 199.71.212.91/32 202.153.175.126/32 203.73.22.132/32 204.74.66.132/32 204.74.67.132/32 207.46.61.31/32 210.17.20.96/27 210.242.32.192/26 210.242.34.22/32 210.59.145.150/32 210.59.230.184/32 211.72.255.76/32 211.76.177.154/32 216.178.38.116/32 216.86.150.58/32 216.97.228.247/32 217.160.6.64/32 219.84.193.1/32 219.90.126.148/32 220.130.112.187/32 220.228.196.240/29 24.143.195.43/32 59.120.84.206/32 60.199.197.177/32 61.188.178.51/32 61.31.192.1/32 61.31.192.56/29 61.31.192.80/30 61.31.224.110/32 61.61.132.34/32 61.63.43.97/32 61.63.52.81/32 61.67.128.128/30 61.67.168.150/32 61.67.212.224/27 66.151.151.149/32 69.63.176.101/32 69.63.176.8/30 69.63.181.8/29 69.63.184.142/32 69.63.185.11/32 69.63.186.0/26 69.63.187.0/27 69.63.191.219/32 69.63.191.91/32 69.65.42.218/32 72.249.23.165/32 72.44.35.31/32 74.208.147.52/32 74.208.155.165/32 74.208.167.108/32 74.208.44.207/32 74.208.79.164/32 74.208.98.38/32 87.106.71.99/32
◎先設定午休時間允許的規則
http_access allow Deny_Domain RestTime
http_access allow Deny_IP RestTime
◎再設定上班時間拒絕的規則
http_access deny Deny_Domain WorkTime
http_access deny Deny_IP WorkTime
※squid的規則是越前面的規則優先順序越高。
※http_access allow 跟 deny後規則的邏輯是AND,兩個條件皆成立時才會作用。
2.套用規則
/usr/sbin/squid -k reconfigure