Giter VIP home page Giter VIP logo

binder's Introduction

Binder

Build Status Code Health

A Django web application for viewing and editing BIND DNS zone records.

It has support for NSD-hosted DNS zones, but as NSD does not support dynamic updates, that feature is not available.

Download

git clone https://github.com/jforman/binder.git

Requirements

The requirements.txt file has the necessary dependencies.

pip install -r requirements.txt

Running Binder

Over the course of developing Binder, it has come to the fore that using a container makes development and running Binder much easier.

Local Sqlite database

docker run jforman/binder:latest

Admin user

Default admin user for Binder is 'admin', and password is 'admin' as well.

MySQL database

If you wish to use a MySQL database, the following structure works:

docker run -e 'DJANGO_DB_HOST=XXXX' -e 'DJANGO_DB_PASSWORD=YYYY' -e 'DJANGO_DB_NAME=ZZZZ' -e 'DJANGO_DB_USER=binder' jforman/binder:latest

The Django settings.py is configured to accept the following environment variables when configuring a MySQL-based backend database.

  • DJANGO_DB_HOST: IP address or Hostname of the MySQL database host. (Required)
  • DJANGO_DB_NAME: Name of the MySQL database. (Required)
  • DJANGO_DB_USER: Username to access the above database. (Optional. Default: binder)
  • DJANGO_DB_PASSWORD: Binder Database password (Required)

If you wish to use MySQL as the backing database, you must specify all required parameters.

Manually

Or you can run Binder directly on your host using the Django devserver.

python manage.py migrate
python manage.py createsuperuser
python manage.py runserver

Develop Binder

If you want to develop on Binder, I've tried to write down the steps I use.

develop.sh is a shell script that will start a Docker container based off the same image as the one on Docker hub. Only this script will mount your Binder code directory into /code in the container.

Before any development can commence, you will need to install the requirements.

From inside the container:

pip install -r requirements.txt

Generating a new initial_data.json

Certain versions of Django cause changes in the schema of the admin table. In this case, I've found a (perhaps less than proper) workflow for creating a new initial_data.json file. This uses a local Sqlite database file for bootstrapping.

python manage.py migrate
python manage.py createsuperuser
python manage.py dumpdata -o binder/fixtures/initial_data.json

Encrypted TSIG Keys

Starting with version 1.5, TSIG keys inside the database are encrypted using the Crytography library and Fernet facilities.

Normally on startup, a new Fernet encryption key is created. This will change upon reboot as the process dies and restarts.

If you wish to use a statically configured encryption/decryption key, one must pass the DJANGO_FERNET_KEY environment variable, containing this key string. This should be used in production. This key MUST be kept secret or your TSIG keys will be able to be decrypted.

External configuration

Aside from the Binder application itself, other infrastructure is required to make Binder useful.

NSD DNS Server

If you wish to access an NSD DNS server, the credentials are expected to be found in /creds creds directory, where each subdirectory matches the configured hostname.

For example, for NSD host ns1.university.edu, the NSD remote control certificates would be found at the following paths:

/creds/ns1.university.edu/nsd_control.key
/creds/ns1.university.edu/nsd_control.pem

BIND DNS Server

When Binder accesses your BIND DNS server, it first queries the statistics port to gather zone information. This includes zone name, view, and serial number.

named.conf

We must provide server statistics from the BIND process itself. This allows Binder to query BIND itself and get a list of zones, views, and other statistics.

options {
  zone-statistics yes;
}

statistics-channels {
    inet * port 8053 allow { 10.10.0.0/24; };
};

This tells bind to start an HTTP server on port 8053 on all interfaces, allowing 10.10.0.0/24 to make requests on this interface, http://${bind_server}:8053/. You will most likely want to narrow down list of source hosts/IPs who can query BIND for this data.

It is smart to include your TSIG key in a separate file. This way if you choose to have specific ACLs for your named.conf that are different from your TSIG key, this can be done.

include "/etc/bind/dynzone.key";

This tells Bind to load a TSIG key from dynzone.key that can be referenced later in named.conf.

Moving on to zone declaration, determine how locked down you want zone updates and transfers to be. The following zone is defined to allow all zone transfers, but restrict updates to those provided with the dynzone-key TSIG key.

zone "dynzone.yourdomain.org" IN {
    type master;
    file "/var/cache/bind/master/db.dynzone.yourdomain.org";
    allow-update { key dynzone-key; };
};

/etc/bind/dynzone.key

