我的 squid(正向)代理服务器出了点小问题。即使远程服务器和客户端具有 IPv6 连接,它仍会继续使用 IPv4 作为传出 IP 地址。
我的客户端的 IP 地址:
devuan@devuan:~$ ip a show scope global
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:6e:90:f3 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.110/24 brd 192.168.1.255 scope global dynamic eth0
valid_lft 75947sec preferred_lft 75947sec
inet6 2a01:xxxx::90f3/64 scope global dynamic mngtmpaddr
valid_lft 86362sec preferred_lft 562sec
我使用自己制作的 HTTP 服务器测试了我的连通性,该服务器仅使用 IP 地址和所有 HTTP 标头来应答。
devuan@devuan:~$ curl -x proxy.home:3128 20102020.xyz
{
"headers": {
"Host": "20102020.xyz",
"X-Real-Ip": "90.1.1.1",
"X-Forwarded-For": "2a01:xxxx::90f3, 90.1.1.1",
"X-Forwarded-Proto": "http",
"X-Api": "/api",
"Connection": "close",
"User-Agent": "curl/7.74.0",
"Accept": "*/*",
"Via": "1.1 proxy.home (squid/5.7)",
"Cache-Control": "max-age=259200"
},
"date": "12-Jul-2023 09:37:33",
"ip": "90.1.1.1"
我得到了这个流程:客户端 --> IPv6 --> 代理服务器 --> IPv4 --> http 服务器当然,如果我强制客户端使用其 IPv4 地址,则连接流程将变为:客户端 --> IPv4 --> 代理服务器 --> IPv4 --> http 服务器
从代理服务器,默认情况下通过 IPv6 进行连接
tchupy@proxy:~ $ curl -vI 20102020.xyz
* Trying [2001:bc8:1820:134::1]:80...
* Connected to 20102020.xyz (2001:bc8:1820:134::1) port 80 (#0)
这是 squid.conf:
acl localnet src 0.0.0.1-0.255.255.255 # RFC 1122 "this" network (LAN)
acl localnet src 10.0.0.0/8 # RFC 1918 local private network (LAN)
acl localnet src 100.64.0.0/10 # RFC 6598 shared address space (CGN)
acl localnet src 169.254.0.0/16 # RFC 3927 link-local (directly plugged) machines
acl localnet src 172.16.0.0/12 # RFC 1918 local private network (LAN)
acl localnet src 192.168.1.0/24 # RFC 1918 local private network (LAN)
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
acl localnet src 2a01:xxxx::/56 # IPv6 local prefix
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
include /etc/squid/conf.d/*.conf
http_access allow localnet
http_access allow localhost
http_access deny all
http_port 3128
logformat squid-log %tl %6tr %>a %Ss/%03>Hs %<st %rm %ru %[un %Sh/%<a %mt
access_log daemon:/var/log/squid/access.log squid-log
coredump_dir /var/spool/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
我尝试在删除、关闭或打开时配置“forwarded_for”键,但除了私有 IP 地址隐藏在“X-Forwarded-For”标头中之外,它没有改变任何东西。
明确地说,如果远程服务器具有 IPv6 连接,我想使用 IPv6 传出地址。有没有办法像这样配置 squid?
谢谢