發表文章

目前顯示的是 8月, 2020的文章

lubuntu install wireguard

筆者前幾天為我舊筆電安裝了wireguard server 之前這舊筆電是拿來當honeypot的,但現在重灌後,就當VPN server 不多說 上code: [server端] #開terminal以root權限執行 sudo apt update sudo apt upgrade sudo apt install wireguard cd /etc/wireguard/ umask 077; wg genkey | tee privatekey | wg pubkey > publickey cat privatekey #這邊是伺服器私鑰要記好 不要洩漏 cat publickey #伺服器公鑰 一樣要記好 sudo vim /etc/wireguard/wg0.conf 把以下寫進去: [Interface] ## My VPN server private IP address ## Address = 10.0.0.1/24 #這邊切24 你可以根據你的需求來改 ## My VPN server port ## ListenPort = 41194 PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o [你的對外網卡名稱] -j MASQUERADE; sysctl net.ipv4.ip_forward=1 ## VPN server's private key i.e. /etc/wireguard/privatekey ## PrivateKey = [伺服器密鑰] DNS = 8.8.8.8 MTU = 1420 寫完以後 啟動一下 看看有無異常: sudo systemctl enable wg-quick@wg0 sudo systemctl start wg-quick@wg0 sudo systemctl status wg-quick@wg0 然後 在/etc/wireguard底下 新增一個sigh.sh 或是XXX.sh 輸入: #!/bin/bash server_pub_key=$(cat /etc/wireguard/publickey) read -