隧道穿透技术笔记

参考博客:

https://cherrot.com/tech/2017/01/08/ssh-tunneling-practice.html

https://blog.creke.net/722.html

https://www.ibm.com/developerworks/cn/linux/l-cn-sshforward/index.html

https://github.com/timest/blog/issues/5


1.”动态“端口转发(SOCKS代理,可以用于FQ):

ssh -D 1080 目标主机IP  //如果目标主机可以访问Google,在建立隧道后,将代理设置为localhost的1080端口,就可以访问外网了。

2.本地端口转发(可以通过内网主机登录远程主机)
ssh -L 2222:localhost:22 远程主机IP  #通过本地2222端口访问远程ssh服务器,这里-L参数中的IP,可以是本机IP,也可以是远程主机IP


3.远程端口转发(可以通过外网主机访问内网主机,也可以说是内网穿透)

ssh -R 8080:localhost:80 远程主机IP
如何将端口绑定到外部地址上

使用上面的方法,映射的端口只能绑定在127.0.0.1这个接口上。也就是说,只能被本机自己访问到。如何才能让其他机器访问这个端口呢?我们可以把这个映射的端口绑定在0.0.0.0的接口上,方法是加上参数-b 0.0.0.0。同时还需要打开SSH服务器端的一个选项-GatewayPorts。默认情况下它应当是被打开的。如果被关闭的话,可以在/etc /sshd_config中修改GatewayPorts no为GatewayPorts yes来打开它。

#如果你在VMware里面,遇到了【packet_write_wait: Connection to 154.xxx.xxx.xxx port 223: Broken pipe】这个问题,可以使用

[ssh -o IPQoS=throughput -R 远程主机端口:localhost:本地主机端口 [email protected] ]命令

答案来源:https://unix.stackexchange.com/questions/259225/packet-write-wait-broken-pipe-even-leaving-top-running

猜你喜欢

转载自www.cnblogs.com/blogs-1024/p/11296621.html