Squid Web Cache Wiki

Squid Web Cache 文档

🔗 使用 Fedora Core Linux 和 WCCPv2 配置透明拦截

🔗 目录

此配置适用于运行 Squid 并通过 ip_gre 接收 WCCPv2 流量的 Fedora Core Linux 2.6.18 服务器。预计另一台设备将执行 WCCPv2 路由,并将其转发到此服务器进行处理。

🔗 Fedora Core WCCPv2 配置

GRE 数据包的源 IP 是路由器上的一个 IP 地址 - 我猜是“路由器标识符”。这可能不是本地以太网 IP(在本例中,不是 192.168.1.1)。

🔗 /etc/sysctl.conf

# Controls IP packet forwarding
net.ipv4.ip_forward = 1
# Controls source route verification
net.ipv4.conf.default.rp_filter = 0
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0

🔗 /etc/sysconfig/network-scripts/ifcfg-gre0

DEVICE=gre0
BOOTPROTO=static
IPADDR=172.16.1.6
NETMASK=255.255.255.252
ONBOOT=yes
IPV6INIT=no

通过这样配置接口,它会在启动时自动启动,并且模块会自动加载。我还可以根据需要手动启动或停止该接口。这是 Fedora 配置 GRE 接口的标准方法。

🔗 Fedora Core 拦截配置

然后,您需要将进入 gre0 接口的数据包重定向到 Squid 应用程序。

🔗 /etc/sysconfig/iptables

-A PREROUTING -s 192.168.0.0/255.255.255.0 -d ! 192.168.0.0/255.255.255.0 -i gre0 -p tcp -m tcp --dport 80 -j DNAT --to-destination $SQUIDIP:3127

🔗 Squid 配置文件

http_port 3127 transparent
wccp2_router $ROUTERIP
# GRE forwarding
wccp2_forwarding_method gre
# GRE return method
wccp2_return_method gre
wccp2_service standard 0

🔗 整体看起来是怎样的?

我的操作系统运行一个 GRE 隧道,看起来是这样的

[root@tornado squid]# ifconfig gre0
gre0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:172.16.1.6  Mask:255.255.255.252
          UP RUNNING NOARP  MTU:1476  Metric:1
          RX packets:449 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:20917 (20.4 KiB)  TX bytes:0 (0.0 b)

我的路由器可以看到缓存引擎,并告诉我它已经转发了多少流量到缓存

router#show ip wccp web-cache
Global WCCP information:
    Router information:
        Router Identifier:                   172.16.1.5
        Protocol Version:                    2.0
    Service Identifier: web-cache
        Number of Service Group Clients:     1
        Number of Service Group Routers:     1
        Total Packets s/w Redirected:        1809
          Process:                           203
          Fast:                              1606
          CEF:                               0
        Redirect access-list:                -none-
        Total Packets Denied Redirect:       0
        Total Packets Unassigned:            0
        Group access-list:                   -none-
        Total Messages Denied to Group:      0
        Total Authentication failures:       0
        Total Bypassed Packets Received:     0
router#
router#show ip wccp web-cache detail
WCCP Client information:
        WCCP Client ID:          192.168.0.5
        Protocol Version:        2.0
        State:                   Usable
        Initial Hash Info:       00000000000000000000000000000000
                                 00000000000000000000000000000000
        Assigned Hash Info:      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
                                 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
        Hash Allotment:          256 (100.00%)
        Packets s/w Redirected:  449
        Connect Time:            13:51:42
        Bypassed Packets
          Process:               0
          Fast:                  0
          CEF:                   0
router#

⚠️ 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

导航:站点搜索站点页面分类🔼 向上