iptables - 如何将来自openvpn客户端的所有流量重定向到socks5?
问题描述
我已将 openvpn 完全配置为 udp 端口。openvpn 网络地址为 10.8.0.0。我已经设置了 redsocks 代理,如下所示。
base {
log_debug = on;
log_info = on;
log = "stderr";
daemon = off;
redirector = iptables;
}
redsocks {
// Local IP listen to
local_ip = 127.0.0.1;
// Port to listen to
local_port = 31338;
ip = 127.0.0.1;
port = 31337;
// Proxy type
type = socks5;
}
我已经为传出端口 31337 设置了路由。
问题是我要将所有来自 openvpn 客户端的传入数据包重定向到 redsocks 代理。我已经配置了 iptables,但无法正常工作。我错过了什么重要的东西?
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
REDSOCKS tcp -- anywhere anywhere tcp dpt:https
REDSOCKS tcp -- anywhere anywhere tcp dpt:http
REDSOCKS tcp -- anywhere anywhere tcp dpt:socks
REDSOCKS udp -- anywhere anywhere
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
REDSOCKS tcp -- anywhere anywhere owner UID match user0
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
Chain REDSOCKS (5 references)
target prot opt source destination
RETURN all -- anywhere 0.0.0.0/8
RETURN all -- anywhere 10.0.0.0/8
RETURN all -- anywhere localhost/8
RETURN all -- anywhere link-local/16
RETURN all -- anywhere 172.16.0.0/12
RETURN all -- anywhere 192.168.0.0/16
RETURN all -- anywhere base-address.mcast.net/4
RETURN all -- anywhere 240.0.0.0/4
REDIRECT tcp -- anywhere anywhere redir ports 31338
如果我在本地运行 curl,redsocks 代理会接收数据包并处理它们。但是如果我在 openvpn 客户端中运行 curl,redsocks 没有收到数据包。
请帮我。ps:我也添加了iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
,但现在还在工作。
解决方案
推荐阅读
- linux - 在 bash 中通过单个 sftp 连接传输多个文件
- javascript - 使用react-dnd在形状边缘拖放?
- ios - 滚动时选择了多个单元格[重用单元格问题]
- javascript - Javascipt将父级添加到数组
- ios - 如何在 SwiftUI 中进行这种简单的布局?
- python - 与熊猫合并后设置索引?
- javascript - 使用 React Hooks 在两个独立组件之间传递状态的问题
- javascript - 如果提供许多数据,图形不显示值/使用 ajax 在 HTML 中绘制 charrt
- angular - 角度确认框:如何使它*看起来*像一个对话框?
- python - 如何在没有外部模块的情况下跨 python 2 和 3 透明地处理字符串?