为什么访问第二个 LAN(通过 squid)失败?

为什么访问第二个 LAN(通过 squid)失败?

我在使用一个非常简单的 squid 配置时遇到了问题。

我的网络配置如下:

=== 192.168.3.xxx LAN === (eth1 - .100)[代理主机](.18.240.66 - eth0) === 10.xxx LAN

我想将来自 192.168.3.0/24 LAN 的请求代理到 10.0.0.0/8 LAN。我已在 192.168.3.200 上设置了代理设置,以使用 192.168.3.100:8080 上的代理。代理请求可以顺利到达代理,但似乎无法通过 eth0 发出。我已经使用 Wireshark 验证了这两个问题。

具体来说,我尝试通过代理从 192.168.3.200 向 10.63.78.243 发送 HTTP 请求。以下是最终到达 squid 的内容access.log

192.168.3.200 TCP_MISS/000 0 GET http://10.63.78.243:8080/path/server.jsp? - DIRECT/10.63.78.243 -

从 .200 发送到 .100:8080 的数据包具有此内容(通过 Wireshark):

GET http://10.63.78.243:8080/path/server.jsp?x=x HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Accept-Language: en-us
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.1; MS-RTC LM 8)
Accept-Encoding: gzip, deflate
Proxy-Connection: Keep-Alive
Host: 10.63.78.243:8080

我有以下鱿鱼配置:

#
# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines
acl RDnet dst 10.0.0.0/8

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

#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager

# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost
http_access allow RDnet

# And finally deny all other access to this proxy
http_access deny all

# Squid normally listens to port 3128
http_port 8080

# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?

# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

# Add any of your own refresh_pattern entries above these.
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

netstat -rn给出以下内容:

[root@localhost squid]# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.3.0     0.0.0.0         255.255.255.0   U         0 0          0 eth1
192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0
10.18.240.0     0.0.0.0         255.255.248.0   U         0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth1
0.0.0.0         10.18.247.254   0.0.0.0         UG        0 0          0 eth0

我读到的是,通过 eth0 将任何数据包(包括发往 10.63.78.243 的数据包)路由到 10.18.247.254。我知道它是可访问的(请参阅此输出ping -R

[root@localhost squid]# ping -c 1 -R 10.63.78.243
PING 10.63.78.243 (10.63.78.243) 56(124) bytes of data.
64 bytes from 10.63.78.243: icmp_seq=1 ttl=50 time=377 ms
RR:     10.18.240.66
    10.138.156.186
    10.17.182.22
    10.190.11.66
    112.78.255.4
    198.19.1.41
    10.143.222.81
    10.143.222.98
    172.31.206.129


--- 10.63.78.243 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 377ms
rtt min/avg/max/mdev = 377.644/377.644/377.644/0.000 ms

有什么想法吗?我有一个想法是 Squid 可以正常接收请求并尝试发送它,但是......它会去哪里?此主机只有 2 个接口,发往 10.xxx 的数据包应该从 eth0 发出。但是 Wireshark 中没有显示任何数据包。所以我有点迷茫。

更新:在配置文件中添加以下内容:

cache_peer 10.159.3.23 parent 8080 0 default

这使得我的代理可以将请求转发到实际上可以到达 10.63.78.243 主机的代理。

答案1

MISS/000 表示中止,不确定它是否来自客户端,或者将请求传递到 10.63.78.243:8080 后没有回复

从 squid 主机执行“telnet 10.63.78.243 8080”会得到什么?GET / HTTP/1.1 Host: 10.63.78.243:8080

相关内容