MY Blog
友情链接
往期整理
  •   历史归档
  •   文章分类
  •   文章标签
关于我
ZZB
Article
454
Category
4
Tags
798
友情链接
往期整理
历史归档
文章分类
文章标签
关于我
tech
🚀 WireGuard:打造你的专属加密网络通道!
Post on: 2024-8-7
Last edited: 2024-10-14
Views
tools
recommend
type
status
date
slug
summary
tags
category
icon
password
📌 准备工作 🧰🛠️ 安装 WireGuard🔑 生成密钥对⚙️ 配置服务器📱 配置客户端 (以另一台 Ubuntu 系统为例)🎉 测试连接🔥 进阶技巧
 
WireGuard,一款轻量级、快速且现代的 VPN 实现,让你轻松搭建自己的加密网络,实现内网穿透,安全访问内部资源!🌐 告别复杂的配置,拥抱简洁高效的 WireGuard!

📌 准备工作 🧰

  • 一台 Ubuntu 20.04 服务器: 作为你的 WireGuard 服务器。
  • 具有 sudo 权限的用户: 用于安装软件和修改系统配置。
  • 稳定的网络连接: 确保服务器可以连接到互联网。

🛠️ 安装 WireGuard

  1. 更新系统:
    1. 安装 WireGuard:

      🔑 生成密钥对

      在服务器上生成 WireGuard 密钥对:
      • /etc/wireguard/privatekey: 服务器私钥,妥善保管,不要泄露!
      • /etc/wireguard/pubkey: 服务器公钥,稍后会用于客户端配置。

      ⚙️ 配置服务器

      1. 创建配置文件 wg0.conf:
        1. 粘贴以下配置,并修改相应内容:
            • 将 <服务器私钥> 替换为 /etc/wireguard/privatekey 文件中的内容。
            • 将 <客户端公钥> 替换为客户端生成的公钥。
            • 将 <你的网络接口> 替换为你的服务器连接外网的网络接口名称,例如 eth0 或 ens3,可以使用 ip a 命令查看。
            • Address: 服务器在 VPN 网络中的 IP 地址。
            • AllowedIPs: 客户端允许访问的 IP 地址范围,可以是单个 IP 或网段。
        1. 启动 WireGuard:
          1. 设置开机启动:

            📱 配置客户端 (以另一台 Ubuntu 系统为例)

            1. 安装 WireGuard: 与服务器安装步骤相同。
            1. 生成密钥对: 与服务器生成密钥对步骤相同,将生成的公钥提供给服务器管理员。
            1. 创建配置文件 wg0.conf:
              1. 粘贴以下配置,并修改相应内容:
                1. 启动 WireGuard:

                  🎉 测试连接

                  在客户端执行 ping 10.8.0.1,如果能 ping 通,说明 WireGuard 连接成功! 你也可以尝试访问服务器上的内网资源。

                  🔥 进阶技巧

                  • 多客户端配置: 在服务器的 wg0.conf 文件中添加多个 [Peer] 部分,每个客户端对应一个 [Peer]。
                  • 域名解析: 将服务器的公网 IP 地址配置到域名,方便客户端连接。
                  • 防火墙配置: 根据需要配置服务器的防火墙规则,允许 WireGuard 流量通过。
                  希望这篇博客能帮助你轻松搭建 WireGuard VPN,享受安全、快速的网络连接!💖
                  • Author:ZZB
                  • URL:https://project-servers.com/article/wireguard-1
                  • Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!
                  Relate Posts
                  ✨ Oh My Zsh:让你的终端炫酷起来!
                  🚀 开启 DevOps 之旅:GitLab 与 GitLab Runner 实战指南!
                  🌈 使用 Oh-My-Posh 打造个性化的 PowerShell 命令行体验
                  🌟 Docker:你的应用集装箱 🐳
                  ✨ Ubuntu 主机名修改
                  🚀 SSH 免密登录:告别密码,一键直达!
                  🚀 基本环境配置与软件安装 🚀回忆
                  Loading...
                  ZZB
                  ZZB
                  A Coder 🤖
                  Article
                  454
                  Category
                  4
                  Tags
                  798
                  Latest posts
                  ✨Github热门榜: 2025-05-01
                  ✨Github热门榜: 2025-05-01
                  2025-5-1
                  ✨Github热门榜: 2025-04-30
                  ✨Github热门榜: 2025-04-30
                  2025-4-30
                  ✨Github热门榜: 2025-04-29
                  ✨Github热门榜: 2025-04-29
                  2025-4-29
                  ✨Github热门榜: 2025-04-28
                  ✨Github热门榜: 2025-04-28
                  2025-4-28
                  ✨Github热门榜: 2025-04-27
                  ✨Github热门榜: 2025-04-27
                  2025-4-27
                  ✨Github热门榜: 2025-04-26
                  ✨Github热门榜: 2025-04-26
                  2025-4-26
                  Announcement
                  🎉欢迎来到我的博客🎉
                  -- 感谢您的支持 ---
                  👏Welcome to my blog👏
                  联系我们
                   
                  2024-2025 ZZB.
                  赣ICP备2024046115号

                  MY Blog | A Coder 🤖