Dante SOCKS5 服务器不通过 ppp 接口发送流量

Dante SOCKS5 服务器不通过 ppp 接口发送流量

我通过带有外部电源适配器的 USB 集线器将几个 3G 调制解调器安装到我的 RaspberryPI 中。目标是通过这些调制解调器创建多个 ppp 连接,并通过ocks5代理共享互联网(1个运营商 -> 1个专用端口)。

root@raspberrypi:/etc# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.88.81  netmask 255.255.255.0  broadcast 192.168.88.255
        inet6 fe80::be35:5f3a:e942:e39a  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:92:b1:0b  txqueuelen 1000  (Ethernet)
        RX packets 8747  bytes 702623 (686.1 KiB)
        RX errors 0  dropped 2448  overruns 0  frame 0
        TX packets 1452  bytes 183993 (179.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 4  bytes 156 (156.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 156 (156.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ppp-kyivstar0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
        inet 10.203.1.38  netmask 255.255.255.255  destination 10.64.64.64
        ppp  txqueuelen 3  (Point-to-Point Protocol)
        RX packets 16  bytes 382 (382.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 16  bytes 514 (514.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ppp-vodafone0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1440
        inet 100.87.250.240  netmask 255.255.255.255  destination 10.64.64.65
        ppp  txqueuelen 3  (Point-to-Point Protocol)
        RX packets 7  bytes 58 (58.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7  bytes 82 (82.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

dante-server 的配置文件如下所示:

root@raspberrypi:/etc# grep -v "^#" /etc/danted-vodafone0.conf | grep -v "^$"
debug: 0
logoutput: stderr stdout
internal: 192.168.88.81 port = 50002
internal: 127.0.0.1 port = 50002
external: ppp-vodafone0
socksmethod: none
clientmethod: none
user.privileged: proxy
user.unprivileged: nobody
user.libwrap: nobody
client pass {
    from: 192.168.88.0/24 port 1-65535 to: 0.0.0.0/0
}
client pass {
    from: 127.0.0.0/8 port 1-65535 to: 0.0.0.0/0
}
client block {
    from: 0.0.0.0/0 to: 0.0.0.0/0
    log: connect error
}
socks block {
    from: 0.0.0.0/0 to: lo
    log: connect error
}
socks pass {
    from: 192.168.88.0/24 to: 0.0.0.0/0
    protocol: tcp udp
}
socks pass {
    from: 127.0.0.0/8 to: 0.0.0.0/0
    protocol: tcp udp
}
socks block {
    from: 0.0.0.0/0 to: 0.0.0.0/0
    log: connect error
}

当我尝试用curl 测试它时 - 什么也没有发生:

# curl -v --socks5 192.168.88.81:50002 http://ifconfig.co
* Rebuilt URL to: http://ifconfig.co/
*   Trying 192.168.88.81...
* TCP_NODELAY set
* SOCKS5 communication to ifconfig.co:80
* SOCKS5 connect to IPv4 104.27.140.78 (locally resolved)
* Can't complete SOCKS5 connection to 0.0.0.0:0. (6)
* Closing connection 0
curl: (7) Can't complete SOCKS5 connection to 0.0.0.0:0. (6)

从另一侧,当我将其作为参数时,curl 能够通过该接口建立连接:

# curl -v --interface ppp-vodafone0 http://ifconfig.co
* Rebuilt URL to: http://ifconfig.co/
*   Trying 104.27.140.78...
* TCP_NODELAY set
* Local Interface ppp-vodafone0 is ip 100.120.201.176 using address family 2
* Local port: 0
* Connected to ifconfig.co (104.27.140.78) port 80 (#0)
> GET / HTTP/1.1
> Host: ifconfig.co
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Sat, 08 Sep 2018 00:20:50 GMT
< Content-Type: text/plain; charset=utf-8
< Content-Length: 14
< Connection: keep-alive
< Set-Cookie: __cfduid=df1da9ab56a621c1a8e3a1e75faac555c1536366050; expires=Sun, 08-Sep-19 00:20:50 GMT; path=/; domain=.ifconfig.co; HttpOnly
< Via: 1.1 vegur
< Server: cloudflare
< CF-RAY: 456d4066058483ee-KBP
<
46.133.227.38
* Curl_http_done: called premature == 0
* Connection #0 to host ifconfig.co left intact 

这里可能出了什么问题?

答案1

我发现了问题。首先,在 ppp 会话期间我特别设置了 ppp 对等体没有默认路由配置。因此,从 pppX 接口发出的数据包不知道如何路由。这种情况通过所谓的基于策略的路由得到了解决。

首先,您需要在 中预先定义所有附加路由表/etc/iproute2/rt_tables。我的文件如下所示:

# Ansible managed
#
# reserved values
#
255 local
254 main
253 default
0   unspec
#
# local
#
#1  inr.ruhep
103 kyivstar0
101 lifecell0
102 vodafone0

这些 101..103 是 PPP 接口的路由表。之后您需要设置策略。它看起来像这样:

ip rule add from 100.83.31.204 table vodafone0
ip route add 0.0.0.0/0 via 10.64.64.64 dev ppp-vodafone0 table vodafone0

在哪里:

  • 100.83.31.204- 本地 PPP IP 地址
  • 10.64.64.64- 远程PPP IP地址
  • ppp-vodafone0- PPP接口的名称
  • vodafone0- 预定义的路由表名称/etc/iproute2/rt_tables

调整基于策略的路由后,一切都按预期进行。

相关内容