🔗 使用 IPFW 拦截流量
🔗 目录
此配置用于使用 IPFirewall (IPFW) 将 NAT 流量拦截到 Squid 代理的机器。
NAT配置仅在在squid盒子上使用时才有效。这是准确和安全地执行拦截所必需的。要从网关机拦截并将流量指向单独的squid盒,请使用策略路由。
🔗 Squid 配置
首先,编译并安装 Squid。它需要以下选项
./configure --enable-ipfw-transparent
您需要像这样配置 Squid 以便它知道 IP 地址正在被拦截:
http_port 3129 transparent
在 Squid 3.1+ 中,transparent 选项已被拆分。使用 ‘intercept 来捕获 IPFW 数据包。
http_port 3129 intercept
🔗 rc.firewall.local 配置
# Interface where client requests are coming from
IFACE=eth0
# The IP Squid is listening on for requests. localhost is safest.
SQUIDIP=127.0.0.1
# Path to ipfw command
IPFW=/sbin/ipfw
${IPFW} -f flush
${IPFW} add 60000 permit ip from any to any
${IPFW} add 100 fwd ${SQUIDIP},3129 tcp from any to any 80 recv ${IFACE}
🔗 测试
要测试是否有效,请使用 **nc** 工具。停止 squid,然后从 root 命令提示符中输入
nc -l 3129
然后重新启动 squid 并尝试浏览一个页面。
您现在应该看到类似以下的输出
<root:freebsd> [/root]
> nc -l 3129
GET / HTTP/1.1
User-Agent: Mozilla/5.0 (compatible; GNotify 1.0.25.0)
Host: example.com
Connection: keep-alive
...
从那时起,只需正常设置您的浏览器,无需代理服务器,您就应该看到缓存已满,并且您的浏览速度加快。
🔗 故障排除
🔗 在 MacOS X 10.6 上,流量未显示在 Squid 中
作者:Jeffrey j Donovan
你需要编辑
sysctl -w net.inet.ip.scopedroute=0
之前的 MacOS X 默认将其设置为 0。在 MacOS X 10.6 上,它现在默认为 1。禁用此设置,Squid 即可接收流量。
⚠️ Disclaimer: Any example presented here is provided "as-is" with no support
or guarantee of suitability. If you have any further questions about
these examples please email the squid-users mailing list.
类别: ConfigExample
导航:站点搜索、站点页面、分类、🔼 向上