Intranet penetration technology FRP combat

1 the concept

1.1 Official Documents

Document making

1.2 What is FRP?

FRP is a high-performance reverse proxy application that focuses on Intranet penetration and supports various protocols such as TCP, UDP, HTTP, and HTTPS. Intranet services can be exposed to the public network in a secure and convenient manner through the forwarding of nodes with public IP addresses.

1.3 Why is FRP used?

By deploying the FRP server on a node with a public IP address, Intranet services can be easily penetrated to the public network and professional functions and features are provided, including:

  • Client-server communication supports TCP, KCP, and Websocket.
  • TCP connection multiplexing is adopted to carry more requests between a single connection and save connection establishment time.
  • Load balancing between agent groups.
  • Ports are overused. Multiple services are exposed through the same server port.
  • Multiple natively supported client plug-ins (static file viewing, HTTP, SOCK5 proxy, etc.) make it easy to do some work with the FRP client independently.
  • Highly extensible server plug-in system, easy to combine their own requirements for functional expansion.
  • UI pages of the server and client.

1.4 the principle

The FRP consists of a client (FRPC) and a server (FRPS). The server is usually deployed on a machine with a public IP address, and the client is usually deployed on the machine where the Intranet service to be penetrated resides.

Intranet services cannot be accessed by non-LAN users because they do not have public IP addresses.

After a user accesses the FRPS on the server, the FRP routes the request to the corresponding Intranet machine according to the requested port or other information, thus realizing communication.

2 Install and configure the server

2.1 Downloading the FRP Installation Package

Prerequisites The server must have a public IP address. Download the latest Linux version from the Github Release page:

Github.com/fatedier/fr…

Log in to a server with a public IP address through SSH. I am using an Aliyun ECS here.

mkdir -p /opt/frp-server
cd/ opt/FRP - server wget https://github.com/fatedier/frp/releases/download/v0.35.1/frp_0.35.1_linux_amd64.tar.gz tar ZXF Frp_0. 35.1 _linux_amd64. Tar. Gz mv frp_0. 35.1 _linux_amd64 FRPcd frp
Copy the code

2.2 configuration

vim frps.ini

[common]
bind_port = 7000
token = frp2021
Copy the code

The token here is your plaintext password, please customize.

Set automatic startup upon startup:

cp systemd/frps.service /usr/lib/systemd/system/
vim /usr/lib/systemd/system/frps.service
Copy the code

Change the boot path:

ExecStart=/opt/frp-server/frp/frps -c /opt/frp-server/frp/frps.ini
Copy the code
systemctl daemon-reload
systemctl enable frps
Copy the code

Start the service:

systemctl start frps
ps -ef | grep frps
nobody    421370       1  1 12:27 ?        00:00:00 /opt/frp-server/frp/frps -c /opt/frp-server/frp/frps.ini
Copy the code

Open port 7000 in the security group configuration controlled by Aliyun:

Port 6022 is a remote port for the Intranet service to be opened. For convenience, you can open a group of ports, such as 6000-7000, when you open the security group ports.

3 Client configuration

3.1 Installing CentOS7 VMS

Install a vm on the same network segment that requires service opening to build the FRP client or use a small server with low configuration. CentOS7.6 is recommended.

3.2 Installation and Configuration

Similarly download the URL in the above server configuration:

mkdir -p /opt/frp-client
cd/ opt/FRP - client wget https://github.com/fatedier/frp/releases/download/v0.35.1/frp_0.35.1_linux_amd64.tar.gz tar ZXF Frp_0. 35.1 _linux_amd64. Tar. Gz mv frp_0. 35.1 _linux_amd64 FRPcd frp
Copy the code
Vim frpc.ini [common] server_addr = 114.114.114.114 server_port = 7000 token = frp2021 [SSH]typeLocal_ip = 192.168.0.102 local_port = 22 Remote_port = 6022Copy the code

Notes:

  • Server_addr specifies the public IP address or domain name of the server (assuming you resolved the domain name).
  • The token must be the same as that configured on the server
  • The following [SSH] configuration segment is the Intranet service that needs to be penetrated. The following uses port 22 of the FRP server as an example

Set automatic startup upon startup:

cp systemd/frpc.service /usr/lib/systemd/system/
vim /usr/lib/systemd/system/frpc.service
Copy the code

Change the boot path:

ExecStart=/opt/frp-client/frp/frpc -c /opt/frp-client/frp/frpc.ini
ExecReload=/opt/frp-client/frp/frpc reload -c /opt/frp-client/frp/frpc.ini
Copy the code
systemctl daemon-reload
systemctl enable frpc
Copy the code

Start the service:

systemctl start frpc
ps -ef | grep frpc
nobody    1650     1  0 23:49 ?        00:00:00 /opt/frp-client/frp/frpc -c /opt/frp-client/frp/frpc.ini
Copy the code

4 test

Next, use the phone to connect to the 4/5G network to connect to the Intranet server through port 6022 of that public IP address.