Coder Social home page Coder Social logo

nftset flags: timeout about chinadns-ng HOT 15 CLOSED

gityoog avatar gityoog commented on July 19, 2024
nftset flags: timeout

from chinadns-ng.

Comments (15)

zfl9 avatar zfl9 commented on July 19, 2024 1

不对不对,nft set 也可以在创建 set 时指定 timeout。看文档:

% nft add table ip filter
% nft add set ip filter ports {type inet_service \; timeout 3h45s \;}

timeout, it determines how long an element stays in the set. The time string respects the format: "v1dv2hv3mv4s":

from chinadns-ng.

cattyhouse avatar cattyhouse commented on July 19, 2024 1

如果你是想一个set里面

  • 既包含 不会timeout 的元素
  • 又包含 会timeout 的元素

那我的建议是分开两个set,不要这样混用。

iptables和nftables可以自由的在一条rule里面match多个set的,没必要把复杂度挪到chinadns这边来。

ipset 倒是可以同时满足这两条的哦

  1. 设置 header timeout : create proxy hash:net family inet timeout 21600
  2. 添加timeout 0 的条目: add proxy 1.1.1.1 timeout 0 add proxy 8.8.8.8 timeout 0 ...

这样 chinadns-ng 添加的 ipset 条目就会遵守 header 里面设置的 timeout 也就是 21600s (6h), 其余的就是永久.

from chinadns-ng.

zfl9 avatar zfl9 commented on July 19, 2024

收到,我才发现 nftset 不能像 ipset 那样,在创建 set 时指定 element 的默认超时值。必须每个 element 都带上 timeout 参数(好吧,其实是可以的,被误导了)。

from chinadns-ng.

gityoog avatar gityoog commented on July 19, 2024

收到,我才发现 nftset 不能像 ipset 那样,在创建 set 时指定 element 的默认超时值。必须每个 element 都带上 timeout 参数。

是的 ipset的timeout是在创建的时候设置的 nftset是在添加element的时候设置的

from chinadns-ng.

zfl9 avatar zfl9 commented on July 19, 2024

另外你这个报错,应该是 add set 时,flags 少了,看 readme:

image

from chinadns-ng.

gityoog avatar gityoog commented on July 19, 2024

另外你这个报错,应该是 add set 时,flags 少了,看 readme:

image

我的flags创建的是timeout

from chinadns-ng.

zfl9 avatar zfl9 commented on July 19, 2024

所以我说flags少了,flags可以多个,逗号隔开。

也就是说,flags 必须至少包含 interval。

from chinadns-ng.

gityoog avatar gityoog commented on July 19, 2024

所以我说flags少了,flags可以多个,逗号隔开。

也就是说,flags 必须至少包含 interval。

nft add set ip nat outside { type ipv4_addr; flags interval; timeout 1h; }
解决了感谢

from chinadns-ng.

zfl9 avatar zfl9 commented on July 19, 2024

但是在这里的用例,不需要 flags timeout,只需要 flags interval; timeout xx;

from chinadns-ng.

hyfink avatar hyfink commented on July 19, 2024

但是在这里的用例,不需要 flags timeout,只需要 flags interval; timeout xx;

希望chinadns-ng可以添加nftset-timeout参数,用来单独控制chinadns主动添加到set里面的ip的timeout。定义set时候就指定timeout xx的话,整个set都会过期。这样和其他代理共用一个set的话,会有问题。 @zfl9

from chinadns-ng.

zfl9 avatar zfl9 commented on July 19, 2024

没有整个set过期,在set级别设置timeout只是给那些进入该set的element提供一个默认的timeout值而已

from chinadns-ng.

zfl9 avatar zfl9 commented on July 19, 2024

如果你是想一个set里面

  • 既包含 不会timeout 的元素
  • 又包含 会timeout 的元素

那我的建议是分开两个set,不要这样混用。

iptables和nftables可以自由的在一条rule里面match多个set的,没必要把复杂度挪到chinadns这边来。

from chinadns-ng.

hyfink avatar hyfink commented on July 19, 2024

如果你是想一个set里面

  • 既包含 不会timeout 的元素
  • 又包含 会timeout 的元素

那我的建议是分开两个set,不要这样混用。

iptables和nftables可以自由的在一条rule里面match多个set的,没必要把复杂度挪到chinadns这边来。

我想的的确是这样。

说下我这边情况:
代理软件会根据源ip、目标ip等条件自动生成一些nftset和rules,并且有一整条rule chain控制流量走向。这里面的rules都是代理代码生成的,用户只能增删相应的nftset里面的ip。自己手动编写额外的nft文件倒也可行,但是毕竟麻烦且不够优雅(相当于把代理的rules复制一遍唯独换一下里面match的nftset),想了下这样做不行。所以希望dns软件能直接复用代理的nftset。

from chinadns-ng.

zfl9 avatar zfl9 commented on July 19, 2024

那请开一个新issue。

from chinadns-ng.

zfl9 avatar zfl9 commented on July 19, 2024

nftset 其实也可以,只不过“永久”的条目不能用 timeout 0s 实现,要用 timeout 99999d(或类似的值,总之近似永久)。

from chinadns-ng.

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.