跳到主要內容

發表文章

目前顯示的是有「vpn」標籤的文章

在 Ubuntu 上設定 WireGuard VPN 伺服器

  如何設定 WireGuard VPN Server How to Set Up a WireGuard VPN Server on Ubuntu 想要架設自己的 VPN?WireGuard 是現在最輕量、高速又安全的 VPN 協議,比 OpenVPN 和 IPSec 更簡單易用!這篇教學會手把手帶你在 Ubuntu 上安裝與設定 WireGuard 伺服器,讓你的連線更安全、且快速!🚀 💡 Step 1:更新系統 在開始之前,先確保你的系統是最新的: sudo apt update && sudo apt upgrade -y 小提醒 :記得備份重要資料,確保系統更新不會影響到其他服務哦!📦 🛠 Step 2:安裝 WireGuard Ubuntu 20.04 以上的版本已經內建 WireGuard,直接執行安裝指令: sudo apt install wireguard -y 安裝完後,可以用這個指令確認版本: wg --version 🔑 Step 3:生成 WireGuard 金鑰 每台裝置都需要一組 私鑰 (private key) 和 公鑰 (public key) 。先來生成伺服器端的密鑰: umask 077 wg genkey | tee privatekey | wg pubkey > publickey 接著把這些密鑰放到安全的位置: sudo mv privatekey /etc/wireguard/server_private.key sudo mv publickey /etc/wireguard/server_public.key sudo chmod 600 /etc/wireguard/server_private.key 📄 Step 4:設定 WireGuard 伺服器 現在來建立 WireGuard 設定檔 : sudo nano /etc/wireguard/wg0.conf 輸入以下內容: [Interface] Address = 10.0.0.1/24 SaveConfig = true PrivateKey = <server_private_key> ListenPort = 51820 # 啟用 IP 轉發...

在 Debian/Ubuntu 設置 WireGuard Client

  在 Ubuntu 設置 WireGuard Client Setting Up a WireGuard Client on Debian/Ubuntu 想讓你的網路變得更安全、更隱私,WireGuard 就是你的好夥伴!這是一款超高效、超簡單的 VPN 協議,不但安全性強,而且性能優異。這篇文章將會示範如何在 Debian/Ubuntu 系統上安裝並配置 WireGuard Client。 第一步:安裝 WireGuard 首先,更新軟體包列表並安裝 WireGuard,執行以下命令: sudo apt update sudo apt install wireguard 第二步:生成 WireGuard 密鑰 WireGuard 需要一對加密密鑰來確保安全通信。執行以下命令來生成密鑰: cd /etc/wireguard/ wg genkey | tee privatekey | wg pubkey > publickey 第三步:配置 WireGuard 客戶端 在 /etc/wireguard/ 目錄下建立 my-client.conf 配置檔,並填入以下內容: 範例配置: [Interface] PrivateKey = <您的私鑰> Address = <WireGuard 伺服器分配的 IP,例如 10.13.0.105/32> DNS = <可選,指定 DNS 伺服器,例如 8.8.8.8> [Peer] PublicKey = <WireGuard 伺服器的公鑰,例如 utrkMw+tobMpNfQgxa3ZnFzTjhja1XPXz4QQLllcVis=> AllowedIPs = <VPN 網段,例如 10.13.0.0/24>, <內部網段,例如 10.101.0.0/16> Endpoint = <WireGuard 伺服器的 URL 或 IP,例如 wireguard01-server.aws.test.tw:51820> PersistentKeepalive = 25 ⚠️ 注意 :如果 Client 與伺服器位於不同網路,請確保 Endpoint 使用的是伺服器的 public  IP 。 範...

如何使用 Cloud VPN 跨專案存取私有 GKE 叢集 - 使用 Classic VPN

  如何使用 Cloud VPN 跨專案存取私有 GKE 叢集 - 使用 Classic VPN Classic VPN 使用 Route Based 的方式, 跟據 Routing Table 裡設定的路由規則, 將封包轉送到指定的目的地 以下示範在 project 01, project 02 各自建立 GKE, VM, 接著透過 Classic VPN 讓 us-east4 的 VM 可以 access project 01 下 us-central1 的 private GKE 叢集 Step 1. 建立 VPN Gateway 需要建立一個 VPN Gateway 作為 VPC 網路對外溝通的橋樑 variable "p1_project_id" {     default = "project-01" } variable "p1_region" {     default = "us-central1" } resource "google_compute_vpn_gateway" "p1_vpn_gw" {   project   = var.p1_project_id   region    = var.p1_region   name      = "vpn-gw"   network = "projects/ ${var.p1_ project_id } /global/networks/default" } Step 2. 建立 Routing 規則 需要一個對外 IP, 讓外部流量可以流進 VPN Gateway resource "google_compute_address" "p1_vpn_ip" {   project      = var.p1_project_id   region       = var.p1_region   name         = "p1-vpn-ip"   address_type = ...

如何使用 Cloud VPN 跨專案存取私有 GKE 叢集

  如何跨專案存取私有 GKE 叢集  在 GKE 的 Control Plane 沒有提供外部 IP  的情況下,  維運人員若想要操作 GKE  則必需走 VPN 的方式才能訪問到 Control Plane  的 API Server 以下示範, 如何在不同的專案底下建立跳板機跟 GKE 叢集,  並透過 VPN 的方式在跳板機上去操作另一個專案下的 GKE 叢集 在 Project A 建立 VPC #1 variable "gke_project" {   default = "prj-1" } variable "gke_network_name" {   default = "net-1" } variable "gke_subnet_name" {   default = "subnet-1" } resource "google_compute_network" "gke_vpc_network" {   project                 = var.gke_project   name                    = var.gke_network_name   auto_create_subnetworks = false } resource "google_compute_subnetwork" "gke_vpc_subnet" {   project                 = var.gke_project   name          = var.gke_subnet_name   ip_cidr_range = "10.51.0.0/23"   region       ...