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点上网
做了一个Linux学习的平台,目前出来一个个形,各位可以参考使用
链接:
https
://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ密码:n7bk
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29270124/viewspace-2222601/
,如需转载,请注明出处,否则将追究法律责任。