Giter Site home page Giter Site logo

rpz_summarize's Introduction

rpz_summarize - eliminate redundant DNS entries for RPZ

When using wildcard policies it is easy to wind up with redundant entries in your zone. For example

www.badguys.com.rpz.example.com. 300 IN CNAME sinkhole.example.com.
mail.badguys.com.rpz.example.com. 300 IN CNAME sinkhole.example.com.
ns1.badguys.com.rpz.example.com. 300 IN CNAME sinkhole.example.com.
*.badguys.com.rpz.example.com. 300 IN CNAME sinkhole.example.com.

Here the *.badguys.com policy makes the other three redundant.

$ ./rpz_summarize < tests/badguys.txt 
*.badguys.com.rpz.example.com. IN 300 CNAME sinkhole.example.com.
== ZONE STATS ==
Lines: 4
Unparsable: 0
Policy targets: 1
Entries in tree: 4
Entries after summarization: 1 (75.00% reduction)

The zone is segmented by policy targets so for example sinkholed responses aren't compared with NXDOMAIN or NODATA or RPZ-PASSTHRU:

*.shadyguys.com.rpz.example.com. 300 IN CNAME sinkhole.example.com.
wpad.shadyguys.com.rpz.example.com. 300 IN CNAME *.
bad.shadyguys.com.rpz.example.com. 300 IN CNAME sinkhole.example.com.
smtp.shadyguys.com.rpz.example.com. 300 IN CNAME rpz-passthru.
*.static.shadyguys.com.rpz.example.com. 300 IN CNAME rpz-passthru.
good.static.shadyguys.com.rpz.example.com. 300 IN CNAME rpz-passthru.

Which gets reduced like so:

$ ./rpz_summarize < tests/passthru.txt 
smtp.shadyguys.com.rpz.example.com. IN 300 CNAME rpz-passthru.
*.static.shadyguys.com.rpz.example.com. IN 300 CNAME rpz-passthru.
*.shadyguys.com.rpz.example.com. IN 300 CNAME sinkhole.example.com.
wpad.shadyguys.com.rpz.example.com. IN 300 CNAME *.
== ZONE STATS ==
Lines: 6
Unparsable: 0
Policy targets: 3
Entries in tree: 6
Entries after summarization: 4 (33.33% reduction)

Speed

With a moderately large zone (720k entries) the code takes around 1 second:

$ time ./rpz_summarize < /tmp/rpz.txt > /dev/null
== ZONE STATS ==
Lines: 722724
Unparsable: 0
Policy targets: 6
Entries in tree: 722724
Entries after summarization: 554819 (23.23% reduction)

real	0m1.071s
user	0m2.484s
sys	0m0.125s

Peak memory usage while processing this zone is about 160MB.

rpz_summarize's People

Contributors

bmenrigh avatar

Watchers

 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.