名前付き構成ファイル

名前付き構成ファイル

私の設定はますます複雑になっており、一般的に私は物をいくつかの部分に分けて直接組み立てる傾向があります。しかし、今回は、機器全体が一緒に機能するのにもう少し助けが必要だと思いました。そのため、@Rui F Ribeiroユーザーが私にこの質問を別の質問として依頼しました。


私が達成したいことは何ですか?デフォルトでは、インターネットで見つけたものはDNSファイアウォールと呼ばれます。
次の機能で構成された BIND サーバーが必要です。

  • デフォルトでは、すべての要求を外部DNSに転送することが期待されています(私の場合はOpenDNS:208.67.222.222、208.67.220.220)。
  • OpenDNSには便利なドメインブロック/操作機能があるため、どのような状況でもルートサーバーに問い合わせることはできません。したがって、バインディングサーバーがOpenDNSとルートサーバーにランダムに要求を開始すると、毎回異なる結果が得られます。(注:この転送は、途中で他のサーバーが傍受したり、さらに操作したりしないなど、さまざまな理由で暗号化モードで実行する必要があります。)
  • バインドサーバーもキャッシュとして機能し、OpenDNSにクエリを送信できますが、すでに新しいデータがある場合はクエリを続ける必要がなく、帯域幅と時間が無駄になります。
  • 私の構成をより複雑にする他の主な要求は次のとおりです。多くのドメインリストを持つRPZゾーンを設定したいと思います。ドメインを確認したくありません。デフォルトでは、127.0.0.1または私のLANの他のIP /ホストとして解決されることを望みます。広告目的などのためのhttpサーバーのすべてのキャプチャに使用されます。

このように複雑な構成をどのように達成できますか?

これは私の設定ファイルです。ここで何かが必要に応じて動作しないようですので、整理するのに役立ちます。


名前付き構成ファイル

// This is the primary configuration file for the BIND DNS server named.
//
// Please read /usr/share/doc/bind9/README.Debian.gz for information on the
// structure of BIND configuration files in Debian, *BEFORE* you customize
// this configuration file.
//
// If you are just adding zones, please do that in /etc/bind/named.conf.local

include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";

名前付き.conf.オプション

acl "trusted" {
        127.0.0.1/8;
        10.0.0.0/8;
        172.16.0.0/12;
        192.168.0.0/16;
        ::1;
};

options {

        directory "/var/cache/bind";    # bind cache directory

        recursion yes;                  # enables resursive queries

        allow-query { trusted; } ;

        allow-recursion { trusted; };   # allows recursive queries from "trusted" clients

        //listen-on { 0.0.0.0; };       # interfaces where to listen

        allow-transfer { none; };       # disable zone transfers by default

        // If there is a firewall between you and nameservers you want
        // to talk to, you may need to fix the firewall to allow multiple
        // ports to talk.  See http://www.kb.cert.org/vuls/id/800113

        // If your ISP provided one or more IP addresses for stable
        // nameservers, you probably want to use them as forwarders.
        // Uncomment the following block, and insert the addresses replacing
        // the all-0's placeholder.

        forward only;

        forwarders {
                208.67.222.222;
                208.67.220.220;
        };


        //========================================================================
        // If BIND logs error messages about the root key being expired,
        // you will need to update your keys.  See https://www.isc.org/bind-keys
        //========================================================================

        dnssec-enable no;
        dnssec-validation no;
        dnssec-lookaside auto;


        auth-nxdomain no;               # conform to RFC1035
        #listen-on-v6 { any; };

        response-policy {
                zone "rpz-white" policy PASSTHRU; // my own white list
                zone "rpz-foreign";    // obtained from producer
        };

};

zone "rpz-white" {
  type master;
  file "/etc/bind/rpz-white.db";
};

zone "rpz-foreign" {
  type master;
  file "/etc/bind/rpz-foreign.db";
};

名前.conf.local

