zzl001 发表于 2018-12-27 06:35:09

253_squid安装

  简单的安装为了实验而实验:
  # ifconfig eth0
eth0      Link encap:EthernetHWaddr 00:0C:29:BA:70:10
          inet addr:192.168.1.105Bcast:192.168.1.255Mask:255.255.255.0

  # setenforce 1
# getenforce
Enforcing
  # service iptables restart

# iptables -F

# service iptables save

# rpm -qa |grep squid

# yum install squid*

# rpm -qa |grep squid
squid-2.6.STABLE21-3.el5

# service squid restart
停止 squid:                                             [失败]
init_cache_dir /var/spool/squid... 启动 squid:.         [确定]

在做squid的时候要注意主机名的问题,要用完整的域名来做,不然服务启动不了;

# chkconfig --list squid
squid         0:关闭1:关闭2:关闭3:关闭4:关闭5:关闭6:关闭
# chkconfig squid on
# chkconfig --list squid
squid         0:关闭1:关闭2:启用3:启用4:启用5:启用6:关闭
#
  squid 配置文件在/etc/squid/下面,默认是拒绝所有的;
  1、宿主机是192.168.1.6,我们把1.6这个IP地址加到配置文件中测试宿主机能否访问;
  在没加之前都是可以访问的,1.6的IE中设置IE的代理
http://blog.运维网.com/attachment/201010/183802487.jpg
  在访问就无法访问了,有错误提示
http://blog.运维网.com/attachment/201010/183657667.jpg
  要让1.6主机访问。那么我们就在squid.conf中配置acl与访问策略http_access
  578   acl    xp01      src         192.168.1.6
  xp01 定义主机名称   src是来源,因为1.6这个主机要通过squid服务器访问公网;IP 是主机的IP;在定义acl时没有什么顺序 ,但是最好都是写在一起 好区分,
----------------------------------------------------------
  637    http_access   allow      xp01
在定义访问策略时就有顺序区分了 一定要写在第 639 http_access deny all前面 不然就会被禁掉的,
  保存 ,重启squid
  # service squid restart
停止 squid:                                             [确定]
启动 squid:.                                              [确定]

  宿主机在通过IE访问就可以了
  2、禁止用户访问域名为www.163.com与www.sohu.com的网站。
  还是先定义acl 访问
  acl sohuweb dstdomain-iwww.sohu.com
   acl 163web dstdomain    -i    www.163.com
然后在定义http_access
  640 http_access deny    163web
    641 http_access deny   sohuweb
    642 http_access allow   xp01

  在IE中访问:
http://blog.运维网.com/attachment/201010/191658898.jpg
http://blog.运维网.com/attachment/201010/191709852.jpg
http://blog.运维网.com/attachment/201010/191728929.jpg
  我们可以看到 www.sohu.com www.163.com 都不能访问了 ,而mail.163.com 确能访问;
  3、我们在做一条访问策略:禁止用户访问域名包含有163.com的网站。
  acl badurl1 url_regex -i 163.com
http_access deny badurl1
http://blog.运维网.com/attachment/201010/192427887.jpg
  现在mail.163也不能访问了
  url_regex表示的是URL规则表达式匹配



页: [1]
查看完整版本: 253_squid安装