0

つまり、PFとSquidを実行しているFreeBSDルーターがあり、3つのネットワークインターフェイスがあります。2つはアップストリームプロバイダー(em0およびem1)に接続され、もう1つは私たちがサービスを提供するLAN(re0)に接続されています。PFで構成されたロードバランシングがいくつかあります。1-1024基本的に、すべてのトラフィックを1つのインターフェイス()を介してポートにルーティングしem0、その他すべてを他のインターフェイス()を介してルーティングしますem1

これで、LANからのポート3128にHTTPリクエストを透過的にリダイレクトするSquidプロキシもボックスで実行されています127.0.0.1。Squidはこのリクエストを外部のHTTPにリダイレクトするため、負荷分散ルールに従う必要がありますem0。問題は、テストしたときに(LAN内のコンピューターからhttp://whatismyip.comにアクセスすると、em1インターフェイスの外部IPが報告されます!Squidをオフにすると、の外部IPが次のem0ように報告されます。期待される。

設定した負荷分散ルールでSquidを動作させるにはどうすればよいですか?

これが私が持っている関連する設定です/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

ありがとう!

4

1 に答える 1

1

すべての発信squidリクエストを特定のインターフェイスの特定のIPアドレスに送信する場合は、squid.confの「tcp_outgoing_address」オプションを使用してem0のIPアドレスを指定できる必要があります。

于 2010-06-27T13:02:41.190 に答える