VPN或者NAT过来的流量怎么转发到指定端口出去?

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
回复
winok
帖子: 27
注册时间: 2012-06-12 14:22

VPN或者NAT过来的流量怎么转发到指定端口出去?

#1

帖子 winok » 2015-11-10 16:50

通过配置ss-redi和防火墙,可以实现本机直接通过ss-redi的端口访问长城外,但VPN和NAT(其他电脑填写本机做网关的方法),过来的流量就不行了,请问在IPTABLES中有办法做这两个流量的指定端口转发吗??谢谢!!

以下是本机通过7070端口访问长城的IPTABLES配置,而PPTP(VPN)需要配置“iptables -t nat -A POSTROUTING -s 10.100.0.0/24 -o eth0 -j MASQUERADE”才能访问外网,而不能把指定流量转发到7070端口。

代码: 全选

iptables -t nat -N SOCKS
iptables -t nat -A SOCKS -d 59.188.236.196 -j RETURN
iptables -t nat -A SOCKS -d 106.186.126.173 -j RETURN
iptables -t nat -A SOCKS -d 0.0.0.0/8 -j RETURN
iptables -t nat -A SOCKS -d 10.0.0.0/8 -j RETURN
iptables -t nat -A SOCKS -d 127.0.0.0/8 -j RETURN
iptables -t nat -A SOCKS -d 169.254.0.0/16 -j RETURN
iptables -t nat -A SOCKS -d 172.16.0.0/12 -j RETURN
iptables -t nat -A SOCKS -d 192.168.0.0/16 -j RETURN
iptables -t nat -A SOCKS -d 224.0.0.0/4 -j RETURN
iptables -t nat -A SOCKS -d 240.0.0.0/4 -j RETURN
iptables -t nat -A SOCKS -p tcp -j REDIRECT --to-ports 7070
iptables -t nat -A OUTPUT -p tcp -j SOCKS
如果可以,请问要把NAT或者VPN(PPTP)的流量转发到端口7070的规则要怎么设置?谢谢!
头像
lilydjwg
论坛版主
帖子: 4258
注册时间: 2009-04-11 23:46
系统: Arch Linux
联系:

Re: VPN或者NAT过来的流量怎么转发到指定端口出去?

#2

帖子 lilydjwg » 2015-11-10 19:35

代码: 全选

iptables -t nat -I PREROUTING -p tcp -s 192.168.1.123 -j REDIRECT --to-ports 7070
把来自 192.168.1.123 的流量重定向到 7070 端口。要求程序在来源网络接口上监听,比如监听 192.168.1.100(本机在那个网络的地址)或者 0.0.0.0。
回复