PowerDNS / pdns

PowerDNS Authoritative, PowerDNS Recursor, dnsdist
https://www.powerdns.com/
GNU General Public License v2.0
3.69k stars 907 forks source link

dnsdist: feature request: add weight and/or order to rules #7424

Open spirillen opened 5 years ago

spirillen commented 5 years ago

Usecase

definition: weight should be understood as groupRule|ruleGroup

First use case: You have your scripts distributed in diff. files based on function rather than a 10000 lines long conf.lua. Written rules could be used as subsets for other rules and you might control that a regexRule should be rule #3 and not #0 and the be related to group2 and group4 (weight) independent from pool, so now this rules could look like

addAction(RegexRule("(^|\\.)ads\\."), RCodeAction(dnsdist.NXDOMAIN) weight='{2,4}' order='3') Since this action should apply to all pools the weight and order becomes handy here.

Second use case: If we take the same example as usecase 1, but we need this rule to out rule everything else no matter what it is rule #=0 then we apply it either by cli, api or script as..

addAction(RegexRule("(^|\\.)ads\\."), RCodeAction(dnsdist.NXDOMAIN) order='0')

However this action would in ex. be equal:

addAction(RegexRule("(^|\\.)ads\\."), RCodeAction(dnsdist.NXDOMAIN))
topRule()

Description

In this way you can save commands like mvRule and topRule and it should work on api level as well

Give it some thought, as lieter said... could be nice but maybe hard :)
My thought is (haven't read the code), but is it possible to simply adapt this from the newServer module/code part?

spirillen commented 5 years ago

Third use-case could be that you have your recurser set up to distribute the answer based on roundrobin or geoip etc. Now you figure out that one of those server is infected, or not responding, anyway it's misbehave and you should like to redirect any request to that server to another, disregard other rulesets, then you only had to do:

addAction(SpoofAction(ip[, ip[...]] rule='5')

Fast and easy place a rule to disengage the server running on that ip and route the traffic to another server.....