使用iptables做端口转发访问ftp nat
十月 19th, 2009 Posted in Iptables | 阅读次数: 606 次
制作:高进波
时间:2009-4-25
主题:使用iptables做端口转发访问ftp nat
用iptables做端口转发是个很实用的功能,可以让我们忽略协议细节而实现透明转发,对于加密的数据传输更是好用。
ftp协议不同于http协议,因为ftp的控制端口和数据端口是分离的,在被动模式下,数据端口是通过控制信息来商定的,所以我们不能简单地对21端口做转发。
注:假定我们是通过在 本机IP 上做NAT设置使 源IP 可以通过 本机IP 访问到 目标IP
1.iptables脚本
vi iptables_ftp_forward.sh
#!/bin/bash
echo "1">/proc/sys/net/ipv4/ip_forward #启用内核ip转发
#加载需要的模块
modprobe iptable_nat
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
#使用iptables转发
iptables -t nat -A POSTROUTING -d 目标ip -p tcp –dport 21 -j MASQUERADE
iptables -t nat -A PREROUTING -d 本机ip -p tcp –dport 21 -j DNAT –to-dest 目标IP:21
注: DNAT 修改目标IP,适用于PREROUTING
SNAT 修改源IP ,适用于POSTROUTING
完成
五月 9th, 2011 at 20:00
Interesting Article…
[...]some interesting sites worth visitng. We recommend all our readers go and check these out[...]……
八月 18th, 2011 at 11:24
Sites we Like………
[...] Every once in a while we choose blogs that we read. Listed below are the latest sites that we choose [...]………
八月 26th, 2011 at 01:41
IP Checking…
使用iptables做端口转发访问ftp nat | 高进波博客 – 零起点一步配置你的linux服务器,linux博客,linux教程,web架构…
九月 15th, 2011 at 13:06
Cool sites……
[...]we came across a cool site that you might enjoy. Take a look if you want[...]………