VPS配置

常用VPS


简单的公式显示:
$a_1=b_0+c_0$

名称 说明
谷歌云(GCP) 新用户赠送3个月有效的300美元额度,可转赠给其他用户,实现无缝续用。
微软云(Azure) 新账户拥有1个月的免费试用订阅,并赠送200美元的使用额度。
亚马逊云(AWS) 新用户可申请12个月的Free Trier订阅,需绑定信用卡,有银联标识即可。
甲骨文云(Oracle) 这是史上最强的免费服务器,申请的时候要谨慎,申请地区和用户信息应匹配,否则申请容易被拒。
申请链接
Woiden(Only IPV6) 纯IPV6服务器,3天使用期,到期后可再次申请。
EUServ(Only IPV6) 俗称德鸡,也是纯IPV6服务器,开机需要支付2欧元,1个月的使用时间,到期时可续用,邮箱提醒。

注:VPS排行榜

服务器初始化


  1. 一般情况下,购买VPS时,需要保存SSH密钥,用于登录SSH客户端(如FinalShellWindTermTermius)。
  2. 注意选择系统时,建议选Ubuntu,版本则可以是22.04或20.04,其中20.04版本较为稳定。

设置root账户


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 切换到root账户
sudo -i # 切换到root账户,进入root账户目录
sudo su # 切换到root账户,停留在当前目录

# 更新系统
sudo apt update -y && sudo apt upgrade -y

# 修改root账户密码
echo root:V2rayssr |chpasswd root

# 开放root账户登录权限
# 更新SSH连接服务,使root账户登录功能生效
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config;
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
service sshd restart

:如果无法登录root账户,可尝试重启服务器

关闭防火墙

对于一台服务器,一般情况下有两个地方需要设置防火墙,一个是服务器商的安全规则,另一个则是系统的防火墙。因此,当服务器失联的时候,应查看系统防火墙及服务器提供商的控制台安全规则是否设置正确。
如果服务器主要用于的搭建节点,可能用到的端口需要很多,此时,应放开服务商的安全规则并关闭系统防火墙。
ufw为iptables的简易管理工具,如果系统未安装ufw,则应先安装:sudo apt install ufw

注:ufw防火墙无法禁用Docker的端口映射,Docker的防火墙设置是在运行Docker时进行设置的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# For Ubuntu/Debian 
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -F

# 放开某个指定的端口
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
ip6tables -A INPUT -p tcp --dport 80 -j ACCEPT

# For CentOS/Redhat
# 删除多余附件
systemctl stop oracle-cloud-agent
systemctl disable oracle-cloud-agent
systemctl stop oracle-cloud-agent-updater
systemctl disable oracle-cloud-agent-updater

# 关闭防火墙及自启动
systemctl stop firewalld.service
systemctl disable firewalld.service

# 查看防火墙状态
firewall-cmd --state

curl ip.sb # 也可使用以下URL:ifconfig.me,4.ipw.cn,6.ipw.cn,test.ipw.cn
curl -4 ip.sb # 获取本机的出站IPV4,也可使用curl ipv4.ip.sb | curl 4.ipw.cn
curl -6 ip.sb # 获取本机的出站IPV6,也可使用curl ipv6.ip.sb | curl 6.ipw.cn

# 查看某个设备的网络状态
ip addr show # 显示系统所有设备的IP信息
ip addr show docker0 # 显示容器docker0的IP信息,在进行域名反代时可填写这里获取的内部IP

ip addr | grep "inet " # 显示IPV4地址
ip addr | grep inet6 # 显示IPV6地址
ipconfig | find "IPv4" # Windows平台下显式IPv4地址

# 纯IPv6小鸡无法请求Github,试试以下命令:
echo -e "nameserver 2001:67c:2b0::4\nnameserver 2001:67c:2b0::6" > /etc/resolv.conf

端口查看和设置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 查看当前端口情况
netstat -tuln # 查看端口占用信息
ss -tuln # ss为netstats的简易命令

# 查看指定端口情况
lsof -i :port # e.g. lsof -i :80

# For Ubuntu/Debian
ufw status # 查看防火墙状态
ufw enable # 开启防火墙
ufw disable # 关闭防火墙
ufw allow [port] # 允许端口port被外部访问
ufw deny [port] # 拒绝端口port被外部访问

# For CentOS
firewall-cmd --zone=public --add-port=80/tcp --permanent

1Panel面板

这是一款国产开源面板,安装之后默认安装最新版本的Docker和Docker-compose。
面板对服务器的管理具有很大的优点,可申请SSL证书(单域名和泛域名均可,面板上申请的证书可自动续期)。
可非常方便地进行反代设置(使用openResty进行管理)。
也可以安装面板提供的最新版本的应用程序,均以Docker的方式安装。
其中code_server可以部署一个在线的code编辑器,不依赖于本地机器。

1
2
3
4
5
6
7
8
9
10
11
12
13
# For ubuntu: 
curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sudo bash quick_start.sh

# For Debian:
curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && bash quick_start.sh

# For Redhat/CentOS:
curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sh quick_start.sh

