LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2268|回复: 18

如何实现端口映射(重定向)

[复制链接]
发表于 2005-8-12 22:04:18 | 显示全部楼层 |阅读模式
192.168.1.247的80端口上运行着apache。
完成这样的效果:
通过http://192.168.1.245:8080可以 ... 7:80上的内容。
用iptables搞了很久还搞不掂。。请知道的兄弟帮一下忙。。

谢谢。
发表于 2005-8-12 23:06:23 | 显示全部楼层
Post by zhhxie
192.168.1.247的80端口上运行着apache。
完成这样的效果:
通过http://192.168.1.245:8080可以 ... 7:80上的内容。
用iptables搞了很久还搞不掂。。请知道的兄弟帮一下忙。。

谢谢。

User SSH port forwarding

  1. ssh username@192.168.1.247 -N -L 8080:192.168.1.247:80
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-12 23:11:52 | 显示全部楼层

it could not works

谢谢!

我按照您所说的方法做,但还是不行。。

我想应该是用iptables做比较合适吧,至少是效率方面。。
能再帮我想想吗?
回复 支持 反对

使用道具 举报

发表于 2005-8-12 23:27:21 | 显示全部楼层
Post by zhhxie
谢谢!

我按照您所说的方法做,但还是不行。。

我想应该是用iptables做比较合适吧,至少是效率方面。。
能再帮我想想吗?

I don't know if you can use iptables since they are in the same network, so you can't apply the NAT table. SSH tunnel should be the easiest and most security way and it just works. I've used it for a long time. Can you find out what's the error message?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-13 00:31:33 | 显示全部楼层

i see

明白您的意思。。。

那有什么办法可以做到:
221.96.27.87:8000 -> 220.194.59.216:80
回复 支持 反对

使用道具 举报

发表于 2005-8-13 12:12:42 | 显示全部楼层
Post by zhhxie
明白您的意思。。。

那有什么办法可以做到:
221.96.27.87:8000 -> 220.194.59.216:80


the same. use ssh tunnelling. Security and stable
回复 支持 反对

使用道具 举报

发表于 2005-8-13 12:36:09 | 显示全部楼层
iptables -t nat -A PREROUTING --protocol tcp --destination 192.168.1.245 --dport 8080 -j DNAT --to-destination 192.168.1.247:80
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-13 12:44:17 | 显示全部楼层

still not works

my steps

1. start apache(listening port 80) on 192.168.1.247.

2. login 192.168.1.245, and execute:
ssh username@192.168.1.247 -N -L 8080:192.168.1.247:80
and input the password for [username]

3. could not connect 192.168.1.245:8080, and i use:
nmap 192.168.1.245
could not find port 8080 openning

you mean the ssh tunnel, not the IP Tunnel?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-13 12:46:16 | 显示全部楼层

syntax error

Post by daemeon
iptables -t nat -A PREROUTING -j DNAT --to-destination 192.168.1.247:80 -p tcp --dport 8080



[root@localhost ~]# iptables -t nat -A PREROUTING -j DNAT --to-destination 192.168.1.247:80 -p tcp --dport 8080
iptables v1.2.11: Need TCP or UDP with port specification
Try `iptables -h' or 'iptables --help' for more information.
回复 支持 反对

使用道具 举报

发表于 2005-8-13 12:56:15 | 显示全部楼层
已经更正了
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表