FreeBSD拨号网关的建立下


    以下原因之一:

  磁盘上没有空间了。

  (对此我无能为力)

  没有建立/usr/local/squid/logs/目录。

  (手工建一个嘛)

  您的/usr/local/squid/logs/cache.log文件属于root。

  (可以用这条命令“chown nobody.nogroup /usr/local/squid/logs/cache.log”改一下,另外../log和../cache目录里的所有文件都要有此属性。)

  于是我查了一下这些目录中的文件,的确都属于root,所以我用了这两条命令:

  # chown nobody.nogroup /usr/local/squid/logs

  # chown nobody.nogroup /usr/local/squid/cache

  然后再试一下建立Cache目录:

  # /usr/local/sbin/squid -z

  2001/01/01 09:14:32| Creating Swap Directories

  这次运行顺利!

  测试

  在IE的选项->连接选项卡中设好代理服务器的地址和端口(3128),接着用squid的调试/测试模式进行试运行:

  # /usr/local/sbin/squid -NCd1

  09:30:54| Starting Squid Cache version 2.1 for i386--freebsd3.2...

  09:30:54| Process ID 1026

  09:30:54| With 1064 file descriptors available

  09:30:54| Performing DNS Tests...

  09:30:54| Successful DNS name lookup tests...

  09:30:54| helperOpenServers: Starting 5 'dnsserver' processes

  09:30:54| Unlinkd pipe opened on FD 13

  09:30:54| Swap maxSize 102400 KB, estimated 7876 objects

  09:30:54| Target number of buckets: 157

  09:30:54| Using 8192 Store buckets, replacement runs every 10 seconds

  09:30:54| Max Mem size: 8192 KB
09:30:54| Max Swap size: 102400 KB

  09:30:54| Rebuilding storage in Cache Dir #0 (DIRTY)

  09:30:54| Loaded Icons.

  09:30:54| Accepting HTTP connections on port 3128, FD 35.

  09:30:54| Accepting ICP messages on port 3130, FD 36.

  09:30:54| Ready to serve requests.

  09:30:54| storeRebuildFromDirectory: DIR #0 done!

  09:32:10| Finished rebuilding storage disk.

  09:32:10| 0 Entries read from previous logfile.

  09:32:10| 0 Entries scanned from swap files.

  09:32:10| 0 Invalid entries.

  09:32:10| 0 With invalid flags.

  09:32:10| 0 Objects loaded.

  09:32:10| 0 Objects expired.

  09:32:10| 0 Objects cancelled.

  09:32:10| 0 Duplicate URLs purged.

  09:32:10| 0 Swapfile clashes avoided.

  09:32:10| Took 76 seconds ( 0.0 objects/sec).

  09:32:10| Beginning Validation Procedure

  09:32:10| storeLateRelease: released 0 objects

  09:32:11| Completed Validation Procedure

  09:32:11| Validated 0 Entries

  09:32:11| store_swap_size = 21k

  09:32:31| parseHttpRequest: Unsupported method 'PROPFIND'

  09:32:31| clientReadRequest: FD 14 Invalid Request

  (用Ctl+C中止squid)

  09:33:44| Preparing for shutdown after 8 requests

  09:33:44| Waiting 0 seconds for active connections to finish

  09:33:44| FD 35 Closing HTTP connection

  09:33:45| Shutting down...

  09:33:45| FD 36 Closing ICP connection
