常用VPS
简单的公式显示:
$a_1=b_0+c_0$
注:VPS排行榜
服务器初始化
- 一般情况下,购买VPS时,需要保存SSH密钥,用于登录SSH客户端(如FinalShell、WindTerm、Termius)。
- 注意选择系统时,建议选Ubuntu,版本则可以是22.04或20.04,其中20.04版本较为稳定。
设置root账户
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| sudo -i sudo su
sudo apt update -y && sudo apt upgrade -y
echo root:V2rayssr |chpasswd 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
| 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
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 curl -4 ip.sb curl -6 ip.sb
ip addr show ip addr show docker0
ip addr | grep "inet " ip addr | grep inet6 ipconfig | find "IPv4"
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
lsof -i :port
ufw status ufw enable ufw disable ufw allow [port] ufw deny [port]
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
| curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sudo bash quick_start.sh
curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && bash quick_start.sh
curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sh quick_start.sh
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线路和地区的具体情况,择优选择。
安装命令:
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
| bash <(curl -s -L https://git.io/v2ray.sh) bash <(curl -s -L https://cdn.jsdelivr.net/gh/233boy/v2ray/install.sh)
bash <(wget -qO- -o- https://github.com/233boy/Xray/raw/main/install.sh) bash <(curl -s -L https://cdn.jsdelivr.net/gh/233boy/Xray/install.sh)
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
bash <(wget -qO- https://raw.githubusercontent.com/fscarmen/argox/main/argox.sh)
wget -N --no-check-certificate https://raw.githubusercontent.com/Misaka-blog/hysteria-install/main/hy2/hysteria.sh && bash hysteria.sh
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