# 1Panel使用说明
1pctl --help # 面板使用说明
1pctl user-info # 查看面板访问信息
1pctl reset domain # 重新恢复面板的域名访问

FastPanel

1
2
# 免费的海外服务器面板
wget http://repo.fastpanel.direct/install_fastpanel.sh -O - | bash -

安装Warp+

可以为VPS安装Warp,使得机器破墙访问。
一键BBR加速
VPS测速

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

# 选择一:
wget -N https://gitlab.com/fscarmen/warp/-/raw/main/menu.sh && bash menu.sh [option] [lisence/url/token]

bash menu.sh a 8Al42B9X-8ta9z4h3-V5Du8J64 # 升级为Warp+账户,后面的字符串为Key密钥

# 选择二:这是小破站提供的一键安装脚本,有2个版本可选,默认大部分地区使用Warpcf,香港和美国地区可优先考虑warp-go版本。
wget -N https://gitlab.com/Misaka-blog/warp-script/-/raw/main/warp.sh && bash warp.sh

# 测试Warp开启状态
curl -s4m5 https://www.cloudflare.com/cdn-cgi/trace
curl -s6m5 https://www.cloudflare.com/cdn-cgi/trace

# Warp常用命令
warp o # 切换Warp状态[开启|关闭]
warp u # 卸载Warp
warp h # 查看warp的使用说明
warp n # 重新请求IP
warp i # 更换IP,可添加国家代码,如jp, hk, us, de...

# 一键BBR加速
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p

wget -N --no-check-certificate "https://raw.githubusercontent.com/chiakge/Linux-NetSpeed/master/tcp.sh" && chmod +x tcp.sh && ./tcp.sh

安装x-ui

X-UI面板有较多的版本,可根据VPS线路和地区的具体情况,择优选择。

版本 说明
rwkgyg 勇哥的脚本,默认为最新的Xray版本,同时解锁ChatGPT
FranzKafkaYu 支持Reality+Vision,可刷新筛选Reality服务端页面
vaxilu vaxilu最初版本
sing-web 大佬针对中国用户的修改版本,OK for Woiden(IPV6)
3x-ui 伊朗大佬的修改版本
x-ui 伊朗大佬alireza0的修改版本
勇哥四合一脚本 Sing-box精装桶小白一键脚本【Vless-reality、Vmess-ws(tls)、Hysteria2、Tuic5】

安装命令:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# 最初始版本,不过vaxilu有一段时间停更了
bash <(curl -Ls https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh)

