Chiloh

Chiloh Wei

一个尝试理解世界,理解自己的人
jike
twitter

Frp internal network penetration

I have always wanted to be able to remotely access my home computer and transfer files at any time while at the office or on a business trip. After considering many methods, I ultimately chose the Frp internal network penetration service based on the Alibaba Cloud ECS server I am using, which has a public IP address. I have basically achieved the requirement of accessing my home Windows computer anytime and anywhere.

1. Server Configuration#

Taking a CentOS server as an example, the Frps server configuration tutorial is as follows:

1. Install Go Environment#

Frp is based on the Go language, so refer to this tutorial: https://golang.org/doc/install#requirements, and first install the Go language and configure the environment on Linux.

2. Install Frps and Start#

Here, I recommend the Frp server one-click script, which is simpler than configuring from source code. You just need to follow the prompts and enter the corresponding port numbers.

+------------------------------------------------------------+
|   frps for Linux Server, Author Clang, Mender MvsCode     |
|      A tool to auto-compile & install frps on Linux        |
+------------------------------------------------------------+

Check your server setting, please wait...

+------------------------------------------------------------+
|   frps for Linux Server, Author Clang, Mender MvsCode     |
|      A tool to auto-compile & install frps on Linux        |
+------------------------------------------------------------+


Please select frps download url:
[1].aliyun 
[2].github (default)
Enter your choice (1, 2 or exit. default [github]): 1
-----------------------------------
       Your select: 1    
-----------------------------------
Loading network version for frps, please wait...
frps Latest release file frp_0.34.3_linux_amd64.tar.gz
Loading Your Server IP, please wait...
Your Server IP:your_vps_ip
————————————————————————————————————————————
     Please input your server setting:
————————————————————————————————————————————

Please input frps bind_port [1-65535](Default Server Port: 5443):
frps bind_port: 5443


Please input frps vhost_http_port [1-65535](Default : 80):8080
frps vhost_http_port: 8080


Please input frps vhost_https_port [1-65535](Default : 443):8888
frps vhost_https_port: 8888


Please input frps dashboard_port [1-65535](Default : 6443):
frps dashboard_port: 6443


Please input frps dashboard_user(Default : admin):chiloh
frps dashboard_user: chiloh


Please input frps dashboard_pwd(Default : N2qeE26x):chiloh-wei
frps dashboard_pwd: chiloh-wei


Please input frps token(Default : p57D0IwDHL3LwpJC):your_token
frps token: your_token


Please input frps subdomain_host(Default : your_vps_ip):
frps subdomain_host: your_vps_ip


Please input frps max_pool_count [1-200]
(Default : 50):
frps max_pool_count: 50

Please select log_level
1: info (default)
2: warn
3: error
4: debug
-------------------------
Enter your choice (1, 2, 3, 4 or exit. default [1]): 
log_level: info


Please input frps log_max_days [1-30]
(Default : 3 day):
frps log_max_days: 3

Please select log_file
1: enable (default)
2: disable
-------------------------
Enter your choice (1, 2 or exit. default [1]): 
log_file: enable

Please select tcp_mux
1: enable (default)
2: disable
-------------------------
Enter your choice (1, 2 or exit. default [1]): 
tcp_mux: true

Please select kcp support
1: enable (default)
2: disable
-------------------------
Enter your choice (1, 2 or exit. default [1]): 
kcp support: true

============== Check your input ==============
Your Server IP      : your_vps_ip
Bind port          : 5443
kcp support        : true
vhost http port    : 8080
vhost https port   : 8888
Dashboard port     : 6443
Dashboard user     : chiloh
Dashboard password : chiloh-wei
token              : your_token
subdomain_host     : your_vps_ip
tcp_mux            : true
Max Pool count     : 50
Log level          : info
Log max days       : 3
Log file           : enable
==============================================

Press any key to start...or Press Ctrl+c to cancel
frps install path:/usr/local/frps
config file for frps ... done
download frps ... done
download /etc/init.d/frps... done
setting frps boot... done

+---------------------------------------------------------+
|     Manager for Frps, Author Clang, Mender MvsCode      |
+---------------------------------------------------------+

Starting Frps(0.34.3)... done
Frps (pid 31075) is running.

