使用鱿鱼循环通过出站 IP 地址

Bry*_*her 2 squid

工作中的 Squid 服务器用于通过多个外部 IP 地址路由请求。我正在使用解决方案在我自己的 Unix.SE 问题上进行命名 IP 路由。如果未设置自定义标题,我现在需要添加的另一个难题是随机选择。

我知道有一个“随机”指令可以根据概率设置 ACL,但在线示例充其量只是粗略的。

我需要一种方法将我的所有流量随机分配到 20 个 IP 地址,除非设置了特定的标头,此时标头(又名 ACL)应该优先并强制出站 IP 地址。如何在鱿鱼中使用 ACL 执行此操作?

Aar*_*ate 6

我不是鱿鱼专家,但我已经使用过它,并认为这可能有用。

acl random1 random 1/20
acl random2 random 1/20
acl random3 random 1/20
acl random4 random 1/20
acl random5 random 1/20
acl random6 random 1/20
acl random7 random 1/20
acl random8 random 1/20
acl random9 random 1/20
acl random10 random 1/20
acl random11 random 1/20
acl random12 random 1/20
acl random13 random 1/20
acl random14 random 1/20
acl random15 random 1/20
acl random16 random 1/20
acl random17 random 1/20
acl random18 random 1/20
acl random19 random 1/20
acl random20 random 1/20
acl prio1 req_header priohdr 1
acl prio2 req_header priohdr 2
acl prio3 req_header priohdr 3
acl prio4 req_header priohdr 4
acl prio5 req_header priohdr 5
acl prio6 req_header priohdr 6
acl prio7 req_header priohdr 7
acl prio8 req_header priohdr 8
acl prio9 req_header priohdr 9
acl prio10 req_header priohdr 10
acl prio11 req_header priohdr 11
acl prio12 req_header priohdr 12
acl prio13 req_header priohdr 13
acl prio14 req_header priohdr 14
acl prio15 req_header priohdr 15
acl prio16 req_header priohdr 16
acl prio17 req_header priohdr 17
acl prio18 req_header priohdr 18
acl prio19 req_header priohdr 19
acl prio20 req_header priohdr 20
tcp_outgoing_address 10.0.0.1 random1
tcp_outgoing_address 10.0.0.2 random2
tcp_outgoing_address 10.0.0.3 random3
tcp_outgoing_address 10.0.0.4 random4
tcp_outgoing_address 10.0.0.5 random5
tcp_outgoing_address 10.0.0.6 random6
tcp_outgoing_address 10.0.0.7 random7
tcp_outgoing_address 10.0.0.8 random8
tcp_outgoing_address 10.0.0.9 random9
tcp_outgoing_address 10.0.0.10 random10
tcp_outgoing_address 10.0.0.11 random11
tcp_outgoing_address 10.0.0.12 random12
tcp_outgoing_address 10.0.0.13 random13
tcp_outgoing_address 10.0.0.14 random14
tcp_outgoing_address 10.0.0.15 random15
tcp_outgoing_address 10.0.0.16 random16
tcp_outgoing_address 10.0.0.17 random17
tcp_outgoing_address 10.0.0.18 random18
tcp_outgoing_address 10.0.0.19 random19
tcp_outgoing_address 10.0.0.20 random20
tcp_outgoing_address 10.0.0.1 prio1
tcp_outgoing_address 10.0.0.2 prio2
tcp_outgoing_address 10.0.0.3 prio3
tcp_outgoing_address 10.0.0.4 prio4
tcp_outgoing_address 10.0.0.5 prio5
tcp_outgoing_address 10.0.0.6 prio6
tcp_outgoing_address 10.0.0.7 prio7
tcp_outgoing_address 10.0.0.8 prio8
tcp_outgoing_address 10.0.0.9 prio9
tcp_outgoing_address 10.0.0.10 prio10
tcp_outgoing_address 10.0.0.11 prio11
tcp_outgoing_address 10.0.0.12 prio12
tcp_outgoing_address 10.0.0.13 prio13
tcp_outgoing_address 10.0.0.14 prio14
tcp_outgoing_address 10.0.0.15 prio15
tcp_outgoing_address 10.0.0.16 prio16
tcp_outgoing_address 10.0.0.17 prio17
tcp_outgoing_address 10.0.0.18 prio18
tcp_outgoing_address 10.0.0.19 prio19
tcp_outgoing_address 10.0.0.20 prio20
Run Code Online (Sandbox Code Playgroud)

将 10.0.0.X 更改为传出连接的 ip 地址,显然这些地址需要在系统上可用,因此它们需要是静态 ips。

将最后的 10.0.0.1 更改为您希望流量 w/header 设置使用的任何连接。

来自浏览器的标头需要具有指定的名称并具有与正则表达式匹配的内容。

我再次不是专家,但值得一试。

这也是 20 次,每 20 次有 1 次机会匹配随机概率,理论上必须匹配一个,但不能保证,所以第一行应该设置默认连接。

编辑:

更新以允许连接选择,它需要测试,因为我不能 100% 确定它会按要求工作。