folbricht / routedns

DNS stub resolver, proxy and router with support for DoT, DoH, DoQ, and DTLS
BSD 3-Clause "New" or "Revised" License
479 stars 63 forks source link

How to configure client whitelist #392

Closed liang-hiwin closed 5 months ago

liang-hiwin commented 6 months ago

I want to configure that only IPs that comply with CIDR can use dns.

folbricht commented 6 months ago

That seems straightforward, like in https://github.com/folbricht/routedns/blob/master/cmd/routedns/example-config/client-blocklist-drop.toml Just need to set resolver to something that blocks, and blocklist-resolver to something that forwards the query.

liang-hiwin commented 6 months ago

That seems straightforward, like in https://github.com/folbricht/routedns/blob/master/cmd/routedns/example-config/client-blocklist-drop.toml Just need to set resolver to something that blocks, and blocklist-resolver to something that forwards the query.

I need a whitelist IP list, such as building a dns server whitelisted IP or a whitelisted country IP before I can use it.

folbricht commented 5 months ago

If you need to block/allow responses based on geo location, there's an example in https://github.com/folbricht/routedns/blob/master/cmd/routedns/example-config/response-blocklist-geo.toml#L8 Or if you want to block clients based on location you can look at https://github.com/folbricht/routedns/blob/master/cmd/routedns/example-config/client-blocklist-geo.toml

liang-hiwin commented 5 months ago

If you need to block/allow responses based on geo location, there's an example in https://github.com/folbricht/routedns/blob/master/cmd/routedns/example-config/response-blocklist-geo.toml#L8 Or if you want to block clients based on location you can look at https://github.com/folbricht/routedns/blob/master/cmd/routedns/example-config/client-blocklist-geo.toml

I want to implement a function similar to nginx. For example

allow 1.1.8.0/24; allow 1.1.8.0/24; allow 1.116.0.0/15; ..... deny all;

cbuijs commented 5 months ago

It can be done like this:

[groups.client-allowlist]
type = "client-blocklist"
resolvers = ["deny-client"]
blocklist-resolver = "allow-client"
blocklist = [
  '1.1.8.0/24',
  '1.116.0.0/15',
]