+------------------------------------------------------------+
|   frps for Linux Server, Author Clang, Mender MvsCode     |
|      A tool to auto-compile & install frps on Linux        |
+------------------------------------------------------------+


Congratulations, frps install completed!
================================================
Your Server IP      : your_vps_ip
Bind port          : 5443
KCP support        : true
vhost http port    : 8080
vhost https port   : 8888
Dashboard port     : 6443
token              : your_token
subdomain_host     : your_vps_ip
tcp_mux            : true
Max Pool count     : 50
Log level          : info
Log max days       : 3
Log file           : enable
================================================
frps Dashboard     : http://your_vps_ip:6443/
Dashboard user     : chiloh
Dashboard password : chiloh-wei
================================================

frps status manage : frps {start|stop|restart|status|config|version}
Example:
  start: frps start
   stop: frps stop
restart: frps restart

Note: If you are using a service provider like Alibaba Cloud, you need to allow the ports configured in the above script in the server's security group.

2. Client Configuration#

The client configuration method is similar to the server side, with the following steps:

1. Install Frp Client and Start#

  • Download the latest Windows version of the Frp compressed package from this page: https://github.com/fatedier/frp/releases.
  • Unzip frpc.ini and frpc.exe to a directory on Windows, for example, D:\frp.
  • Edit the client configuration file frpc.ini according to the code below.
[common]
# Public address of the VPS
server_addr = your_vps_ip
# Previously configured frps bind_port
server_port = 5443
# Previously configured frps token
token=your_token
# Name can be anything
[RDP]
# Type remains tcp
type = tcp
# Local address remains unchanged
local_ip = 127.0.0.1
# Windows remote port 3389 remains unchanged
local_port = 3389
# Port accessed when remote, value [1024-65535]
remote_port = 6000

2. Configure Frp Client to Start Automatically#

After configuring the server, it is best to set it to start automatically, so that the service will run in the background when the Windows computer is turned on. The specific steps are as follows:

  • Download winsw and rename it to winsw.exe.
  • Create a new winsw.xml format file and write the following content:
<service>
    <id>frp</id>
    <name>frpc</name>
    <description>chiloh's frpc</description>
    <executable>frpc</executable>
    <arguments>-c frpc.ini</arguments>
    <onfailure action="restart" delay="60 sec"/>
    <onfailure action="restart" delay="120 sec"/>
    <logmode>reset</logmode>
</service>
  • Create a registration.bat file and write the following content:
@echo off
if exist "%SystemRoot%\SysWOW64" path %path%;%windir%\SysNative;%SystemRoot%\SysWOW64;%~dp0
bcdedit >nul
if '%errorlevel%' NEQ '0' (goto UACPrompt) else (goto UACAdmin)
:UACPrompt
%1 start "" mshta vbscript:createobject("shell.application").shellexecute("""%~0""","::",,"runas",1)(window.close)&exit
exit /B
:UACAdmin
cd /d "%~dp0"
echo Current running path is: %CD%
echo Admin privileges obtained

winsw install
winsw start
  • Create an uninstall.bat file and write the following content:
@echo off
if exist "%SystemRoot%\SysWOW64" path %path%;%windir%\SysNative;%SystemRoot%\SysWOW64;%~dp0
bcdedit >nul
if '%errorlevel%' NEQ '0' (goto UACPrompt) else (goto UACAdmin)
:UACPrompt
%1 start "" mshta vbscript:createobject("shell.application").shellexecute("""%~0""","::",,"runas",1)(window.close)&exit
exit /B
:UACAdmin
cd /d "%~dp0"
echo Current running path is: %CD%
echo Admin privileges obtained

winsw stop
winsw uninstall
  • Double-click to run the registration.bat file to register the service. After that, you can access the internal Windows computer using the format ip+remote_port.

Frp Remote Desktop Connection

3. Overall Experience#

The process of setting up Frp is not very difficult when using scripts; the biggest requirement is probably having a public IP address. Additionally, buying a smart plug for home that automatically powers on the computer can allow remote control of the computer's power. After the computer is turned on, the internal network penetration service starts automatically, and as long as there is internet access, you can use a tablet or computer to access your home computer for remote operation or file transfer.

Reference Articles:

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.