Giter Site home page Giter Site logo

zone-file-py's Introduction

DNS Zone File Library

CircleCI PyPI PyPI PyPI Slack

A library for creating and parsing DNS zone files

Zone File Example

$ORIGIN example.com
$TTL 86400

server1      IN     A       10.0.1.5
server2      IN     A       10.0.1.7
dns1         IN     A       10.0.1.2
dns2         IN     A       10.0.1.3

ftp          IN     CNAME   server1
mail         IN     CNAME   server1
mail2        IN     CNAME   server2
www          IN     CNAME   server2

Parsing Zone Files

>>> zone_file_object = parse_zone_file(zone_file)
>>> print json.dumps(zone_file_object, indent=4, sort_keys=True)
{
    "$origin": "EXAMPLE.COM", 
    "$ttl": 86400, 
    "a": [
        {
            "ip": "10.0.1.5", 
            "name": "SERVER1"
        }, 
        {
            "ip": "10.0.1.7", 
            "name": "SERVER2"
        }, 
        {
            "ip": "10.0.1.2", 
            "name": "DNS1"
        }, 
        {
            "ip": "10.0.1.3", 
            "name": "DNS2"
        }
    ], 
    "cname": [
        {
            "alias": "SERVER1", 
            "name": "FTP"
        }, 
        {
            "alias": "SERVER1", 
            "name": "MAIL"
        }, 
        {
            "alias": "SERVER2", 
            "name": "MAIL2"
        }, 
        {
            "alias": "SERVER2", 
            "name": "WWW"
        }
    ]
}

Making Zone Files

>>> records = {'uri': [{'priority': 1, 'target': 'https://mq9.s3.amazonaws.com/naval.id/profile.json', 'name': '@', 'weight': 10, 'ttl': '1D'}]}
>>> zone_file = make_zone_file(records, origin="ryan.id", ttl="3600")
>>> print zone_file
$ORIGIN ryan.id
$TTL 3600
@ 1D URI 1 10 "https://mq9.s3.amazonaws.com/naval.id/profile.json"

zone-file-py's People

Contributors

donnchac avatar jcnelson avatar kantai avatar shea256 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.