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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值