A basic DHCP container.

This container provide a basic DHCP server that you can drop
in your topology and configure.
This commit is contained in:
Julien Duponchelle 2016-04-04 18:31:27 +02:00
parent e3d94f2cbb
commit 0e3e2f8392
No known key found for this signature in database
GPG Key ID: F1E2485547D4595D
3 changed files with 78 additions and 0 deletions

9
docker/dhcp/Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM alpine:3.3
MAINTAINER developers@gns3.net
RUN apk add --update dnsmasq && rm -rf /var/cache/apk/*
VOLUME /etc/dnsmasq
COPY boot.sh .
CMD /bin/sh boot.sh

19
docker/dhcp/README.rst Normal file
View File

@ -0,0 +1,19 @@
Basic DHCP server
-----------------
This container provide a basic DHCP server fro GNS3 topologies
build on top of dnsmasq.
At first startup a sample config will be write in
/etc/dnsmasq/dnsmaq.conf
You can customize the server by editing this file and restarting the container.
Build, run and publish
=======================
.. code:: bash
docker build -t gns3/dhcp .
docker run -i -t gns3/dhcp
docker push gns3/dhcp

50
docker/dhcp/boot.sh Normal file
View File

@ -0,0 +1,50 @@
#!/bin/sh
#
# Copyright (C) 2016 GNS3 Technologies Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
mkdir -p /etc/dnsmasq
if [ ! -f /etc/dnsmasq/dnsmaq.conf ]
then
cat > /etc/dnsmasq/dnsmaq.conf <<EOF
# dnsmasq will open tcp/udp port 53 and udp port 67 to world to help with
# dynamic interfaces (assigning dynamic ips). Dnsmasq will discard world
# requests to them, but the paranoid might like to close them and let the
# kernel handle them:
bind-interfaces
# Dynamic range of IPs to make available to LAN pc
dhcp-range=192.168.0.50,192.168.0.240,12h
EOF
fi
echo '
_______ __ __ ______ _______
/ \ / | / | / \ / \
$$$$$$$ |$$ | $$ |/$$$$$$ |$$$$$$$ |
$$ | $$ |$$ |__$$ |$$ | $$/ $$ |__$$ |
$$ | $$ |$$ $$ |$$ | $$ $$/
$$ | $$ |$$$$$$$$ |$$ | __ $$$$$$$/
$$ |__$$ |$$ | $$ |$$ \__/ |$$ |
$$ $$/ $$ | $$ |$$ $$/ $$ |
$$$$$$$/ $$/ $$/ $$$$$$/ $$/
'
echo "Edit /etc/dnsmasq/dnsmaq.conf to change the configuration"
dnsmasq --log-dhcp --no-daemon --conf-file=/etc/dnsmasq/dnsmaq.conf