FRP01-下载FRP
1.下载FRP
wget https://github.com/fatedier/frp/releases/download/v0.51.3/frp_0.51.3_linux_386.tar.gz
2.新建frp用户并配置sudoers权限用于处理FRP
useradd -md /home/frp frp
passwd
sed -i $(cat -n /etc/sudoers|grep 'root.*ALL=.*ALL'|awk '{print $1}')a'frp ALL=(ALL) ALL' /etc/sudoers
3.需要提前安装filezilla[因为github有可能连不上-可以通过上传获取]
sudo yum -y install epel-release
sudo yum install filezilla
4.解压tar包并配置
tar -xvf frp_0.51.3_linux_386.tar.gz
cd frp_0.51.3_linux_386/
vi frps.ini
修改配置
[common]
#服务通信端口
bind_port = 7000
#服务端认证token
token=${token}
#服务端管理界面端口
dashboard_port=7500
dashboard_user=${user}
dashboard_pwd=${pwd}
log_file = ./frps.log
log_level = info
log_max_days = 3
enable_prometheus = true
5.新建service文件设置开机自起
先生成文件
sudo touch frps.service
修改文件
[Unit]
Description=frps service
After=network.target syslog.target
Wants=network.target
[Service]
Type=simple
ExecStart=/home/frp/frp_0.51.3_linux_386/frps -c /home/frp/frp_0.51.3_linux_386/frps.ini
[Install]
WantedBy=multi-user.target
然后迁移到对应路径下
sudo cp frps.service /etc/systemd/system
sudo chmod 755 /etc/systemd/system/frps.service
启动并设置开机自起
sudo systemctl start frps.service
sudo systemctl enable frps.service
sudo systemctl status frps.service
8.解压客户端并配置客户端
tar -xvf frp_0.51.3_linux_386.tar.gz
vi frpc.ini
修改配置
[common]
token=dengliang
server_addr =
server_port = 7000
admin_addr=127.0.0.1
admin_port=7400
admin_user=${user}
admin_pwd=${pwd}
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port =
remote_port =
9.设置客户端开机自起
sudo touch frpc.service
修改文件
[Unit]
Description=frpc service
After=network.target syslog.target
Wants=network.target
[Service]
Type=simple
ExecStart=/home/frp/frp_0.51.3_linux_386/frpc -c /home/frp/frp_0.51.3_linux_386/frpc.ini
[Install]
WantedBy=multi-user.target
然后迁移到对应路径下
sudo cp frpc.service /etc/systemd/system
sudo chmod 755 /etc/systemd/system/frpc.service
启动并设置开机自起
sudo systemctl start frpc.service
sudo systemctl enable frpc.service
sudo systemctl status frpc.service
访问服务器端 7500 口 可以管理对应端口
客户端 7400 口 可以管理对应端口
服务器与客户端所在机器都需要防火墙开放对应端口[云服务器还要配置安全组]
必须确认客户端所在机器上配置的端口服务正常 [netstat -ntlp]
token=frpClientPrivacy
server_addr=$1
server_port=7000
admin_addr=127.0.0.1
admin_port=7400
admin_user=frp
admin_pwd=frp
type=tcp
local_ip=127.0.0.1
local_port=$2
remote_port=$3
# wget https://github.com/fatedier/frp/releases/download/v0.51.3/frp_0.51.3_linux_386.tar.gz
# useradd -md /home/frp frp
# passwd
# sed -i $(cat -n /etc/sudoers|grep 'root.*ALL=.*ALL'|awk '{print $1}')a'frp ALL=(ALL) ALL' /etc/sudoers
rm -rf frp_0.51.3_linux_386/
tar -xvf frp_0.51.3_linux_386.tar.gz
cd frp_0.51.3_linux_386/
sed -i 1a'token=dengliang' frpc.ini
sed -i s/'server_addr.*'/'server_addr='$1/ frpc.ini
sed -i s/'server_port.*'/'server_port='$2/ frpc.ini
sed -i 4a'admin_addr=127.0.0.1' frpc.ini
sed -i 5a'admin_port=7400' frpc.ini
sed -i 6a'admin_user=frp' frpc.ini
sed -i 7a'admin_pwd=frp' frpc.ini
sed -i s/'local_port.*'/'local_port='$3/ frpc.ini
sed -i s/'remote_port.*'/'remote_port='$4/ frpc.ini
cat frpc.ini
./frpc -c frpc.ini
# touch frpc.service
# sed -i 1a'[Unit]' frpc.ini
# sed -i 2a'admin_port' frpc.ini
# sed -i 3a'admin_port' frpc.ini
# sed -i 4a'admin_port' frpc.ini
# sed -i 5a'admin_port' frpc.ini