VPN 搭建

2022 new tour

2022 has no time to see new world, now restart,vpn is great.

now do this

1 购买VPS
2 测试外网IP是否能访问
3 ssh 连接
4 购买域名,解析域名到VPS的IP

now all things is ready

现在基础已经准备完毕,可以开始搭建了

使用v2ray搭建

v2ray是常见的方式,网络上有很多教程
参考地址:https://www.youtube.com/watch?v=YLmAsP84yCM

获取root权限

sudo -i

执行v2ray搭建代码

bash <(curl -sL https://raw.githubusercontent.com/daveleung/hijkpw-scripts-mod/main/v2ray_mod1.sh)

使用选项8:安装v2ray-vless+tcp+xtls(推荐)
使用选项16:可以查看v2ray服务端配置,客户端使用时需要用到。
还需要关闭服务器防火墙。

v2rayN去GITHUB 下载稳定发布版本V2RAY-CORE.zip包
github下载地址:https://github.com/2dust/v2rayN/releases

重点:客户端配置参考上文选项16,协议需要选择xtls协议,配置完成切换为活动服务器。

备注:此方案速度快,但容易被墙,可能端口或者IP,遇到这种情况需要更换服务端端口,客户端同理。

使用naive+ caddy搭建

和v2ray的区别在于,caddy进行了额外的指纹加密,和域名证书自动申请以及代理,可以更好的伪装网站,防止被封。
参考链接:https://bulianglin.com/archives/naive.html
naiveGitHub地址:https://github.com/caddyserver/caddy

以下针对centos7的安装教程

bash 说明 首先安装go,然后安装caddy,caddy类似nginx代理和转发,注意第三条命令需要时间较长。

yum -y install golang
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
~/go/bin/xcaddy build --with github.com/caddyserver/forwardproxy@caddy2=github.com/klzgrad/forwardproxy@naive

安装完成后在当前目录下会有一个caddy文件,这时候需要一个Caddyfile,并填充如下内容,我的作为参考。

:443, jackromerstair.club
tls jackromer@163.com
route {
 forward_proxy {
   basic_auth jackromer pass
   hide_ip
   hide_via
   probe_resistance
  }
 reverse_proxy  https://bing.com  {
   header_up  Host  {upstream_hostport}
   header_up  X-Forwarded-Host  {host}
  }
}
log {
    output discard
}

解释:443勿动,jackromerstair.club是你要伪装的域名,bing.com是你要伪装的域名跳转的地址;jackromer@163.com是你的邮箱,jackromer是用户名(客户端会用到),pass自行设置。

Caddyfile弄好之后,执行如下命令,这个命令比较久,它会自动代理伪装域名并为你申请免费证书和绑定,等待 certificate baind successful代表ok, ctrl c 退出程序。

./caddy run

现在开始启动caddy,执行如下命令后台启动caddy即可,大功告成

./caddy start

最后关闭防火墙。

配置客户端
naive客户端下载地址:https://github.com/klzgrad/naiveproxy/releases/latest
客户端下载并解压,复制压缩包naive.exe到v2rayN文件夹,并启动v2rayN.
并将config.json导入到v2rayN建立新的服务器连接,配置文件如下,端口使用1080,然后设为活动服务器

{
  "listen": "socks://127.0.0.1:1080",
  "proxy": "https://jackromer:pass@jackromerstair.com"
}

BBR加速

无论是v2ray还是naive + caddy都需要使用BBR加速进行网络加速,否则vps访问会很慢。

BBR加速命令

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

先安装bbr-plus版本内核 然后重启服务器。

再运行上诉命令,并使用bbr-plus加速,大功告成。

总结

且用且珍惜,science network fly.


   Reprint policy


《VPN 搭建》 by jackromer is licensed under a Creative Commons Attribution 4.0 International License
 Current
VPN 搭建 VPN 搭建
2022 new tour 2022 has no time to see new world, now restart,vpn is great. now do this1 购买VPS2 测试外网IP是否能访问3 ssh 连接4 购买域
2022-12-14
Next 
hello 2022 hello 2022
2022 新的开始 2021 过去几年,收获了很多,也接触了很多人和事,相信缘分,相信自己,2020继续前进。look forward! document.querySelectorAll('.github-emoji'
2022-01-22
  目录