Below are the entire contents of the dynzone.key file. This specifies the name, algorith and TSIG secret.

key dynzone-key {
    algorithm hmac-md5;
    secret "foobar...BhBrq+Ra3fBzhA4IWjXY85AVUdxkSSObbw3D30xgsf.....";
};

referenced as 'dynzone-key' in named.conf

For information on TSIG see http://www.cyberciti.biz/faq/unix-linux-bind-named-configuring-tsig/ .

Apache HTTPD

If you are using Apache to front-end your Binder Django app, the following two configuration files can be used as starting points.

binder-apache.conf.dist: Apache virtual host configuration file to be inclued in your apache.conf. Values provide for Binder to run on its own virtual host, separate logs, etc

django.wsgi: WSGI configuration file used by Apache to run the actual Django app.

Nginx

binder-nginx.conf.dist: Nginx virtual host configuraiton. This configuration expects Django to be running in fcgi mode on port 4001 on 127.0.0.1.

MySQL

If you choose to use MySQL as your backing datastore, the following commands will help you get up and running quickly.

create database binder;

create user 'binder'@'%' identified by 'INSERTYOURPASSWORDHERE';

grant all privileges on binder.* to 'binder'@'%';

flush privileges;

binder's People

Contributors

dunedan avatar goetzk avatar jforman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

binder's Issues

test error

When the project is tested, after the server is added in the background, the homepage selects The Times error.
error:Remote end closed connection without response

BadStatusLine

hi,
Error:
File "/usr/lib64/python2.7/httplib.py", line 408, in _read_status
raise BadStatusLine(line)
BadStatusLine: ''

support other record types like MX, SRV.

Hi Jeff
Thanks for your work! We like binder :-)
Is it correct that the binder app supports adding/editing of the following record types: A, AAAA, CNAME?
Would be great to add support for MX, SRV and others record types. Is it something you plan to implement?

Reverse for '"server_list"' with arguments '()' and keyword arguments '{}' not found.

I'm trying to run binder on test server, after installing all dependencies and running syncdb (without erros), I'm starting a django (manage.py runserver 0.0.0.0:8080)

but if I try to open it browser i see

NoReverseMatch at /

Reverse for '"server_list"' with arguments '()' and keyword arguments '{}' not found.

Request Method:     GET
Request URL:    http://192.168.122.171:8080/
Django Version:     1.4.5
Exception Type:     NoReverseMatch
Exception Value:    

Reverse for '"server_list"' with arguments '()' and keyword arguments '{}' not found.

Exception Location:     /usr/lib/python2.7/dist-packages/django/template/defaulttags.py in render, line 426
Python Executable:  /usr/bin/python
Python Version:     2.7.3
Python Path:    