09:33:45| Closing unlinkd pipe on FD 13

  09:33:45| storeDirWriteCleanLogs: Starting...

  09:33:45| Finished. Wrote 0 entries.

  09:33:45| Took 0 seconds ( 0.0 entries/sec).

  对/usr/local/etc/squid/squid.conf文件进行修改以允许适当的主机使用代理服务,为此加入以下三条:

  acl ourhosts src 192.168.0.0/255.255.255.0 #定义可以使用代理服务的主机地址范围及组名

  http_access allow ourhosts #允许此组访问http

  http_access deny all #禁止其它所有主机访问http

  重新启动squid,并用IE进行测试,结果很顺利:

  # /usr/local/sbin/squid -NCd1

  最后检查一下/usr/local/etc/rc.d目录中是否有它的启动脚本squid.sh,如没有可参照以下内容建一个:

  #!/bin/sh

  if [ -x /usr/local/sbin/RunCache -a -f /usr/local/etc/squid/squid.conf ]; then

  (cd /tmp; /usr/local/sbin/RunCache >/dev/null 2>&1 &) ; echo -n ' squid'

  fi

  防止用户绕过代理服务器

  好了,现在已经初步架好了squid(该服务器软件有非常之多的配置选项,可根据需要修改/usr/local/etc/squid/s quid.conf配置文件),紧接着的问题就是如何让用户只能通过代理服务器访问互联网,而不能绕过它,也就是说要阻塞端口80。为此可以在系统的防火墙规则中加入一些内容,假定ed0是网卡设备,规则添加如下:

  #/sbin/ipfw add 200 deny tcp from any to any 80 via ed0

  #/sbin/ipfw add 300 deny udp from any to any 80 via ed0

  当然,可以将这些规则放入系统的启动文件中,FreeBSD已经具有载入过滤规则的相应文件/etc/rc.firewall,要使用它只要在/etc/rc.conf文件中设置以下参
 firewall_enable=YES

  firewall_type="UNKNOWN"

  这时,除了把它们添加到已有的规则模板以适应少量修改之外,还可以把它们与其它一些您自定义的规则放入一个外部文件中,然后把firewall_type的值(默认的/etc/rc.firewall文件已定义了几种类型可作为此参数的值)改为此文件的全路径名,这样系统就会在启动时用ipfw自动执行这些规则。

  代收邮件

  通过安装并配置Fetchmail和Qpopper这两个软件可以为局域网中其它用户代收他们的外部电子邮件:

  #pkg_add qpopper-2.53.tgz

  #pkg_add fetchmail-5.2.0.tgz

  修改/etc/inetd.conf,去掉下面这条行首的#号:

  pop3 stream tcp nowait root /usr/local/libexec/popper popper

  然后用以下方法重启inetd以提供pop3服务:

  #ps -acx | grep inetd

  165 ? I 0.12 inetd

  #kill -HUP 165

  用户级PPP包含一个/etc/ppp/ppp.linkup这样的文件,用于在拨号成功之后运行一行东东,就象自动批处理文件一样,现在向这个文件中加入下面的内容:

  163:

  !bg sh -c "fetchmail -f /root/.fetchmailrc"

  这样就会在PPP拨号连接后自动后台运行Fetchmail收信了,至于收信的具体配置,需要在.fetchmailrc中定义,我把该文件放在/root目录下并chmod为700,以防止其它用户读取该文件中的信箱账号及口令。其具体设置样本如下:

  poll mail-meaculpa via pop.server1.com

  protocol pop3

  preauth password

  username meaculpa here is mea there

  password "123abc"

  pass8bits

  fetchall

  poll mail-user via pop.server2.com


  protocol pop3

  preauth password

  username user here is mike there

  password "456def"

  pass8bits

  fetchall

  其中via后的名称为pop3邮件服务器名;protocol用来说明使用的协议;authenticate用来说明验证方式;here前的名称为本地用户邮箱账号;there前的名称为远程用户邮箱账号;password说明远程账号对应的口令,其中如包含数字等特殊字符需要加引号;pass8bits说明收到的邮件中含有8位字符,这对于我们中文的邮件非常关键;最后的f etchall说明全部收取。关于Fetchmail的详细说明请用man fetchmail命令。

  这样,当Fetchmail读取该配置文件后即会收取对应的两个用户的外部邮件,并转存到其本地邮箱中,用户可以在自己的计算机中使用pop3方式连到拨号网关计算机进行收信,以便于统一管理

本文作者:
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3