yum install wget -y
openvpn一键搭建脚本命令
wget https://git.io/vpn -O openvpn-install.sh && bash openvpn-install.sh
固定客户端IP
在/etc/openvpn/server.conf中增加\
client-config-dir /etc/openvpn/ccd
然后在 /etc/openvpn/ccd目录中放针对每个客户端的个性化配置文件。
文件名就用客户端名 生成key的时候输入的 “Common Name” 名字
比如要设置客户端 liushiwei为 192.168.2.24
只要在 /etc/openvpn/ccd/liushiwei文件中包含一行:
ifconfig-push 192.168.2.24 255.255.255.0
重启openVPN命令
systemctl restart openvpn-server@server
如果想要添加一个新用户的话重新执行脚本代码就行了
1.使用国外服务器搭建科学节点并使用电脑连接科学节点全局上网,开启电脑的系统代理。
2.安装PI-NODE 0.4.5版本,正常流程登录。
3.配置服务器frp服务端,下载最新的LINUX服务端 Releases · fatedier/frp · GitHub 解压复制到/usr/frp/ 路径内,打开frps.ini文件编辑填入一下代码内容,给整个文件夹及文件设置777权限。
[common]
bind_port = 7000
dashboard_port = 7500 #WEB页面管理端口
dashboard_user = admin #WEB页面管理端口用户名
dashboard_pwd = 你的密码 #WEB页面管理端口密码
4.启动运行测试 frps 输入以下命令测试启动
./usr/frp/frps -c ./usr/frp/frps.ini
5.建立frps开机自自启动服务,进入/lib/systemd/system创建文件frps.service文件并写入一下内容保存给定777权限。
[Unit]
Description=Frp Server Service
After=network.target
[Service]
Type=simple
User=nobody
Restart=on-failure
RestartSec=5s
ExecStart=/usr/frp/frps -c /usr/frp/frps.ini
[Install]
WantedBy=multi-user.target
6.后台启动frps服务命令。
sudo systemctl start frps
设置开启自启
sudo systemctl enable frps
重启命令
sudo systemctl restart frps
停止命令
sudo systemctl stop frps
可以打开服务器的IP:7500端口查看frp的运行状态。
7.设置windows客户端frpc参数,下载最新的windows的客户端。打开frpc.ini配置文件。写入以下内容并保存。
[common]
server_addr = 服务器IP或者域名
server_port = 7000
[31400]
type = tcp
local_ip = 127.0.0.1
local_port = 31400
remote_port = 31400
[31401]
type = tcp
local_ip = 127.0.0.1
local_port = 31401
remote_port = 31401
[31402]
type = tcp
local_ip = 127.0.0.1
local_port = 31402
remote_port = 31402
[31403]
type = tcp
local_ip = 127.0.0.1
local_port = 31403
remote_port = 31403
[31404]
type = tcp
local_ip = 127.0.0.1
local_port = 31404
remote_port = 31404
[31405]
type = tcp
local_ip = 127.0.0.1
local_port = 31405
remote_port = 31405
[31406]
type = tcp
local_ip = 127.0.0.1
local_port = 31406
remote_port = 31406
[31407]
type = tcp
local_ip = 127.0.0.1
local_port = 31407
remote_port = 31407
[31408]
type = tcp
local_ip = 127.0.0.1
local_port = 31408
remote_port = 31408
[31409]
type = tcp
local_ip = 127.0.0.1
local_port = 31409
remote_port = 31409
8.设置开启后台启动frpc客户端,新建一个txt文件写入以下代码并更改FRPC所在的目录,更改扩展名为vbs,创建快捷方式,把快捷方式剪切进启动文件夹内。
Set ws = CreateObject("Wscript.Shell")
ws.run "cmd /c C:\frp\frpc.exe -c C:\frp\frpc.ini",vbhide
9.如果不用frp的话就用socat,优点就是客户端电脑不需要设置什么。服务器设置socat端口映射工具,配置参数,TCP4:106.8.120.456更改成自己的内网IP
#CentOS系统
yum install -y socat
#Ubuntu或Debian系统
apt-get update
apt-get install -y socat
nohup socat TCP4-LISTEN:31400,reuseaddr,fork TCP4:10.8.0.2:31400 >> socat.log 2>&1 &
nohup socat TCP4-LISTEN:31401,reuseaddr,fork TCP4:10.8.0.2:31401 >> socat.log 2>&1 &
nohup socat TCP4-LISTEN:31402,reuseaddr,fork TCP4:10.8.0.2:31402 >> socat.log 2>&1 &
nohup socat TCP4-LISTEN:31403,reuseaddr,fork TCP4:10.8.0.2:31403 >> socat.log 2>&1 &
nohup socat TCP4-LISTEN:31404,reuseaddr,fork TCP4:10.8.0.2:31404 >> socat.log 2>&1 &
nohup socat TCP4-LISTEN:31405,reuseaddr,fork TCP4:10.8.0.2:31405 >> socat.log 2>&1 &
nohup socat TCP4-LISTEN:31406,reuseaddr,fork TCP4:10.8.0.2:31406 >> socat.log 2>&1 &
nohup socat TCP4-LISTEN:31407,reuseaddr,fork TCP4:10.8.0.2:31407 >> socat.log 2>&1 &
nohup socat TCP4-LISTEN:31408,reuseaddr,fork TCP4:10.8.0.2:31408 >> socat.log 2>&1 &
nohup socat TCP4-LISTEN:31409,reuseaddr,fork TCP4:10.8.0.2:31409 >> socat.log 2>&1 &
TCP4-LISTEN:10000监听ipv4的10000TCP端口。10000改成你自己需要转发的端口
fork TCP4:1.1.1.1:10000`转发到1.1.1.1的10000端口,根据需求修改自行修改ip和端口
nohup后台运行。可以把这个命令写到/etc/rc.local里面开机启动启动。
没有rc.local文件就创建一个,给权限777。
Debian 9 系统默认不带 /etc/rc.local 文件,但是却也没有掉 rc.local 服务,所以我们需要的文件。让 Debian 9 系统可以通过编辑 /etc/rc.loacl 文件给我们服务添加开机自启动。
1、添加rc-local.service
以下为一整条命令,一起复制运行
cat > /etc/systemd/system/rc-local.service <<EOF
[Unit]
Description=/etc/rc.local
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
EOF
2、新建rc-local文件
以下为一整条命令,一起复制运行
cat > /etc/rc.local <<EOF
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will “exit 0” on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# bash /root/bindip.sh
exit 0
EOF
3、添加权限并设置开机自启
chmod +x /etc/rc.local
systemctl enable rc-local
systemctl start rc-local.service
检查状态:
systemctl status rc-local.service
返回 Active:active 信息,则成功。
最后我们就可以在 /etc/rc.loacl 里,添加开机的自启命令什么的了。记住添加在 exit 0 之前。
注意:更改自启脚本后,需要重新运行一下命令已使其生效。
systemctl enable rc-local
systemctl start rc-local.service
这样就完成了。对开机自动启动的配置在debian9上。
pi节点测试网站