caiovfernandes / docker-dns-bind

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Project Requirements

  • docker

Quick Test

  1. Run all with make:
make
  1. Inside of the host1 container (already in after make):
ping host1.caio-foundation.com
# OR
ping host2.caio-foundation.com

Environments variables

export IP_RANGE=172.20.0.0
export NETWORK_NAME=caio-net
export DNS_SERVER1_IP=172.20.0.2
export DNS_SERVER2_IP=172.20.0.3
export HOST1_IP=172.20.0.4
export HOST2_IP=172.20.0.5
export DNS_IMAGE_NAME=lab01_dns_server
export HOST_IMAGE_NAME=lab01_dns_host

Docker network

  1. Creating a Docker network:
docker network create --subnet=${IP_RANGE}/16 ${NETWORK_NAME}

Executing DNS_SERVERS

cd dns-server/
  1. Building docker image:
docker build -t ${DNS_IMAGE_NAME} .
  1. Running container
docker run -d --rm --name=dns-server --net=${NETWORK_NAME} --ip=${DNS_SERVER_IP} ${DNS_IMAGE_NAME}
  1. Starting bind9 service
docker exec -d dns-server /etc/init.d/bind9 start

Running hosts

cd host/
  1. Building docker image
docker build -t ${HOST_IMAGE_NAME} .
  1. Running host 1
docker run -d --rm --name=host1 --net=${NETWORK_NAME} --ip=${HOST1_IP} --dns=${DNS_SERVER_IP} ${HOST_IMAGE_NAME} /bin/bash -c "while :; do sleep 10; done"
  1. Running host 2
docker run -d --rm --name=host1 --net=${NETWORK_NAME} --ip=${HOST2_IP} --dns=${DNS_SERVER_IP} ${HOST_IMAGE_NAME} /bin/bash -c "while :; do sleep 10; done"

Testing Connections

  • Inside the container, it is possible to verify that the host2 is reachable from the host1, using the DNS
  1. Accessing host1 container:
docker exec -it host1 bash
  1. Inside of host1, getting host2 IP throw the DNS_SERVER:
ping host2.caio-foundation.com

About


Languages

Language:Makefile 62.4%Language:DIGITAL Command Language 18.8%Language:Dockerfile 18.7%