差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

兩邊的前次修訂版 前次修改
下次修改
前次修改
tech:wireguard [2023/11/15 23:27] – [採用 weejewel/wg-easy 版本(包含 WebUI)] jonathantech:wireguard [2024/04/12 20:53] (目前版本) – [host Alpine 升級到 3.19 之後啟動異常解決方法] jonathan
行 21: 行 21:
       - PASSWORD=myPassword       - PASSWORD=myPassword
       - WG_PORT=51820       - WG_PORT=51820
-      - WG_DEFAULT_ADDRESS=10.8.0.x+      - WG_DEFAULT_ADDRESS=10.13.12.x
       - WG_DEFAULT_DNS=192.168.11.6       - WG_DEFAULT_DNS=192.168.11.6
       # - WG_MTU=1420       # - WG_MTU=1420
行 33: 行 33:
     container_name: wg-easy     container_name: wg-easy
     volumes:     volumes:
-      - ./ect_wireguard:/etc/wireguard+      - ./etc_wireguard:/etc/wireguard
     ports:     ports:
       - "51820:51820/udp"       - "51820:51820/udp"
行 45: 行 45:
       - net.ipv4.conf.all.src_valid_mark=1       - net.ipv4.conf.all.src_valid_mark=1
 </file> </file>
 +  * 啟動服務 <cli>
 +docker compose up -d
 +</cli>
 +  * 可以使用瀏覽器 http://server-ip:51821 輸入設定密碼(myPassword)登入管理介面進行 vpn 使用者管理
 +  * 詳細設定參數請參考 - https://github.com/wg-easy/wg-easy#options
 +
 +==== 修改 Listen Port ====
 +  * Exp. 將原本 Listen Port udp/51820 改成 udp/123 (預設 ntp port)<cli>
 +vi docker-compose.yml
 +</cli>修改以下 ports 設定<file>
 +:
 +      - WG_PORT=51820
 +:
 +    ports:
 +      - "123:51820/udp"
 +:
 +</file>
 +
 +===== FAQ =====
 +  - host Alpine 升級到 3.19 之後啟動時 log 出現 <cli>
 +:
 +iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT;
 +modprobe: can't change directory to '/lib/modules': No such file or directory
 +modprobe: can't change directory to '/lib/modules': No such file or directory
 +iptables v1.8.3 (legacy): can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
 +Perhaps iptables or your kernel needs to be upgraded.
 +:
 +</cli>
 +    * Ans : 需要在 host (Alpine 3.19) 執行以下指令<cli>
 +modprobe ip_tables
 +echo 'ip_tables' >> /etc/modules
 +</cli>並重新開機即可解決
 +    * 參考 - https://github.com/wg-easy/wg-easy/discussions/976 
  
-===== 採用 linuxserver/wireguard 版本 =====+===== 採用 linuxserver/wireguard 版本(無 WebUI) =====
   * 採用 [[https://hub.docker.com/r/linuxserver/wireguard|linuxserver/wireguard]] 的 docker image    * 採用 [[https://hub.docker.com/r/linuxserver/wireguard|linuxserver/wireguard]] 的 docker image 
   * 執行以下語法 <cli>   * 執行以下語法 <cli>
行 84: 行 117:
 </cli> </cli>
  
-===== 修改 Listen Port =====+==== 修改 Listen Port ====
   * Exp. 將原本 Listen Port udp/51820 改成 udp/123 (預設 ntp port)<cli>   * Exp. 將原本 Listen Port udp/51820 改成 udp/123 (預設 ntp port)<cli>
 vi docker-compose.yml vi docker-compose.yml
行 103: 行 136:
 </file> </file>
  
-===== 建立指定 Client 的憑證 =====+==== 建立指定 Client 的憑證 ====
   * Exp. 將原本 environment 的 PEERS=1 改成要建立 Client 的 id 清單, Exp. jonathan,lin,lin2,stanley,jerry<cli>   * Exp. 將原本 environment 的 PEERS=1 改成要建立 Client 的 id 清單, Exp. jonathan,lin,lin2,stanley,jerry<cli>
 vi docker-compose.yml vi docker-compose.yml
行 128: 行 161:
 </cli> </cli>
  
-===== 刪除特定 Client 的憑證 =====+==== 刪除特定 Client 的憑證 ====
   * Exp. 將原本 environment 的 PEERS= 將特定 Client 的 id 刪除, Exp. 刪除 lin2 : PEERS=jonathan,lin,lin2,stanley,jerry -> PEERS=jonathan,lin,stanley,jerry<cli>   * Exp. 將原本 environment 的 PEERS= 將特定 Client 的 id 刪除, Exp. 刪除 lin2 : PEERS=jonathan,lin,lin2,stanley,jerry -> PEERS=jonathan,lin,stanley,jerry<cli>
 vi docker-compose.yml vi docker-compose.yml
行 144: 行 177:
 </cli>這樣之後若有重建 lin2 這相同 Client id , 就會產生新的憑證 </cli>這樣之後若有重建 lin2 這相同 Client id , 就會產生新的憑證
  
-===== 顯示目前 Client 憑證與連線狀態 =====+==== 顯示目前 Client 憑證與連線狀態 ====
   * 主要是使用 wg 這命令來查詢 Exp. <cli>   * 主要是使用 wg 這命令來查詢 Exp. <cli>
 wgvpn:~# docker exec -it wireguard wg wgvpn:~# docker exec -it wireguard wg
行 186: 行 219:
 </note> </note>
  
-===== 後續須持續了解項目 ===== +==== 後續須持續了解項目 ==== 
   * WireGuard Web UI 方案 - https://github.com/ngoduykhanh/wireguard-ui/ (初步使用 [[https://github.com/ngoduykhanh/wireguard-ui/tree/master/examples/docker-compose|docker-compose]] 範例修改, 還無法正常運作)   * WireGuard Web UI 方案 - https://github.com/ngoduykhanh/wireguard-ui/ (初步使用 [[https://github.com/ngoduykhanh/wireguard-ui/tree/master/examples/docker-compose|docker-compose]] 範例修改, 還無法正常運作)
   * Client 端設為 [[https://www.utunnel.io/help/what-is-split-routing|split routing]] 模式    * Client 端設為 [[https://www.utunnel.io/help/what-is-split-routing|split routing]] 模式 
  • tech/wireguard.1700062028.txt.gz
  • 上一次變更: 2023/11/15 23:27
  • jonathan