['/srv/binder',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/pymodules/python2.7']

Am I missing something in configuration?

Support must be added before being able to support newly-encountered XML version 2.2.'

Getting error this running binder and click on my server that I created in the admin section.
I'm testing under virtualenv and ran the requirements but get error below

Any ideas how I can fix this, thanks

pip list show these versions and I'm running on Ubuntu 14.04.4 LTS
beautifulsoup4 (4.5.1)
Django (1.8.16)
dnspython (1.15.0)
lxml (3.6.4)
pip (7.1.2)
pybindxml (0.6)
setuptools (18.2)
wheel (0.24.0)

'Support must be added before being able to support newly-encountered XML version 2.2.'
Request Method: GET
Request URL: http://172.17.200.111:8080/info/airlcdnstest01/
Django Version: 1.8.16
Exception Type: XmlError
Exception Value:
'Support must be added before being able to support newly-encountered XML version 2.2.'
Exception Location: /opt/dnstool/local/lib/python2.7/site-packages/pybindxml/reader.py in get_stats, line 68
Python Executable: /opt/dnstool/bin/python
Python Version: 2.7.6
Python Path:
['/opt/binder/binder',
'/opt/dnstool/lib/python2.7',
'/opt/dnstool/lib/python2.7/plat-x86_64-linux-gnu',
'/opt/dnstool/lib/python2.7/lib-tk',
'/opt/dnstool/lib/python2.7/lib-old',
'/opt/dnstool/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/opt/dnstool/local/lib/python2.7/site-packages',
'/opt/dnstool/lib/python2.7/site-packages']

Convert binder to stand alone application

Hi,
I'm hoping its possible to convert binder to a standalone application. I am looking to integrate it with an existing django site and it would be easier if that was the case.

(Its possible it can be done but the documentation makes it sound like that isn't the case - if I discover a way I will update here).

dns key error

Hi,
I added the key in the background, and then put the value in the dynzone. Key file, and then the error.
Error:
bash[119220]: /etc/bind/dynzone.key:3: bad secret 'bad base64 encoding'

Resolv host name (NSD back-end)

The NSD back-end passes the server hostname directly to the nsd-control command:

            zs_out = subprocess.check_output(
                ["/usr/sbin/nsd-control",
                "-c", self.get_config_path(),
                "-s", self.hostname,
                "zonestatus"],
                stderr=subprocess.STDOUT,
            ).decode('utf-8')

The problem is that this command is expecting an IP (v4 or v6) address and does not resolve hostnames.
This is usually find with DNS servers since they are rather stable and are often used to resolve names for their own domains, however when the DNS server is in another docker container, container names are more stable than IP addresses and it would be really useful to use hostnames rather than IP addresses.

install error at createsuperuser

python manage.py createsuperuser
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.6/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 70, in handle
    default_username = get_default_username()
  File "/usr/lib/python2.6/site-packages/django/contrib/auth/management/__init__.py", line 116, in get_default_username
    User.objects.get(username=default_username)
  File "/usr/lib/python2.6/site-packages/django/db/models/manager.py", line 131, in get
    return self.get_query_set().get(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 361, in get
    num = len(clone)
  File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 85, in __len__
    self._result_cache = list(self.iterator())
  File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 291, in iterator
    for row in compiler.results_iter():
  File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 763, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 818, in execute_sql
    cursor.execute(sql, params)
  File "/usr/lib/python2.6/site-packages/django/db/backends/util.py", line 40, in execute
    return self.cursor.execute(sql, params)
  File "/usr/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py", line 344, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.DatabaseError: no such table: auth_user

Admin user in the docker image

Please note that, unlike written in the README, there is no admin user predefined in the docker image.

It's not a big deal since its easy to create through "python manage.py createsuperuser" in a newly created container (or image) and that's more secure than providing a default admin but that could be mentioned in the README ;) ...

Thanks.

Doesn't work on Ubuntu 16.04 - multiple errors, XML 3.6 not supported (yet)

First off, Bind9 uses XML 3.6 which isn't supported. Editing the xml library to just use the XML 3.5 parser seems to work... but then it fails not supporting any of the HMACs - no matter which one you use - "TSIG algorithm hmac-sha256. is not supported"

I'm not proficient enough in Python to fix this myself. The XML library claims:
XmlError at /info/127.0.0.1/

u'Support must be added before being able to support newly-encountered XML version 3.6.'

Request Method: GET
Request URL: http://127.0.0.1:8000/info/127.0.0.1/
Django Version: 1.9.6
Exception Type: XmlError
Exception Value:

u'Support must be added before being able to support newly-encountered XML version 3.6.'

Exception Location: /usr/local/lib/python2.7/dist-packages/pybindxml/reader.py in get_stats, line 68
Python Executable: /usr/bin/python
Python Version: 2.7.11
Python Path:

['/usr/src/binder',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages']

Server time: Sat, 14 May 2016 05:23:23 -0400

I'm keen to learn, any ideas? How do I add Unicode support to XML 3.6 library? Is that the main problem? Easier to just use an older BIND?

documentation, round 1

Document:

  • Installation
  • Packages needed
  • named.conf configuration
  • Assumptions
  • URL structure

_mysql.c:1915:41: error: ‘MYSQL’ has no member named ‘reconnect’ (centos 7 python 2/3 mariadb 10.x compilation)

  • OS: centos 7.(5/x)
    *devenvs: MariaDB 10.x + python 2.x/3.x

  • default output:
    _mysql.c: En la función ‘_mysql_ConnectionObject_ping’:
    _mysql.c:1915:41: error: ‘MYSQL’ no tiene un miembro llamado ‘reconnect’
    if ( reconnect != -1 ) self->connection.reconnect = reconnect;
    ^
    error: command 'gcc' failed with exit status 1

  • how to fix

sed '/st_mysql_options options;/a unsigned int reconnect;' /usr/include/mysql/mysql.h -i.bkp

source: DefectDojo/django-DefectDojo#407

Error 403

Hi,
I folowed your instruction page on the installation but the server return me a 403 forbidden when i try to access the website. The logs tell the access was blocked by the wsgi file policy

Multi user capabilities

Hi,
Does this support multiple users each with their own servers/zones? if it does could you provide some information on how that works?

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.