Distributions
› Ubuntu
› Fedora
› CentOS
中文资源站
› 网易开源镜像站
LxnChan
V2EX  ›  Linux

求问 Wireguard 相关配置

  •  
  •   LxnChan ·
    lxnchan · Jun 20, 2023 · 3367 views
    This topic created in 1233 days ago, the information mentioned may be changed or developed.

    现在搭好了一个 Wireguard 的服务端,这里姑且称为 ServerA 。ServerA 上生成了一对 PublicKey 和 PrivateKey ,这里称为 PubKeyA 和 PrivKeyA 。

    1. ServerA 的 wg0.conf 配置文件如下:
      [Interface]
      Address = 10.0.0.1/24
      SaveConfig = true
      ListenPort = 51820
      PrivateKey = PrivKeyA
      PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
      PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
      
    2. 随后通过 systemd 启动 Wireguard ,并通过命令看到 Wireguard 正在运行:
      interface: wg0
        public key: PubKeyA
        private key: (hidden)
        listening port: 51820
      
    3. 构建客户端配置文件
      [Interface]
      PrivateKey = 
      Address = 10.0.0.1/24
      
      [Peer]
      PublicKey = 
      AllowedIPs = 0.0.0.0/0
      Endpoint = myserver.cn:51820
      
      这个时候 Windows 端的 Wireguard 会自动生成一组公钥私钥,那么在客户端的配置文件中应该用哪个公钥和哪个私钥呢
    13 replies  •  2023-06-21 11:13:09 +08:00
    listenfree
    listenfree
    Jun 20, 2023
    1
    我有私钥、公钥给你,你有私钥、公钥给我。
    shimc
    shimc
    Jun 20, 2023
    2
    客户端:用客户端私钥、服务端公钥
    233373
    233373
    Jun 20, 2023
    3
    wireguard 不分服务端客户端
    ysc3839
    ysc3839
    Jun 20, 2023
    4
    客户端配置文件里的 PublicKey 填 PubKeyA ,服务端要添加 Peer ,PublicKey 填客户端的公钥
    LxnChan
    LxnChan
    OP
    Jun 20, 2023
    5
    @listenfree 哦草,一下就懂了
    @ysc3839 那每多加一个客户端服务端就需要新增一个 Peer 吗
    ysc3839
    ysc3839
    Jun 20, 2023
    6
    @LxnChan 是的
    wheat0r
    wheat0r
    Jun 20, 2023
    7
    wireguard 其实是个站到站 vpn
    itechify
    itechify
    Jun 20, 2023 via Android
    8
    偶遇泠泫凝大佬
    GoodRui
    GoodRui
    Jun 20, 2023 via Android
    9
    @wheat0r 大佬,之前用过一段时间 wg ,连接还行,就是用户多了应该怎么管理?还有就是能不能方便的做细粒度的访问控制呢?
    wheat0r
    wheat0r
    Jun 21, 2023
    10
    @GoodRui 没用过 wireguard ,只知道这东西不适合你所说的场景
    ysc3839
    ysc3839
    Jun 21, 2023
    11
    @GoodRui Tailscale?
    ricwangcom
    ricwangcom
    Jun 21, 2023
    12
    为啥不直接用 open VPN ?
    LxnChan
    LxnChan
    OP
    Jun 21, 2023 via Android
    13
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5599 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 46ms · UTC 03:05 · PVG 11:05 · LAX 19:05 · JFK 22:05
    ♥ Do have faith in what you're doing.