`
szpapas
  • 浏览: 105346 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

ipTables portforwarding 的安装方法

阅读更多
下面是ipTables 的安装方法,供日后参考。

Iptables 安装过程

1. 增加一个逻辑端口
Ifconfig lo:1 192.168.254.1 netmask 255.255.255.0

2. 修改iptables,增加DNAT的配置

iptables -t nat -F
iptables -t filter -F
iptables -A PREROUTING -t nat -p tcp --dport 80 -j DNAT --to 192.168.254.1:8800
iptables -A FORWARD -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

3. 修改redir 的配置
root@jack-laptop:~# cat /etc/rinetd.conf

# bindadress    bindport  connectaddress  connectport
192.168.254.1 8800 61.180.1.4 80

# logging information
logfile /var/log/rinetd.log

修改后sudo /et/init.d/rinetd restart

4. 现在打开http://218.64.79.106/ 可以打开Portal 页面
第一次NAT转换
root@jack-laptop:~# iptables -t nat -n -L -v
Chain PREROUTING (policy ACCEPT 7 packets, 316 bytes)
pkts bytes target     prot opt in     out     source               destination        
   45  2880 DNAT       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:80 to:192.168.254.1:8800

Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target     prot opt in     out     source               destination        
   45  2700 MASQUERADE  all  --  *      eth0    0.0.0.0/0            0.0.0.0/0          

Chain OUTPUT (policy ACCEPT 45 packets, 2700 bytes)
pkts bytes target     prot opt in     out     source               destination        

内部的Redir转换
root@jack-laptop:/var/log# tail -f rinetd.log
04/Jul/2009:22:34:18     210.74.155.90    192.168.254.1    8800    61.180.1.4    80    450    104    done-local-closed
04/Jul/2009:22:34:19     210.74.155.90    192.168.254.1    8800    61.180.1.4    80    452    104    done-local-closed
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics