Configuration method of Frp intranet penetration in raspberry pie

Keywords: network vim github Linux

Material Science

Raspberry pie
 A server with public IP
 One filed domain name (not required)

Course

Prepare corresponding procedures

download
Download address: https://github.com/fate/frp/releases

 ## Server side
 wget https://github.com/fatedier/frp/releases/download/v0.32.0/frp_0.32.0_linux_386.tar.gz
 ##Client
 wget https://github.com/fatedier/frp/releases/download/v0.32.0/frp_0.32.0_linux_arm64.tar.gz

If the download is too slow on linux, you can download it first and upload it to linux.
decompression
Enter the directory where the file is located
Enter the command to unzip and enter the folder

##Server linux ECS
tar zxvf frp_0.32.0_linux_386.tar.gz 
cd frp_0.32.0_linux_386/
##Client raspberry pie
 tar zxvf frp_0.32.0_linux_arm64.tar.gz 
 cd frp_0.32.0_linux_arm64/

Description of some main documents

file function
frps Server run file
frpc Client run file
frps.ini Server profile
frpc.ini Client profile
frps_full.ini Server profile description
frpc_full.ini Client profile description

Configure server

Configuration file details: https://blog.csdn.net/gzqiang08/article/details/82848267

vim frps.ini
[common]
bind_port = Communication port between server and client
allow_ports = Specify the range of ports that clients can use, such as (2000-3000,4000,5000-6000)
vhost_http_port = The external network accesses this port and maps to the internal network's http service
vhost_https_port = The external network accesses this port and maps to the internal network's https service

subdomain_host = Allow clients to customize subdomain names, such as frps.com ,Need to resolve to pan domain name

dashboard_port = console port 
dashboard_user = Console user name
dashboard_pwd = Console Password 

privilege_token = Identity key, which needs to be the same when the client connects

Note: if the error is reported during startup, please check the software version, which must be consistent with the actual operating system

The open port needs to be opened in the security group of the ECS

Configure clients

vim frpc.ini
[common]
server_addr = server address
server_port = And server bind_port identical
privilege_token =Identity key
[ssh]
type = tcp
local_ip = Local area network of raspberry pie
local_port = 22 Service port
remote_port = 6000 Internet access port

[web]
type = http
local_port = 80#Service port
subdomain = Custom subdomain names such as( web)
#custom_domains = domain name or public IP, choose one from subdomain

 [web2]
type = http
local_port = 8080#Service port
custom_domains = Custom subdomain

SSH connection
Connect through public IP: remote? Port port
Access Web Services
When there is no domain name to access the web, use http://IP: the HTTP mapping port of the server
When there is a domain name, it is accessed through the http://(subdomain).subdomain_host:http port.

Boot from boot

Write startup script

Server script

vim frps.sh


#!/bin/bash                                                         
### BEGIN INIT INFO
# Provides:       frps
# Required-Start: $network 
# Required-Stop:  $all
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6
# Short-Description:  run frps
# Description:    run frps
### END INIT INFO

logfile=/root/log/frps.log

case "$1" in
 start)
         echo $(date) "start" >> $logfile        
         /etc/frp/frps -c /etc/frp/frps.ini >> $logfile &
 ;;  
 stop)
        echo $(date) 'stop' >> $logfile
        killall /etc/frp/frps -c /etc/frp/frps.ini        
 ;;
 restart)
        echo $(date) 'restart' >> $logfile
        killall /etc/frp/frps -c /etc/frp/frps.ini        
        /etc/frp/frps -c /etc/frp/frps.ini >> $logfile &
 ;;
 reload)
        echo$(date)  'reload' >> $logfile
 ;;
status)
        ps aux | grep /etc/frp/frps.ini 
;;
 *)
         echo "Usage: touchfile.sh <start|stop|restart|reload>" 
 ;;
 esac
 exit 0

Add execution permission and create soft connection to init.d folder, add boot entry

 chmod 755 frps.sh
 ln -s /root/autorun/frps.sh /etc/init.d/frps #Absolute path must be used
 update-rc.d frps defaults

Manual start method

cd /etc/init.d
./frpc start

Client script

vim frpc.sh


#!/bin/bash                                                         
### BEGIN INIT INFO
# Provides:       frpc
# Required-Start: $network 
# Required-Stop:  $all
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6
# Short-Description:  run frpc
# Description:    run frpc
### END INIT INFO

logfile=/root/log/frpc.log

case "$1" in
 start)
         echo $(date) "start" >> $logfile    
         /etc/frp/frpc -c /etc/frp/frpc.ini >> $logfile &
 ;;  
 stop)
        echo $(date) 'stop' >> $logfile
        killall /etc/frp/frpc -c /etc/frp/frpc.ini    
 ;;
 restart)
        echo $(date) 'restart' >> $logfile
        killall /etc/frp/frpc -c /etc/frp/frpc.ini   
        /etc/frp/frpc -c /etc/frp/frpc.ini >> $logfile &
 ;;
 reload)
        echo$(date)  'reload' >> $logfile
 ;;
status)
        ps aux | grep /etc/frp/frpc.ini
;;
 *)
         echo "Usage: touchfile.sh <start|stop|restart|reload>" 
 ;;
 esac
 exit 0

Add execution permission and create soft connection to init.d folder, and add boot entry

 chmod 755 frpc.sh
 ln -s /root/autorun/frpc.sh /etc/init.d/frpc #Absolute path must be used
 update-rc.d frpc defaults

Manual start method

cd /etc/init.d
./frpc start
Published 7 original articles, won praise 2, visited 1191
Private letter follow

Posted by gunabalans on Tue, 17 Mar 2020 00:42:56 -0700