VPS配合Frp实现内网穿透使用windows远程桌面
2018-03-30 00:08
1991 查看
windows远程桌面连接时,要么两台主机再同一个局域网,要么目标主机必须有外网IP。然而很多情况下,我们的主机都是没有外网IP的,因此我通过Frp和一个具有外网Ip的vps实现内网穿透进而进行远程桌面。
一些商家会提供免费vps,但我不是很放心,因此用购买的Vps搭建。
Vultr购买Vps的方式参考:https://blog.csdn.net/linlinlin96/article/details/79750867
首先将目标主机的远程桌面打开并配置防火墙,这里不再细说。
进入frp所在的目录:
使用命令
设置完成,后台运行frps并将日志写入logs文件:
可以使用如下命令实时查看日志文件:
服务器端配置完成!
https://github.com/fatedier/frp/releases/download/v0.16.1/frp_0.16.1_windows_amd64.zip
修改
其中:
然后运行
[W] [control.go:109] login to server failed: dial tcp 108.61.23.7:7000: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
dial tcp 108.61.23.7:7000: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
这时说明服务器的防火墙没有打开该端口,参考Vultr文档:
https://www.vultr.com/docs/install-wordpress-with-apache-php-and-mysql-automated-startup-script
注意到以下关于防火墙的命令:
我们需要将7000(服务器端中的bind_port)端口放行,再vps中输入以下命令:
然后重新连接windows客户端
连接成功!
现在就可以用
最后推荐lanproxy,是github上的一个项目,用于内网穿透,使用很方便。我因为仅使用远程桌面,frp够用,再加上配置lanproxy时遇到一些坑还没有解决,故暂且不用。
一些商家会提供免费vps,但我不是很放心,因此用购买的Vps搭建。
Vultr购买Vps的方式参考:https://blog.csdn.net/linlinlin96/article/details/79750867
首先将目标主机的远程桌面打开并配置防火墙,这里不再细说。
部署Frp服务器端:
首先使用如下命令从官方github下载服务器端frp并解压:wget https://github.com/fatedier/frp/releases/download/v0.16.1/frp_0.16.1_linux_amd64.tar.gz tar -zxvf frp_0.16.1_linux_amd64.tar.gz
进入frp所在的目录:
cd frp_0.16.1_linux_amd64
使用命令
vi frps.ini修改
frps.ini文件:
[common] bind_port = 7000 privilege_token = xxxxxx dashboard_port = 7001 dashboard_user = user dashboard_pwd = 123456
privilege_token是特权模式下与客户端连接的密码
dashboard_port是web控制页面也可以不设置。
设置完成,后台运行frps并将日志写入logs文件:
./frps -c ./frps.ini -L logs &
可以使用如下命令实时查看日志文件:
tail -f logs
服务器端配置完成!
安装Frp客户端
下载windows版Frp:https://github.com/fatedier/frp/releases/download/v0.16.1/frp_0.16.1_windows_amd64.zip
修改
frpc.ini文件:
4000 [code][common] server_addr = xx.xx.xx.xx server_port = 7000 privilege_token = xxxxxx [RemoteDesktop] type = tcp local_addr = 127.0.0.1 local_port = 3389 remote_port = 7002
其中:
server_addr是外网vps的ip地址
server_port要与设置服务器端时的bind_port一致,
privilege_token与服务器端一致
remote_port注意不要冲突
然后运行
frpc.exe。
注意:
这里有一个坑,如果卡在以上界面,一段时间后报错,并且服务器logs没有任何响应:[W] [control.go:109] login to server failed: dial tcp 108.61.23.7:7000: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
dial tcp 108.61.23.7:7000: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
这时说明服务器的防火墙没有打开该端口,参考Vultr文档:
https://www.vultr.com/docs/install-wordpress-with-apache-php-and-mysql-automated-startup-script
注意到以下关于防火墙的命令:
##### Open firewall for http and SSL iptables -F iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT /etc/init.d/iptables save /etc/init.d/iptables restart
我们需要将7000(服务器端中的bind_port)端口放行,再vps中输入以下命令:
iptables -F iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -p tcp -m tcp --dport 7000 -j ACCEPT
然后重新连接windows客户端
连接成功!
现在就可以用
vps的ip:端口号连接远程桌面了(本文为
xx.xx.xx.xx:7002)。
最后推荐lanproxy,是github上的一个项目,用于内网穿透,使用很方便。我因为仅使用远程桌面,frp够用,再加上配置lanproxy时遇到一些坑还没有解决,故暂且不用。
相关文章推荐
- 使用xrdp实现Windows 远程桌面 Ubuntu Linux
- 使用cygwin X server实现Linux远程桌面 (for windows)
- 使用xrdp实现windows 远程桌面 ubuntu linux
- 树莓派-使用xrdp实现windows 远程桌面linux
- 23 使用 cygwin X server实现Linux远程桌面 (for windows)
- 使用xrdp实现Windows 远程桌面 Ubuntu Linux
- 使用cygwin X server实现Linux远程桌面 (for windows)
- 使用xrdp+vnc实现windows图形化远程Ubuntu桌面(支持多用户模式)
- 使用xrdp实现windows 远程桌面 ubuntu linux
- 使用xrdp实现windows 远程桌面 ubuntu linux
- 使用xrdp实现windows 远程桌面 ubuntu linux
- windows 2003 如何利用远程桌面来设置主机密码,或是直接使用主机声卡
- 在Windows远程桌面的不同会话之间,如何实现程序的互斥?
- 使用NAT让外网通过vncserver和windows 远程桌面某内网中的多个服务器且不冲突
- windows 自带远程桌面的使用
- 使用pscp实现Windows 和 linux服务器间远程拷贝文件
- VNCserver实现Windows下远程linux桌面
- 如何使用windows远程控制centOS桌面
- 如何使用windows远程控制centOS桌面
- 在Windows 7中使用tsmmc远程桌面