# FranzKafkaYu基于vaxilu版本进行的修改版
bash <(curl -Ls https://cdn.jsdelivr.net/gh/FranzKafkaYu/x-ui/master/install.sh)
bash <(curl -Ls https://raw.githubusercontent.com/FranzKafkaYu/x-ui/master/install.sh)

# 这是针对中国用户进行的定制看到,xray进行了分流控制,可解锁ChatGPT
bash <(wget -qO- https://raw.githubusercontent.com/sing-web/x-ui/main/install_CN.sh)

# 勇哥的纯IPV4/纯IPV6的VPS直接运行一键脚本,默认为Xray最新版本,安装Warp解锁ChatGPT。
bash <(wget -qO- https://gitlab.com/rwkgyg/x-ui-yg/raw/main/install.sh 2> /dev/null)
bash <(curl -Ls https://gitlab.com/rwkgyg/x-ui-yg/raw/main/install.sh)

# 勇哥四合一【Vless-reality、Vmess-ws(tls)、Hysteria2、Tuic5】
bash <(wget -qO- https://gitlab.com/rwkgyg/sing-box-yg/raw/main/sb.sh 2> /dev/null)
bash <(curl -Ls https://gitlab.com/rwkgyg/sing-box-yg/raw/main/sb.sh)

# 这是一个健康大佬编写的x-ui面板: https://github.com/MHSanaei/3x-ui, 面板默认使用最新版本的xary,支持中文,界面更加美观简洁,推荐使用
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh)

# alireza0大佬的x-ui修改版,界面相当漂亮
bash <(curl -Ls https://raw.githubusercontent.com/alireza0/x-ui/master/install.sh)

# 对于微小鸡,Apline系统
apk update && apk add vsftpd openssh-sftp-server
apk add curl && apk add bash && apk add sudo && bash <(curl -Ls https://raw.githubusercontent.com/ozersource/x-ui-Alpine/main/x-ui-alpine)

# x-ui面板卸载
x-ui uninstall
rm /usr/bin/x-ui -f # 删除文件

# 绵羊三合一脚本:Reality, Hysteria2, vmess+ws
# https://github.com/vveg26/sing-box-reality-hysteria2
# https://wow.mareep.net
# > mianyang

# Reality+hysteria2+vmess
bash <(curl -fsSL https://github.com/vveg26/sing-box-reality-hysteria2/raw/main/beta.sh)
# reality+hysteria2
bash <(curl -fsSL https://github.com/vveg26/sing-box-reality-hysteria2/raw/main/install.sh)

# hy2端口跳跃
# IPv4|ipv6
iptables -t nat -A PREROUTING -i eth0 -p udp --dport 20000:50000 -j DNAT --to-destination :8443
ip6tables -t nat -A PREROUTING -i eth0 -p udp --dport 20000:50000 -j DNAT --to-destination :8443

# hy2 端口跳跃关闭
iptables -t nat -D PREROUTING -i eth0 -p udp --dport 20000:50000 -j DNAT --to-destination :8443
ip6tables -t nat -D PREROUTING -i eth0 -p udp --dport 20000:50000 -j DNAT --to-destination :8443

# Warp
wget -N https://gitlab.com/fscarmen/warp/-/raw/main/warp-go.sh && bash warp-go.sh

# Sing-Box全家桶
# https://github.com/fscarmen/sing-box
bash <(wget -qO- https://raw.githubusercontent.com/fscarmen/sing-box/main/sing-box.sh)

安装v2ray|xray

233Boy大佬开发的一键安装工具,推荐使用Ubuntu 22,CentOS可能存在问题。这2个脚本国内是无法正常使用的,因为作者屏蔽了国内IP。

v2ray-agent安装vasma,EUServ的VPS上安装这个能成功,默认选择第1项安装,生成13个协议类型的节点,有2种安装方式,一种需要域名,另一种不需要域名(使用Reality协议)。

GitHub
搭建教程
V2Ray工具
CF中转Xray流量
V2Ray脚本自动TLS说明(基于Caddy工具)

v2ray申请的ACME证书保存在下面的目录: /root/.local/share/caddy/certificates

工具 说明
v2ray v2ray,纯脚本的节点创建工具
xray xray,一键安装脚本
v2ray-agent vasma,集成了v2ray和xray,可实现分流
ArgoX 这个对纯IPV6的VPS有奇效,因为x-ui在纯IPV6的VPS上面安装容易出现问题
Hysteria2 神奇协议,可以和最近的xray-reality-xtls-vision协议相媲美,这个基于UPD的协议可用于拯救线路不好的VPS
TUIC5 支持端口跳跃
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# v2ray安装
bash <(curl -s -L https://git.io/v2ray.sh) # v2ray
bash <(curl -s -L https://cdn.jsdelivr.net/gh/233boy/v2ray/install.sh) # v2ray

# xray安装
bash <(wget -qO- -o- https://github.com/233boy/Xray/raw/main/install.sh) # xray
bash <(curl -s -L https://cdn.jsdelivr.net/gh/233boy/Xray/install.sh) # xray

# v2ray-agent安装
wget -P /root -N --no-check-certificate "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh" && chmod 700 /root/install.sh && /root/install.sh # 原版
wget -P /root -N --no-check-certificate "https://www.v2ray-agent.com/v2ray-agent/install.sh" && chmod 700 /root/install.sh && /root/install.sh # 镜像

# ArgoX安装
bash <(wget -qO- https://raw.githubusercontent.com/fscarmen/argox/main/argox.sh)

# Hysteria2协议一键安装脚本
wget -N --no-check-certificate https://raw.githubusercontent.com/Misaka-blog/hysteria-install/main/hy2/hysteria.sh && bash hysteria.sh

# Tuic 4|5协议一键安装脚本
wget -N --no-check-certificate https://gitlab.com/Misaka-blog/tuic-script/-/raw/main/tuic.sh && bash tuic.sh

申请ACME证书

服务器与域名的绑定,需要安装SSL证书,才可实现https的访问,以保证数据的安全性。
SSL证书的申请可以使用1Panel面板进行自动申请,也可自行通过脚本手动申请。

注意:申请证书时,域名不应开启CDN(Cloudflare中的小黄云),否则会导致IP解析不正确。

1
2
3
4
5
6
7
8
9
10
11
12
# 一键安装 
curl https://get.acme.sh | sh

# 1.下载证书安装脚本
wget -N --no-check-certificate https://raw.githubusercontent.com/Misaka-blog/acme-script/main/acme.sh
bash acme.sh # 执行ssl申请脚本

# 2.安装证书
~/.acme.sh/acme.sh --register-account -m xxxx@xxxx.com
~/.acme.sh/acme.sh --issue -d test.bozai2.xyz --standalone
~/.acme.sh/acme.sh --installcert -d tese.bozai2.xyz --key-file /root/private.key --fullchain-file /root/cert.crt

Vless-Reality协议可参考的域名:

  • Apple

    • gateway.icloud.com
    • itunes.apple.com
    • swdist.apple.com
    • swcdn.apple.com
    • updates.cdn-apple.com
    • mensura.cdn-apple.com
    • osxapps.itunes.apple.com
    • aod.itunes.apple.com
  • mozilla

    • download-installer.cdn.mozilla.net
    • addons.mozilla.org
  • aws

    • s0.awsstatic.com
    • d1.awsstatic.com
    • images-na.ssl-images-amazon.com
    • m.media-amazon.com
    • player.live-video.net
  • 其他

    • one-piece.com
    • lol.secure.dyn.riotcdn.net
    • www.lovelive-anime.jp
    • www.nokia.com
    • auth.riotgames.com
    • xsso.riotgames.com
    • csgo.com