外网访问
使用frp
准备工具下载:https://github.com/fatedier/frp
安装好frps的服务器一台。
I、根据自己的实际情况修改配置frpc.ini配置:
[common]
server_addr = "服务器地址,支持ip或域名"
server_port = 5443
# for authentication
token = "与服务器端保持一致"
# decide if exit program when first login failed, otherwise continuous relogin to frps
# default is true
login_fail_exit = flase
[PORT_5000]
type = tcp
local_ip = 127.0.0.1
local_port = 5000
remote_port = 5000
[PORT_5001]
type = tcp
local_ip = 127.0.0.1
local_port = 5001
remote_port = 5001
[PORT_5006]
type = tcp
local_ip = 127.0.0.1
local_port = 5006
remote_port = 5006
新建用于存放frp文件的共享文件夹:
控制面板》共享文件夹》新增》
新建setup文件夹,将frp可执行文件和配置文件放到setup》frp文件夹下
II、添加任务计划:
控制面板》任务计划》新增》触发的任务》用户自定义脚本
任务名称随便填,用户账号选择root,事件选开机。
任务设置:
在用户自定义脚本中填写以下脚本:
nohup /volume1/setup/frp/frpc -c /volume1/setup/frp/frpc.ini &
记得勾选启动,并保存。
使用ddns
准备材料:阿里云顶级域名,申请公网ip
动态解析脚本,在github上找的,不记得名字了:
#!/bin/sh
set -e
if [ $1 ]; then
ApiId=$1
#echo $ApiId
fi
if [ $2 ]; then
ApiKey=$2
#echo $ApiKey
fi
if [ $3 ]; then
Domain=$3
#echo $Domain
fi
if [ -z "$ApiId" -o -z "$ApiKey" -o -z "$Domain" ]; then
echo