免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1860 | 回复: 0
打印 上一主题 下一主题

IPNAT+Ipfilter+Squid Transparent Proxy 超級防火牆 [复制链接]

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-09 08:38 |只看该作者 |倒序浏览
Description :
安裝完防火牆之後感覺好像欠缺某些東西似的,對了!少了 HTML 的過濾機智,ipfilter 只有針對各試各樣的通訊協定 ( tcp/udp/icmp...) 過濾,似乎不能滿足我們的需求,因此我們需要在防火牆內再加裝 Squid,以達到擁有 Transparent Proxy 的能力,這樣的防火牆才能真正稱的上是超級防火牆。
Setp 1.
安裝squid:
#cd /usr/ports/www/squid
#make install clean
設定squid.conf  #vi /usr/local/etc/squid/squid.conf 內容如下:
http_port 3128cache_mem 8 MBmaximum_object_size 4096 KBcache_dir ufs /usr/local/squid/cache 100 16 256cache_access_log /usr/local/squid/logs/access.logcache_log /usr/local/squid/logs/cache.logcache_store_log /usr/local/squid/logs/store.log#cache_mgr admin@ntut.idv.twcache_effective_user nobodycache_effective_group nogroup#acl all src 0.0.0.0/0.0.0.0acl manager proto cache_objectacl localhost src 127.0.0.1/255.255.255.255acl SSL_ports port 443 563acl Safe_ports port 80 21 70 1025-65535acl Valid_ports port 80 21 3128 8080 70 151 1-1024acl CONNECT method CONNECTacl lan-a src 10.10.10.0/24acl hotmail dstdomain .hotmail.comacl msn dstdomain .msn.com#http_access deny msnhttp_access deny hotmailhttp_access allow manager localhosthttp_access deny managerhttp_access allow lan-ahttp_access deny all#httpd_accel_host virtualhttpd_accel_port 80httpd_accel_with_proxy onhttpd_accel_uses_host_header on
squid.conf 設定說明:
http_port 3128 # squid Listen於3128這個port。也就是說,只要將Client端browser內的proxy指向,指向這台的 IP,port 為 3128,Client即可透過這台Squid Server上網。
cache_mem 8 MB  # 設定squid所使用的記憶體最大為8 MB。您可以依自己的須求,調整其大小。如:您的實體記憶體為256 MB,您可將此調整為64 MB
cache_dir ufs /usr/local/squid/cache 100 16 256  # 設定 cache 要放在/usr/local/squid/cache 之下,最多佔 100 MB 的硬碟容量,第一層子目錄的 最大數量為 16 個,第二層子目錄的最大數量為 256 個。
cache_access_log /usr/local/squid/logs/access.log # 哪些 IP 去過哪些網址,記錄在/usr/local/squid/logs/access.log 檔內 . ( 此檔會很大 , 若無需要 , 可將之轉向到 /dev/null 內。
cache_log /usr/local/squid/logs/cache.log  # 把 cache 內,檔案的增減,記錄在/usr/local/squid/logs/cache.log 檔案之內。
cache_store_log /usr/local/squid/logs/store.log  # 把從哪些網址捉下哪些檔案,記錄在/usr/local/squid/logs/store.log 的檔案之內。
reference_age 1 week  # 設定網頁留在cache內最多可以保留多久。時間越長,效果越顯著,但看到過期網頁的機會越大。可改成:reference_age 8 hours、reference_age 1 day、reference_age 3 week、reference_age 5 months、reference_age 1 year。
cache_mgr admin@ntut.idv.tw  # 設定管理者的E-Mail信箱。
acl lan-a src 10.10.10.0/24   # 宣告一個名為lan-a的群組,範圍屬於10.10.10.0/24這個網段。
http_access allow lan-a  # 設定lan-a 這個群組可以使用 Squid Proxy Server。
http_access deny all  # (有先後順序)除了前面設定allow或deny的群組之外,其它的全部都不能使用 Squid Proxy Server。
httpd_accel_host virtualhttpd_accel_port 80httpd_accel_with_proxy onhttpd_accel_uses_host_header on   #  這四行為Transparent proxy 設定
squid 常用指令:
#squid -z    # 建立cache_dir
#chown -R nobody:nogroup /usr/local/squid/logs    # 更改logs權限
#chown -R nobody:nogroup /usr/local/squid/cache    # 更改cache權限
#/usr/local/etc/rc.d/squid.sh start   # 開啟squid
#squid -k reconfigure   # 不必重新啟動squid即可重讀squid.conf
Setp 2.
設定 ipfilter 的 ipnat.rules 加入下面這行 ipfilter 即可運作 Transparent mode
rdr de1 0.0.0.0/0 port 80 -> 10.10.10.254 port 3128 tcp/udp
參考資料:
http://w.yi.org/weblog/41_0_1_0.html
http://linux.vbird.org/linux_server/0420squid.php
http://turtle.ee.ncku.edu.tw/~tung/proxy/


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/4206/showart_522875.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP