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之后,使用这个代理的浏览器将不能访问任何网页

     

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”的电脑如果用了这个代理,那么它将不能访问网站

     

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之后,使用这个代理的浏览器将不能访问百度

     

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

     

  

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点上网 

     

猜你喜欢

转载自www.cnblogs.com/wj78080458/p/10060842.html