透過 redsocks 重定向連線但沒有回應

透過 redsocks 重定向連線但沒有回應

我使用 redsocks 透過代理進行重定向。問題是,當我使用像 wget 這樣的工具時,它似乎正在連接但未解析。可能是什麼問題以及我該如何解決它?

執行 wget google.com

--2020-08-22 17:32:34--  http://google.com/
Resolving google.com (google.com)... 172.217.1.110, 2607:f8b0:4008:810::200e
Connecting to google.com (google.com)|172.217.1.110|:80... connected.
HTTP request sent, awaiting response... 

執行curl google.com

捲曲 -v google.com -o 已儲存

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 172.217.1.110:80...
* Connected to google.com (172.217.1.110) port 80 (#0)
> GET / HTTP/1.1
> Host: google.com
> User-Agent: curl/7.71.1
> Accept: */*
> 
  0     0    0     0    0     0      0      0 --:--:--  0:00:14 --:--:--     0^C

紅襪設定檔

base {
    log_debug = on;
    log_info = on;
    log = "file:/var/log/redsocks.log";

    daemon = on;

    redirector = iptables;
}

redsocks {
    local_ip = 0.0.0.0;
    local_port = 12345;

    ip = my.proxy;
    port = 3128;

    type = http-connect;

    login = "myUser";
    password = "myPassword";
}

redsocks {
    local_ip = 0.0.0.0;
    local_port = 12346;

    ip = my.proxy;
    port = 3128;

    type = http-relay;

    login = "myUser";
    password = "myPassword";
}

iptables

Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
REDSOCKS   tcp  --  0.0.0.0/0            0.0.0.0/0           

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         

Chain REDSOCKS (1 references)
target     prot opt source               destination         
RETURN     all  --  0.0.0.0/0            0.0.0.0/8           
RETURN     all  --  0.0.0.0/0            10.0.0.0/8          
RETURN     all  --  0.0.0.0/0            100.64.0.0/10       
RETURN     all  --  0.0.0.0/0            127.0.0.0/8         
RETURN     all  --  0.0.0.0/0            169.254.0.0/16      
RETURN     all  --  0.0.0.0/0            172.16.0.0/12       
RETURN     all  --  0.0.0.0/0            192.168.0.0/16      
RETURN     all  --  0.0.0.0/0            198.18.0.0/15       
RETURN     all  --  0.0.0.0/0            224.0.0.0/4         
RETURN     all  --  0.0.0.0/0            240.0.0.0/4         
REDIRECT   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:80 redir ports 12346
REDIRECT   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:443 redir ports 12345
REDIRECT   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:11371 redir ports 12346

答案1

我用 transocks 取代了 redsocks,現在我可以使用一個配置來同時進行「http」和「https」重定向(在我的 IP 表中,我將所有流量重定向到 transocks)

https://github.com/cybozu-go/transocks

相關內容