Giter Site home page Giter Site logo

Comments (13)

clowwindy avatar clowwindy commented on June 29, 2024

默认不删除是个好办法,但这样每次重启都会增加一条 iptables 重复的规则,有什么好的方式处理么?

from shadowvpn.

aa65535 avatar aa65535 commented on June 29, 2024

关闭NAT, 说的是下面三条么?

iptables -t nat -D POSTROUTING -o $gw_intf -j MASQUERADE
iptables -D FORWARD -i $gw_intf -o $intf -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -D FORWARD -i $intf -o $gw_intf -j ACCEPT

应该是不执行第一条。

防止重复只能在添加前判断一下了。

if !(iptables-save -t nat | grep -q "^-A POSTROUTING -o $gw_intf -j MASQUERADE"); then
    iptables -t nat -A POSTROUTING -o $gw_intf -j MASQUERADE
fi

如果是这样的话,还是自己修改脚本就能解决的啊。
如果说默认只是建立一个内网隧道,其他都需要用户自己去完成,我觉得目前的处理更合理,
可以完成上面这些操作的,修改脚本自然也不是问题。

至于隧道IP 的修改是在哪里完成的问题,如果内置到 shadowvpn 也是合理的,不过直接使用命令的话,简单是一个优势。

from shadowvpn.

cj1324 avatar cj1324 commented on June 29, 2024

@lsylsy2 我把这个特性(ifconfig部分)加到我自己的分支上了~

from shadowvpn.

clowwindy avatar clowwindy commented on June 29, 2024

集成脚本的功能的话就丧失了多 IP、多出口分流的灵活度,而这是公司网络环境使用必备的。

from shadowvpn.

cj1324 avatar cj1324 commented on June 29, 2024

@clowwindy 恩,你说的偏高级特性。 一个开关选项的就能解决这问题。openvpn --ifconfig-noexec
默认应该是自动配置IP (或者说用简单配置代替shell),降低普通用户的使用成本。
虽然C语言难以调试,但是实际上这部分代码量也不大。
不过我没考虑windows支持,因为不熟悉。 @linusyang

from shadowvpn.

clowwindy avatar clowwindy commented on June 29, 2024

用户想解决的无非就是误删 iptables NAT 规则、iptables 转发规则和路由器自带的几个 table 顺序有要求等各种环境兼容问题,用 shell 这样灵活的语言都做不好,用 C 就更做不好了。

如果只是把 IP 移到配置文件里,或者加一些开关选项,现在就可以移,脚本里可以读所有配置变量,把脚本里的 IP 挪到配置文件里 ip=x.x.x.x,在脚本里读 $ip 变量就可以了。这样一些比较 low 的用户改 conf 就可以控制一些参数,其它用户还是可以自定义脚本来兼容他的环境。

在 OpenWRT 上我觉得最好还是应该把 interface 和路由表、启动和停用时的 hook 的配置都交给 UCI 来做,VPN 只提供 interface。事实上,pppoe 断掉重连之后 ShadowVPN 是不需要重启的,只需要重新执行脚本配置 ip 和路由,这可以在 OpenWRT 提供的 hotplug 里做。如果是用反过来的 foreign routes,ip 和路由都不用修改。

from shadowvpn.

cj1324 avatar cj1324 commented on June 29, 2024

在OpenWRT中 我目前是手动修改 /etc/config/network 和 /etc/config/firewall 额外追加一个 /etc/config/shadowvpn , 比较繁琐,但是一次性操作。

通用化

  • 自己编译的话可以打到固件里。
  • opkg包安装的时候可以通过uci命令进行一次性追加配置操作。

目前还没特别好的路由相关处理策略。

其他平台的打包方式我了解不多。

说直接一点,减少shell 依赖,对普通用户屏蔽这些细节。

from shadowvpn.

clowwindy avatar clowwindy commented on June 29, 2024

既然另外开了一个,那这个就关了。不然要盯两个 issue,容易各说各的。

from shadowvpn.

clowwindy avatar clowwindy commented on June 29, 2024

当/etc/init.d/shadowvpn stop时,所有VPN用户都会崩溃,经过检查是server_stop中自动关闭了iptable的NAT功能导致。

我又看了一下 server_down.sh,里面的 iptables -D 是带 tun 名称的,不是全局的,所以理论上不会对其它 VPN 软件产生影响。所以你需要排查一下别的原因。

from shadowvpn.

lsylsy2 avatar lsylsy2 commented on June 29, 2024

#iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
这是我用apt-get安装的服务器(我自己注释掉的)
可能是我在测试的时候频繁restart出的问题?理论上这一句应该在server_up时候被重复加入(iptables内有多条相同的规则),down的时候只删除一个?可能我在测试脚本、restart的时候某次多删除了。

from shadowvpn.

clowwindy avatar clowwindy commented on June 29, 2024

我看错了,MASQUERADE 是没有的。能否通过 comment 来和其它 rule 区分呢?

from shadowvpn.

lsylsy2 avatar lsylsy2 commented on June 29, 2024

这点不太清楚;另外目前我的服务器上,是同时存在着多条MASQUERADE的;我马上回复到另一个issue。

from shadowvpn.

aa65535 avatar aa65535 commented on June 29, 2024

的确是因为 down script 里的 iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE 关闭的。
可以使用 comment 区分

iptables -t nat -A POSTROUTING -o $gw_intf -m comment --comment "$gw_intf (turn_on_nat)" -j MASQUERADE

iptables -t nat -D POSTROUTING -o $gw_intf -m comment --comment "$gw_intf (turn_on_nat)" -j MASQUERADE

from shadowvpn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.