当前位置:网站首页>移动办公时如何使用frp内网穿透+teamviewer方式快速连入家中内网主机
移动办公时如何使用frp内网穿透+teamviewer方式快速连入家中内网主机
2022-07-05 15:33:00 【yuanfan2012】
移动办公时如何使用frp内网穿透+teamviewer方式快速连入家中内网主机
之前有写过腾讯云主机上部署FRP+Teamviewer穿透内网进行远程运维
本文基于该文章做了进一步优化
一、场景描述
如图所示
(图片可点击放大查看)
家中有一台24小时开机的NUC
操作系统为VMware ESXi7.0虚拟化平台
上面部署了如下虚拟机
(图片可点击放大查看)
其中CentOS7.9 虚拟机上部署了frpc内网穿透客户端
将内网Win7虚拟机(192.168.31.239)的Teamviewer(端口为5938)映射到了公网的腾讯云服务器
frpc与frps配置部分截图
(图片可点击放大查看)
(图片可点击放大查看)
这时如果需要在外办公的笔记本想通过Teamviewer访问家中内网的Win7虚拟机 需要云主机firewalld开放5938端口
需要输入命令
firewall-cmd --permanent --zone=public --add-port=5938/tcp
firewall-cmd --reload
然后云主机安全组也放开5938端口
(图片可点击放大查看)
这样在外办公的笔记本随时随时,只用Teamviewer连接云主机公网IP即可访问家中Win7虚拟机
(图片可点击放大查看)
(图片可点击放大查看)
二、安全考量
但是基于安全考量:安全组0.0.0.0过大,担心会有安全风险
所以这时想实现只允许当前笔记本所在网络的公网IP加入5938端口安全组白名单中
但是这样每次都要登录云服务器控制台手动加白,操作过于麻烦,并且耗时费力,一次操作下来估计得2~3分钟不止
所以想到一个相当较安全的方式
1、云控制台上安全组还是保持5938端口 允许0.0.0.0/0的安全组规则
2、已经移除public zone全局开放的5938端口
firewall-cmd --permanent --zone=public --remove-port=5938/tcp
firewall-cmd --reload
3、通过firewalld的rich-rule来实现加白
SSH登录后who am i 查看当前笔记本的出口公网IP
并将此公网IP使用rich-rule加白
[[email protected] ~]# who am i
root pts/1 2022-06-19 20:04 (XX.XX.XX.XX)
[[email protected] ~]#
[[email protected] ~]# firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="XX.XX.XX.XX" port port="5938" protocol="tcp" accept'
success
[[email protected] ~]# firewall-cmd --reload
success
(图片可点击放大查看)
三、优化过程
能否将上面步骤的时间缩短一点呢?比如我在外办公的笔记本SSH登录一下云服务器执行个脚本就自动加白呢,这样是不是更方便
通过不断修改与反复测试脚本,最终实现了这一效果
脚本如下
[[email protected] ~]# vim teamviewer_add_loginIP.sh
[[email protected] ~]# cat teamviewer_add_loginIP.sh
#!/bin/bash
#清除Teamviewer_5938端口的历史rich-rules并重载
firewall-cmd --list-rich-rules| grep 5938 > /tmp/5938_richrules.txt
while read -r line
do
Temp_Rule=`echo $line`
echo $Temp_Rule
firewall-cmd --permanent --remove-rich-rule "$Temp_Rule"
firewall-cmd --reload
done < /tmp/5938_richrules.txt
#获取当前登陆服务器的IP地址,并对当前IP添加开放Teamviewer5938端口的rich-rule
LoginIP=$(who am i | awk '{print $5}' | sed 's/(//g' | sed 's/)//g')
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address='$LoginIP' port port="5938" protocol="tcp" accept'
firewall-cmd --reload
(图片可点击放大查看)
四、验证
在MacOS系统下使用方式
1、iTerm2下登录云服务器SSH(密钥方式免密登录)
2、执行脚本teamviewer_add_loginIP.sh
3、即可直接通过Teamviewer连接云服务器公网IP,即可连入家中Win7虚拟机 耗时10秒不到
边栏推荐
- Value series solution report
- Five common negotiation strategies of consulting companies and how to safeguard their own interests
- Data communication foundation smart_ Link_&_ Monitor_ Link
- 18.[STM32]读取DS18B20温度传感器的ROM并实现多点测量温度
- Subclasses and superclasses of abstract classes
- 抽象类中子类与父类
- [Netease Yunxin] research and practice of super-resolution technology in the field of real-time audio and video
- ES6深入—ES6 Class 类
- 通过的英特尔Evo 3.0整机认证到底有多难?忆联科技告诉你
- list去重并统计个数
猜你喜欢
Object. defineProperty() - VS - new Proxy()
The OBD deployment mode of oceanbase Community Edition is installed locally
17.[STM32]仅用三根线带你驱动LCD1602液晶
定义严苛标准,英特尔Evo 3.0正在加速PC产业升级
抽象类中子类与父类
Data communication foundation ACL access control list
SQL injection sqllabs (basic challenges) 11-20
[brief notes] solve the problem of IDE golang code red and error reporting
swiper. JS to achieve barrage effect
abstract关键字和哪些关键字会发生冲突呢
随机推荐
Exception com alibaba. fastjson. JSONException: not match : - =
基于OpenHarmony的智能金属探测器
Why should we learn mathematical modeling?
wyt 。。
超分辨率技术在实时音视频领域的研究与实践
This article takes you through the addition, deletion, modification and query of JS processing tree structure data
21.[STM32]I2C协议弄不懂,深挖时序图带你编写底层驱动
I'm fat, huh
CSDN I'm coming
Arduino控制微小的六足3D打印机器人
Obj resolves to a set
研发效能度量指标构成及效能度量方法论
Xiao Sha's arithmetic problem solving Report
Clock switching with multiple relationship
CODING DevSecOps 助力金融企业跑出数字加速度
修改pyunit_time使得其支持‘xx~xx月’的时间文本
Intelligent metal detector based on openharmony
D-snow halo solution
MySQL overview
Information collection of penetration test