
從理論上講,我知道代理伺服器的內部和外部如何運作,但實踐讓我發揮了最大作用。
我需要在與我的管理 IP 相同的網路中配置 SOCKS 代理,以便它保持對使用者的抽象。我有一個 vCenter 集群,可以在其上部署任何推薦的作業系統,但為了簡化這裡的設定:
- 儲存系統管理 IP = 10.244.244.15
- SUSE11虛擬機器IP = 10.244.244.10
- Windows XP IP = 10.244.244.5
在 SUSE 系統上,我運行了ssh -ND 1080 <user>@<storage mgmt ip>
,但這並沒有產生端對端連線。
tcpdump
當時我正在同一端口上運行,並看到一些流量嘗試:
17:42:26.669953 IP 10.x.x.x.54214 > x.x.com.socks: S 3287828135:3287828135(0) win 5840 <mss 1460,sackOK,timestamp 6708230 0,nop,wscale 6>
17:42:26.669968 IP x.x.com.socks > 10.x.x.x.54214: R 0:0(0) ack 3287828136 win 0
總體問題:
- 不太重要的是,我上面做了什麼?
- 更重要的是,如何在這種環境下配置 SOCKS 代理?
答案1
由於 SSHD 配置中的 GatewayPorts 設置,SSH 連接可能僅在環回接口 (127.0.0.1) 上偵聽。如果 GatewayPorts 設定為 yes,您的命令將起作用。
netstat -an | grep LISTEN
將向您顯示它是否正在公共介面上偵聽。您可以強制它在公共介面上監聽
ssh -ND <ip address>:<port> <user>:<host>
但前提是 GatewayPorts 允許您這樣做。
GatewayPorts
Specifies whether remote hosts are allowed to connect to ports
forwarded for the client. By default, sshd binds remote port
forwardings to the loopback address. This prevents other remote
hosts from connecting to forwarded ports. GatewayPorts can be
used to specify that sshd should allow remote port forwardings to
bind to non-loopback addresses, thus allowing other hosts to con-
nect. The argument may be "no" to force remote port forwardings
to be available to the local host only, "yes" to force remote
port forwardings to bind to the wildcard address, or
"clientspecified" to allow the client to select the address to
which the forwarding is bound. The default is "no".
我的猜測是 GatewayPorts 設定為預設值 no。將其變更為 yes(在 中/etc/ssh/sshd_config
),然後您的 ssh 命令應該保持不變,但您可以使用特定介面的 IP 位址以防萬一。
注意:除此之外,您還應該檢查是否有 iptables 規則阻止入站連線。
像 ssh 代理程式一樣可以工作,但它可能會很慢(加密開銷)。您可能想查看專用的襪子代理,例如襪子襪子。