当前位置:网站首页>移动办公时如何使用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秒不到
边栏推荐
- 一文带你吃透js处理树状结构数据的增删改查
- Data communication foundation - route republication
- Why should we learn mathematical modeling?
- list去重并统计个数
- Nine hours, nine people, nine doors problem solving Report
- [brief notes] solve the problem of IDE golang code red and error reporting
- RLock锁的使用
- Example project: simple hexapod Walker
- CSDN I'm coming
- 【簡記】解决IDE golang 代碼飄紅報錯
猜你喜欢

Analytic hierarchy process of mathematical modeling (including Matlab code)

vant tabbar遮挡内容的解决方式

Vulnhub-Moneybox

Research and practice of super-resolution technology in the field of real-time audio and video

ES6深入—ES6 Class 类

Intelligent metal detector based on openharmony

keep-alive

sql中set标签的使用

Mistakes made when writing unit tests

【簡記】解决IDE golang 代碼飄紅報錯
随机推荐
F. Min cost string problem solving Report
Relationship between objects and classes
MySQL5.7的JSON基本操作
Exception com alibaba. fastjson. JSONException: not match : - =
Value series solution report
Use of RLOCK lock
Modify PyUnit_ Time makes it support the time text of 'xx~xx months'
研发效能度量指标构成及效能度量方法论
19.[STM32]HC_ SR04 ultrasonic ranging_ Timer mode (OLED display)
20. [stm32] realize the function of intelligent garbage can by using ultrasonic module and steering gear
【簡記】解决IDE golang 代碼飄紅報錯
Advanced level of static and extern
抽象类和接口的区别
Query the latest record in SQL
This article takes you through the addition, deletion, modification and query of JS processing tree structure data
项目sql中批量update的时候参数类型设置错误
力扣今日题-729. 我的日程安排表 I
Defining strict standards, Intel Evo 3.0 is accelerating the upgrading of the PC industry
Codasip为RISC-V处理器系列增加Veridify安全启动功能
通过的英特尔Evo 3.0整机认证到底有多难?忆联科技告诉你