樹莓派:配置frp進行內網穿透
1、日誌目錄創建
在根目錄創建frp文件夾,用於保存日誌信息
sudo mkdir /home/swlog
2、複製文件
#複製執行文件
sudo cp frpc /usr/local/bin/frpc
#更改權限
sudo chmod 777 /usr/local/bin/frpc
#創建配置目錄
sudo mkdir /usr/local/etc/frpc
#複製配置文件
sudo cp frpc.ini /usr/local/etc/frpc/frpc.ini
sudo chmod 777 /usr/local/etc/frpc/frpc.ini
# [common] is integral section
[common]
# A literal address or host name for IPv6 must be enclosed
# in square brackets, as in "[::1]:80", "[ipv6-host]:http" or "[ipv6-host%zone]:80"
server_addr = frp.jlauiot.com
server_port = 6666
# if you want to connect frps by http proxy or socks5 proxy, you can set http_proxy here or in global environment variables
# it only works when protocol is tcp
# http_proxy = http://user:[email protected]:8080
# http_proxy = socks5://user:[email protected]:1080
# console or real logFile path like ./frpc.log
log_file = /home/swlog/frpc.log
# trace, debug, info, warn, error
log_level = info
log_max_days = 3
# disable log colors when log_file is console, default is false
disable_log_color = false
# for authentication
token = tokensworld
# set admin address for control frpc's action by http api such as reload
#admin_addr = 127.0.0.1
#admin_port = 7400
#admin_user = admin
#admin_pwd = admin
# Admin assets directory. By default, these assets are bundled with frpc.
# assets_dir = ./static
# connections will be established in advance, default value is zero
#pool_count = 5
# if tcp stream multiplexing is used, default is true, it must be same with frps
tcp_mux = true
# your proxy name will be changed to {user}.{proxy}
user = JLAU0002-Node-03
# decide if exit program when first login failed, otherwise continuous relogin to frps
# default is true
login_fail_exit = true
# communication protocol used to connect to server
# now it supports tcp and kcp and websocket, default is tcp
protocol = tcp
# if tls_enable is true, frpc will connect frps by tls
#tls_enable = true
# specify a dns server, so frpc will use this instead of default one
# dns_server = 8.8.8.8
# proxy names you want to start seperated by ','
# default is empty, means all proxies
# start = ssh,dns
# heartbeat configure, it's not recommended to modify the default value
# the default value of heartbeat_interval is 10 and heartbeat_timeout is 90
# heartbeat_interval = 30
# heartbeat_timeout = 90
# 'ssh' is the unique proxy name
# if user in [common] section is not empty, it will be changed to {user}.{proxy} such as 'your_name.ssh'
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 20001
[mjpg]
type = tcp
local_ip=127.0.0.1
local_port=8081
remote_port=29001
[web]
type = tcp
local_ip= 127.0.0.1
local_port= 8000
remote_port=28001
3、編寫frpc service文件
sudo nano /usr/lib/systemd/system/frpc.service
內容如下
[Unit]
Description=frpc
After=network.target
[Service]
TimeoutStartSec=10
Restart=always
RestartSec=10
ExecStart=/usr/local/bin/frpc -c /usr/local/etc/frpc/frpc.ini
ExecStop=/bin/kill $MAINPID
[Install]
WantedBy=multi-user.target
4、啓動frp並設置開機自啓
# 啓動 frp 並設置開機啓動
sudo systemctl enable frpc
sudo systemctl start frpc
sudo systemctl status frpc