V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
slowhand
V2EX  ›  WireGuard

求助, windows 版本的 WireGuard,内网测试连接可以,切换到公网映射端口,就连不上

  •  
  •   slowhand · 281 天前 · 1352 次点击
    这是一个创建于 281 天前的主题,其中的信息可能已经有所发展或是发生改变。

    windows 版本的 WireGuard ,内网测试连接可以,切换到公网映射端口,就连不上。 不知道是配置问题,还是被墙了(服务器在本地)。 配置如下: 服务端配置

    [Interface]
    PrivateKey = ……
    ListenPort = 8072
    Address = 192.168.200.200/32
    [Peer]
    PublicKey = ……
    AllowedIPs = 192.168.200.201/32
    

    客户端配置

    [Interface]
    PrivateKey = ……
    Address = 192.168.200.201/32
    [Peer]
    PublicKey = ……
    AllowedIPs = 0.0.0.0/1, 128.0.0.0/1
    Endpoint = xxx.xxx.xxx.xxx:18072
    

    公网端口连不上,流量显示只有发,没有收。 日志则是:

    Sending handshake initiation to peer 1 (xxx.xxx.xxx.xxx:18072)
    ……
    Handshake for peer 1 (xxx.xxx.xxx.xxx:18072) did not complete after 5 seconds, retrying (try 2)
    
    11 条回复    2023-07-21 19:55:40 +08:00
    yyysuo
        1
    yyysuo  
       281 天前   ❤️ 1
    1:检查一下域名解析是否正常。
    2:服务端如果在主路由上,是 docker 版本的话,固件可能存在端口回流的问题,可能需要换固件。
    3:检查主路由的端口映射。

    我的主路由是 10.10.10.1 ,wireguard 服务端部署在非主路由的内网机上,配置如下
    [Interface]
    PrivateKey = xxxxxxxxxx
    Address = 10.8.0.8/24
    DNS = 10.10.10.1

    [Peer]
    PublicKey = xxxxxxx
    PresharedKey = xxxxxxxxx
    AllowedIPs = 0.0.0.0/0, ::/0, 192.168.1.0/24, 10.10.10.0/24, 192.168.4.0/24, 192.168.123.0/24
    Endpoint = mydomian:myport
    iniMeow
        2
    iniMeow  
       281 天前   ❤️ 1
    子网掩码问题? 32 改成 24
    zbinlin
        3
    zbinlin  
       281 天前   ❤️ 1
    为什么服务器的监听端口是 8072 ,而客户端配置的 endpoint 里端口是 18072 ?
    bt7vip
        4
    bt7vip  
       281 天前 via Android   ❤️ 1
    @zbinlin 端口对不上确实显示有发无收
    ZRS
        5
    ZRS  
       281 天前 via iPhone   ❤️ 1
    可能是 hairpin nat 配置不正确的问题
    slowhand
        6
    slowhand  
    OP
       281 天前
    感谢帮助!

    @yyysuo 域名解析正常,配置里面写的是域名,日志里显示是:to peer 1 (IP 和端口)。

    服务端放在 windows 系统的虚拟机上( VMware )。

    端口映射测试正常。用网络助手分别创建 tcpserver 和 tcpclient 连接测试的(用的域名和端口)

    @iniMeow 试了一下,还是不行。

    @zbinlin @bt7vip 内部端口 8072 ,映射到外部 18072

    @ZRS 不太了解,我查一下。
    emberzhang
        7
    emberzhang  
       280 天前   ❤️ 2
    wireguard 不是走的 UDP 么
    bt7vip
        8
    bt7vip  
       280 天前 via Android   ❤️ 1
    你是怎么部署的,是将部署在本地 Windows 服务端的暴露在外,外面连进来吗?这种情况 Windows 是可以的,公钥私钥要填对。
    如果是 VPS 部署,搭网桥连进家里,好像 Windows 做网桥 不好实现,用 Linux 几条防火墙转发就可以了。
    我最开始是用 tcpdump 看 cl 流量有没有发出去,server 流量有没有进来,有没有转出去一步一步排查的,踩过很多坑,熟练了就很快了,现在 win ,Linux ,Android 三端组网。
    slowhand
        9
    slowhand  
    OP
       280 天前
    @bt7vip 就是 windows 主机,通过端口映射,暴露到公网,想要从外面连进来。
    映射端口也测试过,正常的(比如内网端口发布 web 页面,公网 IP 加映射端口可以正常访问)。
    同内网下,客户端的 Endpoint 配置服务端的内网 IP 和端口,可以正常连接;
    但是配置成公网 IP 和映射端口,则连不上。(试过胡乱填端口,也是同样现象)
    zbinlin
        10
    zbinlin  
       280 天前   ❤️ 1
    wireguard 用的是 UDP 的,你端口映射时选对了协议没?
    emberzhang
        11
    emberzhang  
       280 天前   ❤️ 1
    windows 做服务端记得再看看系统防火墙开放端口没
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2772 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 05:39 · PVG 13:39 · LAX 22:39 · JFK 01:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.