侧边栏壁纸
  • 累计撰写 60 篇文章
  • 累计收到 2 条评论

linux 安装配置免费frp内网穿透教程

凌羽
2022-10-07 / 0 评论 / 4 阅读 / 正在检测是否收录...

linux 一键脚本安装

博主根据手动安装 frpc 的方式简单制作了针对linux专用的一键安装卸载脚本.

打开终端并ssh登陆到linux

ssh xxxx@192.168.x.x 
# xxx为linux管理员账号,IP为linux内网IP.输入linux登陆密码 - 回车.
sudo -i
# 获得root权限.输入linux登陆密码 - 回车.

一键安装卸载脚本

安装

wget https://raw.githubusercontent.com/stilleshan/frpc/master/frpc_synology_install.sh && chmod +x frpc_synology_install.sh && ./frpc_synology_install.sh
# 以下为国内镜像
wget https://github.ioiox.com/stilleshan/frpc/raw/branch/master/frpc_synology_install.sh && chmod +x frpc_synology_install.sh && ./frpc_synology_install.sh

卸载

wget https://raw.githubusercontent.com/stilleshan/frpc/master/frpc_synology_uninstall.sh && chmod +x frpc_synology_uninstall.sh && ./frpc_synology_uninstall.sh
# 以下为国内镜像
wget https://github.ioiox.com/stilleshan/frpc/raw/branch/master/frpc_synology_uninstall.sh && chmod +x frpc_synology_uninstall.sh && ./frpc_synology_uninstall.sh

如现有服务器上已存在 frpc 服务,可以先运行卸载脚本,在运行安装脚本.

安装完成后编辑frpc.ini配置你的穿透信息.

vi /usr/local/frp/frpc.ini

修改参照

[common]
server_addr = frp.freefrp.net     # 服务器IP或者地址
server_port = 7000                # 服务器提供的端口号
token = freefrp.net               # 服务器提供的token

[web1_xxxxxx]                     # 为避免错误,一定需更改为比较特殊的名称,不能和服务器端其他配置重名.
type = http                       # http协议
local_ip = 192.168.1.5            # 填写群晖内网IP.
local_port = 5000                 # 群晖内网HTTP端口,默认为5000.
custom_domains = nas.ioiox.com    # 填写你的域名

[web2_xxxxxx]                     # 为避免错误,一定需更改为比较特殊的名称,不能和服务器端其他配置重名.
type = https                      # https协议
local_ip = 192.168.1.5            # 填写群晖内网IP.
local_port = 5001                 # 群晖内网HTTPS端口,默认为5001.
custom_domains = nas.ioiox.com    # 填写你的域名

ESC退出编辑
输入:wq回车即可保存

注意 frpc.ini 中不需要以上参照的注释符号和注释,即#和#之后的文字.更多 frpc.ini 的详解,请参考:新手入门 - 详解 frp 内网穿透 frpc.ini 配置

启动frpc

确保frpc.ini正确无误后执行以下命令后台启动服务.

nohup /usr/local/frp/frpc -c /usr/local/frp/frpc.ini >/dev/null 2>&1 &


服务运行时修改frpc.ini配置后需重启frpc服务才能生效.执行以下命令查询frpc运行进程,并使用kill -9命令停止服务.如图查询frpc的进程ID为1108

ps -aux|grep frp| grep -v grep
# 查询 frpc 的运行进程ID,并 kill 停止服务.
kill -9 1108


如因误操作等原因出现多个进程,可能会导致 frpc 无法使用正确的 frpc.ini 配置,需全部停止,再次启动即可.

0

评论 (0)

取消
召唤看板娘