50% off 所有套餐限时优惠,起价 $2.48/mo
8 min left
Security & Networking

如何在 Netflix VPS 上安装 Wireguard?

Allen By Allen 8 min read Updated Apr 15, 2023
在 VPS 上安装 WireGuard

本指南的目的是记录我在 Netflix VPS 上设置 Wireguard 和 Unbound 的步骤,以解锁在特定位置可用的 Netflix 内容。例如,我住在美国但想观看只在英国提供的 不错的 Netflix 内容。如果你想在我们任何可用的位置观看 Netflix,也可以使用本教程。

完成本教程后,你将拥有:

  • 一个 VPN,使用 WireGuard 提供加密连接。它在全球几乎所有 ISP 上都能工作,轻松穿透 GFW 和伊朗防火墙。还能绕过阿联酋 VoIP 限制,让你在迪拜使用 WhatsApp 语音或视频通话,因为 WireGuard 也加密 UDP 连接。
  • 它不会泄露你的 DNS,不像主流 VPN 方案那样,所以你可以访问 Netflix、Hulu 和其他受地区限制的网站和服务。

如需详细的 WireGuard VPN 在 Ubuntu 服务器上的分步指南,可查看 this article.

What is Wireguard?

在 Netflix VPS 上安装 WireGuard

WireGuard® 是一款极其简洁而快速的现代 VPN,采用 最先进的密码学技术。它旨在比 IPsec 更快、更简单、更轻便、更实用,同时避免复杂问题。性能也远优于 OpenVPN。

Also Read : 最佳 VPS 用于 VPN 托管

什么是 Unbound(DNS 服务器)?

Unbound 是由 NLnet Labs 开发的验证、递归和缓存 DNS 解析器产品。以 BSD 许可证以开源形式免费分发。

安装 Wireguard VPN 前需要采取的步骤

要跟随本教程,你需要拥有一个 Netflix VPS 至少 1GB 内存,不过如果你计划连接大量客户端,我个人建议至少 2GB。本指南假设你使用 Ubuntu 18.04。

linux-vps Linux 主机服务简化版

想要更好的方式来托管网站和网络应用?正在开发新项目?或者只是不喜欢 Windows?这就是我们提供 Linux VPS 的原因。

获取你的 Linux VPS

其他发行版应该也能用,但我只在 Ubuntu 18.04 上测试过本教程的步骤。
另外,我建议你从我们的 ubuntu VPS 页面订购,因为 Netflix 屏蔽行业内所有主流公司如 DigitalOcean 和 Vultr 的 IP。我们很高兴宣布,截至今天(2019 年 7 月),我们的所有 IP 都能正常使用 Netflix。我们也有 如何订购 VPS 的指南.

如何在 Netflix VPS 上安装 VPN?

在 Netflix VPS 上安装 VPN

按照以下步骤,你可以在你的 Netflix VPS 上设置 Wireguard VPN。这样你就能享受只在特定地区(如英国)提供的 Netflix 节目。

Also Read: Streaming VPS

初始服务器设置

I will be using 

ssh

远程登录 Netflix VPS 并配置它。如果你使用基于 Unix 的操作系统,它应该已经安装。如果你使用 Windows 10,最佳方案是 为 Linux 安装 Windows 子系统 (WSL) 安装非常简单,原生支持。你可能需要安装 PuTTY 在较早版本的 Windows 中。
另外,我假设你在 Netflix VPS 上使用的是有效的主机名。

基础 SSH 安全设置

确保你知道服务器的 IP 地址和登录凭证。如果你是从我们这里购买的,可以在欢迎邮件中找到这些信息。

生成 RSA 密钥对

打开终端(或命令提示符)并运行:

ssh-keygen

输入一个名称(比如 wireguard)然后按回车。系统会要求你输入密码,你可以按两次回车跳过这一步。