//
// Do any local configuration here
//

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";

名前付き.conf.defaultzone

// prime the server with knowledge of the root servers
//zone "." {
//      type hint;
//      file "/etc/bind/db.root";
//};

// be authoritative for the localhost forward and reverse zones, and for
// broadcast zones as per RFC 1912

zone "localhost" {
        type master;
        file "/etc/bind/db.local";
};

zone "127.in-addr.arpa" {
        type master;
        file "/etc/bind/db.127";
};

zone "0.in-addr.arpa" {
        type master;
        file "/etc/bind/db.0";
};

zone "255.in-addr.arpa" {
        type master;
        file "/etc/bind/db.255";
};

ベストアンサー1

では、皆さんの願いを全て確認してみましょうか?簡単な問題を最初に解決するために順序を変更しました。

1) BIND はキャッシュとして機能しなければなりません。

これが基本的に行われる作業です。何も設定する必要はありません。

2)私たちはルートネームサーバーと通信しません。

ルートヒントについてコメントしました。これで、組織/自宅の外部のDNSサーバーと通信するときにIPアドレスに要求を転送しないことをお勧めします。だからコメントforward only;してコメントを解除してください。include "/etc/bind/zones.rfc1918";

3) ここRPZがよさそうですね。rpz-foreign.dbDNS名/ドメイン正規表現を定義する必要があります。

www.domaintoblacklist.xxx CNAME myserver

または

www.domaintoblacklist.xxx A 127.0.0.1

4) 接続を暗号化する方法は次のとおりです。ドメイン名の暗号化。 DNS暗号化を使用すると、OpenDNSを含む複数のDNSプロバイダとTLS / SSLを介したDNSについて議論できます。もう一つの利点は、人々がDNS要求を聞いたり変更したりすることができないことです。

最も簡単なインストール方法は、スクリプトをダウンロードすることです。dnscryptのサイレントインストール

スクリプトをダウンロードするには:

git clone https://github.com/simonclausen/dnscrypt-autoinstall

このスクリプトはスタンドアロンdnscryptを使用するために実行されるため、その上にBINDを使用するには追加の作業が必要です。

それでは始めましょう。

./dnscrypt-autoinstall.sh

スクリプトは、DNSサービスを使用するかどうかを含む一連の質問をします。

dnscryptのローカルホストを指すように/etc/resolv.confが変更されます。 resolv.confをBINDに変更する必要があります。これについては後で詳しく説明します。

localhostでは、BINDはdnscrypt-proxy127.0.0.2と127.0.0.3を受け取ります。dnscrypt-proxyopendns サーバーと通信する人になります。

さらに、フォワーダBINDは次のように通信するように設定する必要がありますdnscrypt

options {
  ...
    forwarders {
            127.0.0.2;
            172.0.0.3;
    };
  ...

}

また、/etc/init.d/dnscrypt-proxyを編集し、127.0.0.1行を127.0.0.3に変更しました。

$DAEMON --daemonize --ephemeral-keys --user=dnscrypt --local-address=127.0.0.3 --resolver-address=$ADDRESS1 --provider-name=$PNAME1 --provider-key=$PKEY1

プレイブックも変更されました/etc/resolv.conf。 BIND/0.0.0.0 (DNS 用語で 127.0.0.1) を指すように変更する必要があります。

chattr -i /etc/resolv.conf

そして編集してください。

終わり:

service dnscrypt-proxy restart
service bind9 restart

暗号化の構成が完了した後:

  • BIND をキャッシュとして使用して通信するクライアント
  • BINDはまだ「一般」DNSプロトコルを使用してdnsproxyの2つのインスタンスと通信します。
  • dnsproxyは選択したプロバイダと通信し、443 / UDPと443 / TCPを介してDNSを暗号化します。

外部に送信されるパケットを監視するには、次の手順を実行します。

sudo tcpdump -n port 443

おすすめ記事