Home

Awesome

Marco Polo DNS Daemon

Intro

Marco Polo DNS Daemon is a DNS server, which can return different CNAME record based on DNS resolver's IP address and edns-client-subnet information.

Currently it supports three types: AS Number, Country Code, and Random.

Install

Install the following dependencies:

Then just copy lib/mpdnsd.pm into /usr/sbin/mpdnsd.

Run

/usr/sbin/mpdnsd \
    [--bind_host IP1,IP2,...] \
    [--cpu CPU] \
    [--nsrrs NS1.DOMAIN,NS2.DOMAIN,...] \
    [--port PORT] \
    [--querylog_file FILENAME] \
    [--service_domain SERVICE.DOMAIN] \
    [--ttl_asn SECONDS] \
    [--ttl_country SECONDS] \
    [--ttl_ns SECONDS] \
    [--ttl_random SECONDS] \
    [--whitelist_domain ONE.MP.DOMAIN,TWO.MP.DOMAIN]

For example:

/usr/sbin/mpdnsd \
    --bind_host 0.0.0.0 \
    --nsrrs mp-ns1.example.com,mp-ns2.example.com \
    --service_domain mp.example.com \
    --whitelist_domain example.com

Use

You can get AS number by this example:

dig test.example.com.asn.mp.example.com @mp-ns1.example.com

It will return a CNAME record to:

12345.test.example.com

Which 12345 is AS number based on client's DNS resolver or edns-client-subnet information.

Also, you can get country code:

dig test.example.com.country.mp.example.com @mp-ns1.example.com
TW.test.example.com

And you can get the utc hour:

dig test.example.com.hour.mp.example.com
9.test.example.com

And you can choose randomly for range [0..10) (i.e. 0~9):

dig test.example.com.r10.mp.example.com
9.test.example.com

Test

perl Build.PL
./Build testcover

License

Copyright (c) 2016, Gea-Suan Lin, KKBOX Technologies.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.