Linux服務器---squid限制

Squid連接限制

Squid可以有效的限制連接,指定哪些用戶可以連接,指定哪些網站可以訪問,這樣就可以有效的利用服務器帶寬。

1、限制指定網段不能連接。編輯配置文件”/etc/squid/squid.conf”,利用acl語言添加受限制的ip地址 

[root@localhost wj]# gedit /etc/squid/squid.conf

acl clientdeny src 192.168.0.1-192.168.0.200

http_access deny clientdeny 

 

[root@localhost wj]# service squid restart

停止squid................                               [確定]

正在啓動squid.                                          [確定]

重啓squid之後,使用這個代理的瀏覽器將不能訪問任何網頁

1.png

 

2、限制某個ip不能使用呢,和上面的一樣使用acl語法  

[root@localhost wj]# gedit /etc/squid/squid.conf

acl clientdeny src 192.168.0.113

http_access deny clientdeny

 

[root@localhost wj]# service squid restart

停止squid................                               [確定]

正在啓動squid.                                          [確定]

重啓squid之後,IP地址爲“192.168.0.113”的電腦如果用了這個代理,那麼它將不能訪問網站

1.png

 

3、限制某些網站不能訪問

[root@localhost wj]# gedit /etc/squid/squid.conf

acl domaindeny dstdomain .baidu.com

http_access deny domaindeny

 

[root@localhost wj]# service squid restart

停止 squid................                               [確定]

正在啓動squid.                                          [確定]

重啓squid之後,使用這個代理的瀏覽器將不能訪問百度

1.png

 

4、網站黑名單,可以通過一個網站列表文件形成網站黑名單,這些網站將不能被訪問。

1)在/etc/squid目錄下創建愛你一個文件denyurl,在此文件內輸入要攔截的網站

[root@localhost wj]# gedit /etc/squid/denyurl

.baidu.com

.hao123.com

 

[root@localhost wj]# service squid restart

停止squid................                               [確定]

正在啓動squid.                                          [確定]

2)修改配置文件“/etc/squid/squid.conf”

[root@localhost wj]# gedit /etc/squid/squid.conf

acl denyurl url_regex "/etc/squid/denyurl"     //注意這個路徑就是上面定義的文件路徑

http_access deny denyurl

 

[root@localhost wj]# service squid restart

停止squid................                               [確定]

正在啓動 squid.                                          [確定]

3)訪問百度和hao123

1.png

 

5、限制某個時間段內不能連接  

[root@localhost wj]# gedit /etc/squid/squid.conf

acl timedeny time M 10:00-17:00    //M週一  T週二   W週三   H週四   F週五   A週六    S週日

http_access deny clientdeny

 

[root@localhost wj]# service squid restart

停止squid................                               [確定]

正在啓動squid.                                          [確定]

重啓squid之後,使用這個電腦的代理將無法再星期一的10~17點上網 

      1.png

 

 



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章