squid 代理 - 仅对传出流量使用 ipv6

squid 代理 - 仅对传出流量使用 ipv6

我想设置一个 squid 代理,仅将 ipv6 用于传出流量。我希望 ip4 地址对于我连接的服务完全不可见。我不关心回退和缺乏 ipv6 支持,我连接的服务完全支持 ipv6。使用我的设置,IPv4 和内部 IP 是可见的。我遗漏了什么?

谢谢

这是我的 squid.conf:

http_access allow localhost manager
http_access deny manager
http_access allow localhost
http_port 3128
http_port 3129
coredump_dir /var/spool/squid

http_access allow all
acl to_ipv4 dst ipv4
http_access deny to_ipv4

acl user1 myportname 3128
acl user2 myportname 3129

tcp_outgoing_address x:x:x:x::1 user1
tcp_outgoing_address x:x:x:x::2 user2

forwarded_for delete
via off
follow_x_forwarded_for deny all
request_header_access X-Forwarded-For deny all
request_header_access From deny all
request_header_access Referer deny all
request_header_access User-Agent deny all
request_header_access Authorization allow all
request_header_access Proxy-Authorization allow all
request_header_access Cache-Control allow all
request_header_access Content-Length allow all
request_header_access Content-Type allow all
request_header_access Date allow all
request_header_access Host allow all
request_header_access If-Modified-Since allow all
request_header_access Pragma allow all
request_header_access Accept allow all
request_header_access Accept-Charset allow all
request_header_access Accept-Encoding allow all
request_header_access Accept-Language allow all
request_header_access Connection allow all
request_header_access All deny all

答案1

我在 Windows 11 上运行的 Squid 版本 4.14 上测试了以下配置文件,该配置文件仅允许 IPv6 流量:

acl localnet src 10.0.0.0/8
acl localnet src 172.16.0.0/12
acl localnet src 192.168.0.0/16
acl localnet src fc00::/7
acl localnet src fe80::/10
acl SSL_ports port 443
acl Safe_ports port 80
acl Safe_ports port 21
acl Safe_ports port 443
acl Safe_ports port 70
acl Safe_ports port 210
acl Safe_ports port 1025-65535
acl Safe_ports port 280
acl Safe_ports port 488
acl Safe_ports port 591
acl Safe_ports port 777
acl CONNECT method CONNECT
acl ipv4_from src ipv4
acl ipv4_to dst ipv4
dns_v4_first off
acl to_ipv6 dst ipv6
http_access allow localhost manager
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny ipv4_to
http_access deny ipv4_from
http_access deny !to_ipv6
http_access allow to_ipv6
http_access allow localnet
http_access allow localhost
http_access deny all
http_port 3128
coredump_dir /var/cache/squid
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
dns_nameservers 2620:fe::fe
max_filedescriptors 3200

我确认了https://ipv6-test.com/并正确发现没有 ip4 连接但 ipv6 连接完全正常。

关键部分是拒绝http_access水平ipv4_toipv4_from和相反的规则!to_ipv6

注意:DNS 服务器也设置为使用 IPv6 服务器。

答案2

我遇到了同样的问题,并且这个问题为我解决了:

将其添加到您的 squid.conf 文件中:

forwarded_for off

这将排除系统 (ipv4) IP 地址的转发。

相关内容