Giter Site home page Giter Site logo

fincer / dns-sinkhole Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 5.0 640 KB

Generate domain sinkhole (blacklist) files for DNSCrypt & pdnsd DNS servers

License: MIT License

Python 100.00%
dns-server dnscrypt dnscrypt-proxy pdnsd blacklist blacklists whitelist whitelists dns

dns-sinkhole's Introduction

Generate domain sinkhole (blacklist) files for DNSCrypt and pdnsd DNS servers. Comparable to Pi-Hole, but uses more simple structure without too much overhead. Generated blacklist files can be added to existing DNS server installations.


Usage

Add blacklists and whitelists as you wish into the python script. Once done, run the script with Python 3. The script generates necessary files for you to adapt to your DNS servers.


Developer's notice

Benefits:

Useful for blocking ads, tracking & telemetry on:

  • single device with a DNS server

  • on a full network segment if a centralized DNS server is used (multiple devices)

  • applies to IoT devices (+ SmartTVs etc.) if traffic is routed via a centralized DNS server applying this sinkhole/blacklist policy

NOTE (Tor users): These lists do not work with SOCKS5/HTTP Tor connections, as DNS resolution is done on the Tor exit nodes, not by your DNS server(s).

NOTE: This method may not work if device's hosts file is modified so that it overrides accepted DNS policy.

Tested on

Arch Linux (x86_64):           DNSCrypt server, pdnsd server
Android (mobile phone, ARMv7): DNSCrypt server

About used list formats

pdnsd

Although pdnsd offers neg feature, it is not very reliable with large DNS blocklists. However, custom rr (Resource Record) entries have been tested with a list of over 240 000 blacklisted domains, and it works as expected.

DNSCrypt

Although DNSCrypt offers blacklist feature, it is not very reliable with large DNS blocklists. However, cloaking list has been tested with a list of over 240 000 blacklisted domains, and it works as expected.


Basic principle/idea

Single device

Multiple devices


Detecting malicious network traffic on Android & (embedded) IoT devices

Network analysis is strongly encouraged for mobile phones and (embedded) IoT devices to detect malicious or unwanted connections which are usually taking place without user's knowledge. You can use results of the analysis to build your own DNS sinkhole blacklist for devices or network segments.

You can use tcpdump or wireshark for network analysis purposes.

Mobile phones: you may consider limiting count of installed applications. More applications you have, more unwanted network traffic may occur.

Be aware that some applications or websites may break if too greedy policy is taken in place. DNS sinkhole works at best with combination of other network filtering/firewall policy applied, as well (application & network/data link layers). Understanding OSI model and/or TCP/IP protocol stack helps you to build a proper policy for your network devices.


Why not just a simple hosts file??

Of course, you can apply DNS sinkhole list to your device's hosts file (Linux: /etc/hosts, Android: /system/etc/hosts, Windows: C:\Windows\System32\Drivers\etc\hosts). However, there are some benefits and some drawbacks:

Benefits of hosts:

  • Simple setup: no software installation or compilation

  • No DNS server required: thus no extra configuration/software overhead or server-specific security risks

Drawbacks of hosts:

  • Does not scale: does not apply to a network segment or segments for which you want to block specific domain names. Applies only to single devices.

  • No extra security, such as enforced DNS-over-HTTPS*, proxy configurations**, DNSSEC*** verification or any other useful detailed configuration, provided by a properly configured DNS server

* By default, domain name lookups are done via privileged UDP port 53, and DNS queries are unencrypted. Thus, anyone between you and remote DNS server can read the domain name lookups your applications request. With DNS-over-HTTPS, all DNS queries are wrapped in encrypted packets, sent through (HTTPS) TCP port 443 and thus making your DNS queries unknown by others excluding you and the remote DNS server.

** You can enforce DNS queries through a proxy, such as via a server of your choice or via Tor network

*** You can set-up DNS server of your choice to use enforced DNSSEC policy. In other words, if a rogue, remote DNS server to which your DNS query (domain name lookup) is pointed to, breaks DNSSEC chain, the query is being left unanswered.


License

This repository uses MIT license. See LICENSE file for details.

dns-sinkhole's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.