Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hooks on DNS resolution #25

Open
rande opened this issue Aug 22, 2017 · 3 comments
Open

Hooks on DNS resolution #25

rande opened this issue Aug 22, 2017 · 3 comments

Comments

@rande
Copy link

rande commented Aug 22, 2017

I would like to add a way to add iptables rules based on DNS query. This can be usefull if the DNS server is on the gateway with different outbound interfaces.

This can be done by calling an external program when the resolution is done (can be called once before the cache is set). It will required to have a script to be called on start, so it will be possible to clean the state (iptables).

@looterz
Copy link
Owner

looterz commented Sep 1, 2017

I think for ease of use and security, webhooks would be a good solution for something like this, and would allow for users to respond to grimd events locally or remotely without much hassle.

You could create a small web-server with your iptables altering application and point grimd at it, and it would send data to specified endpoints on dns events. Would this work for what you need?

@elico
Copy link
Contributor

elico commented Sep 26, 2017

@looterz @rande it would be better to use ipset compared to raw iptables.
A small webserver is nice but it's much simpler to define in config file the

  • iptset command location
  • ipset ip-hash name
  • execute it using a go routine or not

@rande now after reading the issue more then 5 time I am thinking that maybe I didn't understood the idea.

@ryancdotorg
Copy link
Contributor

ryancdotorg commented Jul 2, 2018

Just wanted to reference the ipset-dns tool here: https://git.zx2c4.com/ipset-dns/about/ - the code shows how to do this without having to call an external program. It's extremely useful for deny-by-default egress filtering, and selective use of VPN.

Note that it's been integrated into dnsmasq now - I'm using that to do the firewall stuff with grimd to do filtering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants