V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
heeay
V2EX  ›  WireGuard

请教一个 wireguard 网络出口问题

  •  
  •   heeay · Dec 8, 2021 · 2236 views
    This topic created in 1610 days ago, the information mentioned may be changed or developed.

    图片注释

    4 replies    2021-12-08 18:55:14 +08:00
    madao2015
        1
    madao2015  
       Dec 8, 2021
    r1 上应该可以用 iptables 把 c1 的请求转发到 r2 去
    mogita
        2
    mogita  
       Dec 8, 2021
    可以试试:在 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
       Dec 8, 2021
    @madao2015 感谢提供思路
    heeay
        4
    heeay  
    OP
       Dec 8, 2021
    @ck65 由于 C1 是客户端 如果 AllowedIPs 不写四个 0 就只能路由 wireguard 内网 ip 达不到上述的要求
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3269 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 13:05 · PVG 21:05 · LAX 06:05 · JFK 09:05
    ♥ Do have faith in what you're doing.