“Enter file in which to save the key (C:Userskevin/.ssh/id_rsa): wireguard
输入密码短语(留空则不设置密码短语):
再次输入相同的密码:您的身份标识已保存在 wireguard 中。
您的公钥已保存在 wireguard.pub 中。
密钥指纹为:SHA256:PM9TZc0TMO9Iqqq7NC0E+qn32vZp6WELRrFmAc9sw5Y

Also Read: 如何在 CentOS 8 上安装 PPTP VPN?

复制公钥

cat C:Usersamirwireguard.pub | ssh [email protected] "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys

Or

ssh-copy-id [email protected]

然后你会看到类似这样的界面:

无法确认主机 'netflix.routerhosting.com' 的真实性。RSA 密钥指纹是 SHA256:CKp1RW2qe1YEFtz6HOZz3lJnMxYsJm03cH6uGKDnyC8。您确定要继续连接吗(是/否)?

输入 yes 接受 RSA 密钥指纹,然后提供 root 密码。现在尝试用你的密钥通过 SSH 连接:

ssh -i wireguard [email protected]

然后你会看到这个:

C:Usersamir>ssh -i wireguard [email protected]
欢迎使用 Ubuntu 18.04 LTS (GNU/Linux 4.15.0-22-generic x86_64)

  * 文档:https://help.ubuntu.com
  * 管理工具:https://landscape.canonical.com
  * 支持: https://ubuntu.com/advantage

Last login: Wed May 30 03:03:29 2018
root@netflix:~#

linux-vps Linux 主机服务简化版

想要更好的方式来托管网站和网络应用?正在开发新项目?或者只是不喜欢 Windows?这就是我们提供 Linux VPS 的原因。

获取你的 Linux VPS

禁用密码认证

由于密码即将被淘汰,我们必须禁用这个过时的机制:

sed -ie 's/#?PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
sed -ie 's/#?PermitEmptyPasswords yes/PermitEmptyPasswords no/' /etc/ssh/sshd_config

如果你对安全性要求很高,可以禁用 root 账户并创建 sudo 用户,但这超出了本教程的范围

Installing updates

apt update && apt upgrade -y && reboot

it will take few minutes to update and then reboot. Choose “Yes” when it asks for “restart service when the package upgrades without asking”. Update GRUB (install package maintainer’s version) and select both devices with spacebar and hit enter. Keep the local version of /etc/sshd_config and after all this, you have to wait a few seconds for reboot and then ssh to your server again.

Unattended Upgrades

这一步是可选的,你可以跳过,但建议启用并设置自动无人值守安全更新。 以下是官方网站的指南.

Install Unbound

apt install -y software-properties-common curl unbound unbound-host
curl -o /var/lib/unbound/root.hints https://www.internic.net/domain/named.cache

配置 DNS 服务器

本节内容来自 this guide. Run:

nano /etc/unbound/unbound.conf

要打开 unbound 配置文件,使用 Ctrl+K 删除所有内容,然后粘贴以下代码。按 Ctrl+X 并输入 "y" 保存更改。

server:

  num-threads: 4

  #Enable logs
  verbosity: 1

  #list of Root DNS Server
  root-hints: "/var/lib/unbound/root.hints"

  #Use the root servers key for DNSSEC
  auto-trust-anchor-file: "/var/lib/unbound/root.key"

  #Respond to DNS requests on all interfaces
  interface: 0.0.0.0
  max-udp-size: 3072

  #Authorized IPs to access the DNS Server
  access-control: 0.0.0.0/0                 refuse
  access-control: 127.0.0.1                 allow
  access-control: 10.99.97.0/24         allow

  #not allowed to be returned for public internet  names
  private-address: 10.99.97.0/24

  # Hide DNS Server info
  hide-identity: yes
  hide-version: yes

  #Limit DNS Fraud and use DNSSEC
  harden-glue: yes
  harden-dnssec-stripped: yes
  harden-referral-path: yes

  #Add an unwanted reply threshold to clean the cache and avoid when possible a DNS Poisoning
  unwanted-reply-threshold: 10000000

  #Have the validator print validation failures to the log.
  val-log-level: 1

  #Minimum lifetime of cache entries in seconds
  cache-min-ttl: 1800 

  #Maximum lifetime of cached entries
  cache-max-ttl: 14400
  prefetch: yes
  prefetch-key: yes

