Coder Social home page Coder Social logo

bind2other's Introduction

bind2other

named.conf から、それとなるべく同等の動きをする NSD, Unbound, dnsdist のコンフィグを作る

使い方

./bind2other.py named.conf

同じディレクトリに nsd.conf, unbound.conf, dnsdist.conf ができるので、それらを使ってnsd, unbound, dnsdistを起動する。

sudo nsd -c nsd.conf
sudo unbound -c unbound.conf
sudo dnsdist -C dnsdist.conf -d

dig @127.0.0.1 example.com    # ローカルゾーン
dig @127.0.0.1 www.google.com # ローカルゾーン以外

必要なもの

  • Python 2.6
  • dnsdist 1.0.0
  • NSD4
  • Unbound

どのようなコンフィグができるか?

基本的な動作

クライアント ---(クエリ受信)--> [dnsdist]
                                |
                                +--(qnameがローカルゾーン)---> [NSD]
                                |
                                +--(ローカルゾーン以外)---> [Unbound]

dnsdist はクライアントからクエリ受信するために 0.0.0.0:53, [::]:53 で待ち受ける。 クライアントからDNSクエリを受信したら、

  • ローカルゾーン (named.conf に書かれている zone) ならば NSD (127.0.0.1:40000)
  • ローカルゾーン以外なら、Unbound (127.0.0.1:40001)

へフォーワードする。

NSDは、通常の権威サーバとして nsd.conf に書かれたゾーンを読み込み (またはゾーン転送をして)、127.0.0.1:40000でクエリを待ち受ける。

Unboundは、通常のDNSリゾルバとして動作し、127.0.0.1:40001でクエリを待ち受ける。

アクセス制限

  • allow-query にマッチしないソースIPのクエリは常にREFUSED
  • ローカルゾーンへのクエリの場合、NSDにフォワードする。ただし、クエリタイプがAXFR/IXFRの場合は、allow-transfer (options、または各 zone) に従って許可・拒否を行う。
  • ローカルソーン宛てではない、かつ allow-recursion にマッチするソースIPのクエリのみ、Unboundにフォワードされる。

対応する named.conf の機能

BIND9のごく一部の機能のみ対応する

ACL

acl mynetwork1 { 10.0.0.0/8; 192.168.0.0/16; };
acl mynetwork2 { 192.0.2.1; };
acl ournetwork { mynetwork1; mynetwork2; }; # ACLのネストもOK

ACLでは否定の ! は使用不可

# acl evil_in_the_internet { 0.0.0.0/0; ! 1.1.1.1; }; # "!" は不可

options

options {
  directory "/etc";
  allow-query { any; };                    # デフォルトは ANY (BIND9と同じ) 
  allow-recursion { ournetwork; };         # デフォルトは none (BIND9は localhost; localnets) 
  allow-transfer { mynetwork1; 1.1.1.1; }; # デフォルトは none (BIND9は any)
};

zone

masterゾーンと slaveゾーンのみ。アクセス制限は allow-transfer のみ指定可。

zone "example.com" {
  type master;
  file "example.com.zone";
  allow-transfer { none; };  # optionsの allow-transferより優先
};

zone "example2.com" {
  type slave;
  masters { 10.0.0.1; 192.0.2.1; };
  allow-transfer { mynetwork2; 127.0.0.1; }; # optionsの allow-transferより優先
};

view

match-clients のみ対応。

起動方法

dnsdist.confでdnsdistを、各viewに対応するコンフィグでnsd/unboundを起動

sudo nsd -c nsd.conf
sudo nsd -c nsd_external.conf
sudo nsd -c nsd_internal.conf

sudo unbound -c unbound.conf
sudo unbound -c unbound_external.conf
sudo unbound -c unbound_internal.conf

sudo dnsdist -C dnsdist.conf -d

bind2other's People

Contributors

hdais 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.