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

请教一个 wireguard 网络出口问题

  •  
  •   heeay · 2021-12-08 10:19:45 +08:00 · 1279 次点击
    这是一个创建于 868 天前的主题,其中的信息可能已经有所发展或是发生改变。

    图片注释

    4 条回复    2021-12-08 18:55:14 +08:00
    madao2015
        1
    madao2015  
       2021-12-08 11:10:18 +08:00
    r1 上应该可以用 iptables 把 c1 的请求转发到 r2 去
    ck65
        2
    ck65  
       2021-12-08 11:14:51 +08:00
    可以试试:在 C1 、R1 的 AllowedIPs 里加上 R2 的内网 IP/32 ,而不填写四个 0 。同时 R1 、R2 的 wg0.conf 里确保开启转发:

    PreUp = sysctl -w net.ipv4.ip_forward=1
    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
    heeay
        3
    heeay  
    OP
       2021-12-08 18:49:41 +08:00
    @madao2015 感谢提供思路
    heeay
        4
    heeay  
    OP
       2021-12-08 18:55:14 +08:00
    @ck65 由于 C1 是客户端 如果 AllowedIPs 不写四个 0 就只能路由 wireguard 内网 ip 达不到上述的要求
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3663 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 04:36 · PVG 12:36 · LAX 21:36 · JFK 00:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.