大网数据广告活动
服务器运维问答

Squid 4.2 - Different outbound IP for each client/user

· 52CE 我爱测

I have been playing with a few different pieces of forward proxy software, primarily CCProxy and Squid Proxy/Cache. What I have is a dedicated server with a single NIC with multiple IPs assigned to it. One IP is static and the re…

问题原文

原帖链接 · jcbjoe · CC BY-SA 4.0

I have been playing with a few different pieces of forward proxy software, primarily CCProxy and Squid Proxy/Cache. What I have is a dedicated server with a single NIC with multiple IPs assigned to it. One IP is static and the rest are dynamic. The static IP acts as a primary address, which is how I access my proxy server, the others are dynamic ip addresses for web scraping and other tasks. I have created a proxy in CCProxy and it allows you to link a user to a specific outbound ip address, this is really useful for what I am doing, allowing me to assign different tasks to different IPs.

So what I was wondering if this was possible to do in Squid Proxy?

I love how customisable Squid is but I really could do with this feature.

Thanks in advance, Joe

已采纳解答

原帖链接 · A.B · CC BY-SA 4.0

The option to do this is tcp_outgoing_address:

Allows you to map requests to different outgoing IP addresses based on the username or source address of the user making the request.

"outgoing IP address" really means "source IP". Now you can choose an acl to distinguish your user by any available mean, client's IP (acl ... src ...), simple proxy authentication (auth_param + basic_ncsa_auth) etc.

Example adapted from documentation, using source IP as selector, where the squid server would be owning various IPs in the 192.0.2.0/24 LAN with its primary IP 192.0.2.1. Adding this to the typical sample squid.conf:

acl allowed_clients src 198.51.100.0/24
http_access allow allowed_clients

acl dedicated_client1 src 198.51.100.174
tcp_outgoing_address 192.0.2.174 dedicated_client1
tcp_outgoing_address 192.0.2.10 allowed_clients
tcp_outgoing_address 192.0.2.5

will allow clients from allowed_clients, and have them use outgoing IP 192.0.2.10, except for client from 198.51.100.174 which will get 192.0.2.174. Any other client configured elsewhere than in this example would use 192.0.2.5 and the server's primary IP will never be used.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-09-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。