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

搭建了 openvpn 有些疑问。

  •  
  •   Damow · 2023-01-19 13:39:52 +08:00 · 1486 次点击
    这是一个创建于 460 天前的主题,其中的信息可能已经有所发展或是发生改变。
    1.我在家软路由上搭建了 openvpn ,在单位用我的笔记本进行连接。发现流量全走 openvpn ,也能用软路由上的科学上网。相当于流量往家里软路由兜了一圈才出去。

    2.然后,我把 openvpn 服务器搭建在 NAS 上,现在笔记本流量都走单位的宽带,能直接访问家里局域网。

    3.疑问:openvpn 还不是一样在同个局域网上吗?也一样走家里软路由出站。为什么搭建在软路由上,全部流量会往家里转一圈,还是我没设置好?
    第 1 条附言  ·  2023-01-19 20:00:32 +08:00
    #redirect-gateway def1
    在配置中看到这个。
    注释:
    If redirect-gateway is enabled, the client will redirect it's default network gateway through the VPN. It means the VPN connection will firstly connect to the VPN Server and then to the internet.

    如果开启的话,流量会全部走 openvpn 。关闭的话,只有局域网的 ip 段和服务端分配的 ip 段走 openvpn 。

    看了路由表,我的 192.168.11.0 和 192.168.12.0 都走 192.168.12.5 网关。
    11 条回复    2024-03-05 16:08:19 +08:00
    XiLingHost
        1
    XiLingHost  
       2023-01-19 13:43:14 +08:00
    看看路由表写的是不是有问题,还有 openvpn 的配置里也有写入默认路由的配置
    RRyo
        2
    RRyo  
       2023-01-19 14:33:48 +08:00
    用 openvpn+默认路由关键词可以查到相关的东西
    类似 https://www.xiaoxk.com/openvpn-route-settings
    huangya
        3
    huangya  
       2023-01-19 15:18:27 +08:00
    server 端的配置文件不一样。server 可以 push 路由给客户端。我相信你 NAS 上的服务器配置是 NAS 厂商给你弄好的。图形界面上只提供有限的几个选项配置。
    BanShe
        4
    BanShe  
       2023-01-19 16:17:36 +08:00
    route-nopull
    然后自己写要走 vpn 的路由
    Damow
        5
    Damow  
    OP
       2023-01-19 17:01:05 +08:00 via iPhone
    @BanShe 好,非常感谢。
    Damow
        6
    Damow  
    OP
       2023-01-19 17:01:16 +08:00 via iPhone
    @huangya 群晖自带的套件。
    Damow
        7
    Damow  
    OP
       2023-01-19 17:01:24 +08:00 via iPhone
    @RRyo 非常感谢。研究看看。
    muhahaha
        8
    muhahaha  
       2023-01-19 18:43:40 +08:00 via iPhone
    我这是全部走了家里网络,但是没走科学上网,请问这是什么原因?
    Damow
        9
    Damow  
    OP
       2023-01-19 19:49:18 +08:00
    @muhahaha 我开始用 openwrt 搭建的,配置文件默认。然后我接入后,可以科学上网。我刚刚弄明白了。
    #redirect-gateway def1
    注释这个就全部流量走 openvpn ,我看了路由表。只有我家里局域网 192.168.11.x 和 openvpn 的 192.168.12.x 才会走 openvpn
    muhahaha
        10
    muhahaha  
       2023-01-19 21:41:23 +08:00 via iPhone
    @Damow 感谢
    Eyulaodu
        11
    Eyulaodu  
       48 天前
    请教一下,如何设置,才能做到普通网络走手机的流量,而需要科学的走家里的 openvpn 服务器?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5370 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 06:59 · PVG 14:59 · LAX 23:59 · JFK 02:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.