端口转发
本地转发
用于发送
本地端口转发(Local Port Forwarding)
发送到本地端口的请求,转发到目标端口
1 |
|
-
listen to port on the local side 监听本地连接
-
optionally bound to the specified bind_address
-
与此端口建立连接时,该连接都会通过安全通道转发,将流量转发到远程host的hostport
-
The bind_address of “localhost” indicates that the listening port 本地使用, while an empty address or ‘*’ indicates that the port should be available from all interfaces.
应用:远程主机端口服务没有对外开放,使用可以直接
1 |
|
然后本地直接向对应端口发送数据就可以了
remote_host 可以任一主机
跳板机
目标: host1 连接 host2
1 |
|
远程转发
用于接收
远程端口转发(Remote Port Forwarding)
将发送到远程端口的请求,转发到目标端口
1 |
|
过程和上面差不多
应用:host不能连接外网,需要在中转机器运行命令
应用
背景: 内网访问不了外网,me只能访问host1。
target: host1 和 hosts2 可以访问remote
host1:host1_port –> me –> remote:remote_port
1 |
|
host2_port–>host1:host1_port –> me –> remote:remote_port
1 |
|
host1和host2 都通过remote域名访问 修改/etc/hosts
把127.0.0.1 remote