V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
unknow01
V2EX  ›  Linux

关于两个局域网之间使用 wireguard 的问题

  •  
  •   unknow01 · 2022-09-16 13:28:59 +08:00 · 1566 次点击
    这是一个创建于 559 天前的主题,其中的信息可能已经有所发展或是发生改变。

    https://imgur.com/mWwfAF6

    VPS---net.ipv4.ip_forward = 1 ---wg0.conf [Interface] PrivateKey = VPS PrivateKey Address = 30.100.100.1/24 ListenPort = 54321

    [Peer] PublicKey = Client A PublicKey AllowedIPs = 30.100.100.2/32

    [Peer] PublicKey = Client B PublicKey AllowedIPs = 30.100.100.3/32,20.20.20.0/24

    Client A---wg0.conf [Interface] PrivateKey = Client A PrivateKey Address = 30.100.100.2/24

    [Peer] PublicKey = VPS PublicKey AllowedIPs = 30.100.100.0/32 Endpoint = 1.2.3.4:54321 PersistentKeepalive = 25

    Client B---net.ipv4.ip_forward = 1 ---wg0.conf [Interface] PrivateKey = Client B PrivateKey Address = 30.100.100.3/24

    [Peer] PublicKey = VPS PublicKey AllowedIPs = 30.100.100.0/32 Endpoint = 1.2.3.4:54321 PersistentKeepalive = 25

    如图所示:系统基本为 Debian/ubuntu ,在 ClientC 没有公网 IP 和不用安装 WireGuard 的情况下(在 RouterB 下还有其他设备:如 ClientD[提供 FTP 服务]),ClientA 如何透过 ClientB 访问 ClientC(D.E.F...) 所提供的服务,请各位帮帮忙把详细的设置和命令告诉一下,谢谢。

    5 条回复    2022-09-16 16:53:05 +08:00
    smallparking
        1
    smallparking  
       2022-09-16 14:21:39 +08:00 via Android
    tailscale
    olaloong
        2
    olaloong  
       2022-09-16 14:36:12 +08:00
    Client A 的 AllowedIPs 里加上 20.20.20.0/24 ,或者手动加路由表 试试
    还不行的话检查 Client B 的 iptables ,FORWARD 什么的得放行
    olaloong
        3
    olaloong  
       2022-09-16 14:38:22 +08:00
    我是把 4 张局域网连接起来的,在各自局域网的路由上做了 WireGuard ,网下所有设备可以用各自局域网 ip 互访

    不过时间长了,配置有点忘了
    aver4vex
        4
    aver4vex  
       2022-09-16 15:12:16 +08:00
    我是在 clientb 上用 firewalld 做流量重定向,
    firewall-cmd --zone=public --add-masquerade
    firewall-cmd
    --zone=public
    --add-forward-port=port=13389:proto=tcp:toport=3389:toaddr=192.168.0.4
    lsww
        5
    lsww  
       2022-09-16 16:53:05 +08:00
    tailscale 是神器,直接把家里 NAS 用 RADIDRIVE 挂到了本地。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1018 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 19:44 · PVG 03:44 · LAX 12:44 · JFK 15:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.