因此,我有一个运行PF和Squid的FreeBSD路由器,它具有三个网络接口:两个连接到上游提供商(em0em1 分别为LAN)(re0)我们服务。 PF配置了一些负载平衡。基本上,它将所有流量路由到端口 1-1024 通过一个接口(em0)以及其他一切(em1).

现在,我在盒子上还运行了一个鱿鱼代理 3128127.0.0.1. 。由于Squid将此请求重定向到外部HTTP,因此应遵循负载平衡规则 em0, , 不?问题是,当我们测试它时(通过从LAN中的计算机浏览到 http://whathismyip.com, ,报告的外部IP em1 界面!当我们关闭鱿鱼时,外部IP em0 如预期的那样报道。

如何使鱿鱼表现出我们已经建立的负载平衡规则?

这是相关的设置 /etc/pf.conf 我有:

ext_if1="em1"   # DSL
ext_if2="em0"   # T1
int_if="re0"

ext_gw1="x.x.x.1"
ext_gw2="y.y.y.1"

int_addr="10.0.0.1"
int_net="10.0.0.0/16"

dsl_ports = "1024:65535"
t1_ports = "1:1023"

...

squid=3128
rdr on $int_if inet proto tcp from $int_net \
        to any port 80 -> 127.0.0.1 port $squid
pass in quick on $int_if route-to lo0 inet proto tcp \
        from $int_net to 127.0.0.1 port $squid keep state

...

# load balancing
pass in on $int_if route-to ($ext_if1 $ext_gw1) \
        proto tcp from $int_net to any port $dsl_ports keep state
pass in on $int_if route-to ($ext_if1 $ext_gw1) \
        proto udp from $int_net to any port $dsl_ports

pass in on $int_if route-to ($ext_if2 $ext_gw2) \
        proto tcp from $int_net to any port $t1_ports keep state
pass in on $int_if route-to ($ext_if2 $ext_gw2) \
        proto udp from $int_net to any port $t1_ports

pass out on $ext_if1 route-to ($ext_if2 $ext_gw2) from $ext_if2 to any
pass out on $ext_if2 route-to ($ext_if1 $ext_gw1) from $ext_if1 to any

我试过附加以下规则,但没有任何作用:

pass in on $int_if route-to ($ext_if2 $ext_gw2) \
        proto tcp from 127.0.0.1 to any port $t1_ports keep state

谢谢!

有帮助吗?

解决方案

如果您希望所有传出的鱿鱼请求转到特定接口上的特定IP地址,则应该能够在Squid.conf中使用“ TCP_OUTONGION_ADDRESS”选项,以在EM0上指定IP地址。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top