Chinaunix
标题:
iptables如何将本地端口访问重定向到其他外部IP指定端口?
[打印本页]
作者:
bend
时间:
2006-05-15 14:17
标题:
iptables如何将本地端口访问重定向到其他外部IP指定端口?
我有两台机器,
A---------------B
我想让别人访问我的A:80端口时,重定向到B:8080端口上,请问,这应怎么做?A和B都只有一块网卡。
我在A上试过用
iptables -A PREROUTING -t nat -p tcp --dport 8999 -j DNAT --to-destination 192.168.10.18:80 #192.168.10.18是B的IP
但怎么也不成功,请各位帮忙,谢谢
作者:
bend
时间:
2006-05-15 14:43
解决了,用这个可以:
-A PREROUTING -d 192.168.10.113 -p tcp -m tcp --dport 8999 -j DNAT --to-destination 192.168.10.18:80
-A POSTROUTING -d 192.168.10.18 -p tcp -m tcp --dport 80 -j SNAT --to-source 192.168.10.113
谢谢各位
作者:
springwind426
时间:
2006-05-15 16:36
-A PREROUTING -d 192.168.10.113 -p tcp -m tcp --dport 8999 -j DNAT --to-destination 192.168.10.18:80
-A POSTROUTING -j MASQUERADE
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2