Now Run:

chown -R unbound:unbound /var/lib/unbound
systemctl enable unbound

Install Wireguard

add-apt-repository -y ppa:wireguard/wireguard
apt-get update 
apt-get install -y wireguard && reboot

Install Docker CE

本节涵盖 使用仓库安装 Docker CE:

# Install Docker CE

apt-get install
apt-transport-https
ca-certificates
curl
gnupg-agent
software-properties-common

# 添加 Docker 的官方 GPG 密钥

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io -y

# 测试 Docker 安装

docker run hello-world

Also Read: 如何在 VPS 上安装 Docker(分步指南)

Install Subspace

本节涵盖 如何在 Docker 容器中安装 Subspace。确保将 –env SUBSPACE_HTTP_HOST 改为你的公网域名。

# Load modules

modprobe wireguard
modprobe iptable_nat
modprobe ip6table_nat

# Enable IP forwarding

sysctl -w net.ipv4.ip_forward=1
sysctl -w net.ipv6.conf.all.forwarding=1

确保将 –env SUBSPACE_HTTP_HOST 改为你的公网域名。使用 `–volume` 标志将数据目录绑定挂载到容器内的 `/data`。 

mkdir /data
docker create --name subspace --restart always --network host --cap-add NET_ADMIN --volume /usr/bin/wg:/usr/bin/wg --volume /data:/data --env SUBSPACE_HTTP_HOST=netflix.routerhosting.com subspacecloud/subspace:latest
docker start subspace

配置内核模块在启动时加载

为了在重启后保持配置,需要在启动时加载内核模块。

nano /etc/modules-load.d/subspace.conf

粘贴以下代码并保存文件:

wireguard
iptable_nat
ip6table_nat
linux-vps Linux 主机服务简化版

想要更好的方式来托管网站和网络应用?正在开发新项目?或者只是不喜欢 Windows?这就是我们提供 Linux VPS 的原因。

获取你的 Linux VPS

Conclusion

如果你完成了本文提到的所有步骤,应该能看到 Netflix 在你所在地区不提供的电视剧、纪录片、电影以及其他内容。Cloudzy 在全球 12 个以上地区提供价格实惠的多种套餐,支持 Netflix 和其他 Plex 等媒体服务器 。为了能看到你想要的内容,可以考虑查看我们的 Linux VPS 方案.

Share

博客更新

Keep reading.

MikroTik L2TP VPN 指南的 Cloudzy 标题图像,展示笔记本电脑通过发光的蓝色和金色数字隧道连接到服务器机架,并配有盾牌图标。
Security & Networking

MikroTik L2TP VPN 设置(含 IPsec):RouterOS 指南(2026)

在这个 MikroTik L2TP VPN 设置中,L2TP 处理隧道,IPsec 处理加密和完整性验证。将两者结合使用可以获得原生客户端兼容性,无需第三方工具。

Rexa CyrusRexa Cyrus 9 min read
终端窗口显示 SSH 警告信息,提示远程主机标识已更改。深蓝绿色背景上显示修复指南标题和 Cloudzy 品牌标识。
Security & Networking

警告:远程主机标识已更改及修复方法

SSH 是一种安全网络协议,可在系统之间创建加密隧道。在需要远程访问计算机但无需图形界面的开发者中仍然广泛使用。

Rexa CyrusRexa Cyrus 10 min read
DNS 服务器故障排查指南插图,深色背景上显示警告符号和蓝色服务器,用于 Linux 名称解析错误。
Security & Networking

名称解析临时失败:含义和修复方法?

使用 Linux 时,在尝试访问网站、更新软件包或执行需要网络连接的任务时,可能会遇到名称解析临时失败错误。

Rexa CyrusRexa Cyrus 12 min read

Ready to deploy? From $2.48/mo.

独立云服务,始于2008年。AMD EPYC、NVMe,40 Gbps。14天退款保障。