summaryrefslogtreecommitdiffstats
path: root/dhcp_wizard
diff options
context:
space:
mode:
authorDexter Morgan <dmorgan@mageia.org>2011-06-02 20:51:50 +0000
committerDexter Morgan <dmorgan@mageia.org>2011-06-02 20:51:50 +0000
commitf1d6b8a9d3c06f74e904959887cf043d09aff687 (patch)
tree969cb9fdc3becc19b1f2a21c3a9e3cc2e15f39e6 /dhcp_wizard
downloaddrakwizard-f1d6b8a9d3c06f74e904959887cf043d09aff687.tar
drakwizard-f1d6b8a9d3c06f74e904959887cf043d09aff687.tar.gz
drakwizard-f1d6b8a9d3c06f74e904959887cf043d09aff687.tar.bz2
drakwizard-f1d6b8a9d3c06f74e904959887cf043d09aff687.tar.xz
drakwizard-f1d6b8a9d3c06f74e904959887cf043d09aff687.zip
Branch for updates
Diffstat (limited to 'dhcp_wizard')
-rw-r--r--dhcp_wizard/.perl_checker1
-rwxr-xr-xdhcp_wizard/Dhcp.pm285
-rw-r--r--dhcp_wizard/Makefile16
-rwxr-xr-xdhcp_wizard/scripts/check_range.sh83
-rwxr-xr-xdhcp_wizard/scripts/compute_range1.sh51
-rwxr-xr-xdhcp_wizard/scripts/compute_range2.sh51
-rw-r--r--dhcp_wizard/scripts/dhcpd.conf.default144
-rw-r--r--dhcp_wizard/scripts/dhcpd.patch13
8 files changed, 644 insertions, 0 deletions
diff --git a/dhcp_wizard/.perl_checker b/dhcp_wizard/.perl_checker
new file mode 100644
index 00000000..725f44b4
--- /dev/null
+++ b/dhcp_wizard/.perl_checker
@@ -0,0 +1 @@
+Basedir .. \ No newline at end of file
diff --git a/dhcp_wizard/Dhcp.pm b/dhcp_wizard/Dhcp.pm
new file mode 100755
index 00000000..2f7b4c46
--- /dev/null
+++ b/dhcp_wizard/Dhcp.pm
@@ -0,0 +1,285 @@
+#!/usr/bin/perl
+
+# Drakwizard
+
+# Copyright (C) 2002, 2003 Mandrakesoft
+#
+# Authors: Arnaud Desmons <adesmons@mandrakesoft.com>
+# Florent Villard <warly@mandrakesoft.com>
+#
+# 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+package MDK::Wizard::Dhcp;
+use strict;
+
+use common;
+use services;
+use MDK::Wizard::Varspaceval;
+use MDK::Wizard::Wizcommon;
+
+my $wiz = new MDK::Wizard::Wizcommon;
+
+my $wiz_ip_server = $wiz->{net}->itf_get("IPADDR");
+my $wiz_tftpserverip = $wiz_ip_server;
+
+my $o = {
+ name => N("DHCP Wizard"),
+ var => {
+ ip1 => '',
+ ip2 => '',
+ pxe => '1',
+ gateway => '',
+ wiz_authoritative => 0,
+ interface => $wiz->{net}->default_itf
+ },
+ needed_rpm => [ 'dhcp-server' ],
+ defaultimage => "/usr/share/mcc/themes/default/dhcp_server-mdk.png",
+ };
+
+$o->{pages} = {
+ welcome => {
+ name => N("DHCP Wizard") . "\n\n\n" . N("DHCP is a service that automatically assigns networking addresses to your workstations.") . "\n\n\n" . N("This wizard will help you configuring the DHCP services of your server."),
+ no_back => 1,
+ next => 'interface', no_back => 1,
+ },
+ interface => {
+ name => N("Interface the dhcp server must listen to"),
+ pre => sub {
+ if (!$wiz_ip_server) {
+ my $interface = 'eth0';
+ ($wiz_ip_server) = `/sbin/ip addr show dev $interface` =~ /^\s*inet\s+(\d+\.\d+\.\d+\.\d+)/m;
+ }
+ $o->{var}{interface} |= $wiz->{net}->default_itf;
+ },
+ data => [
+ { list => [ keys %{$wiz->{net}{itf}} ], val => \$o->{var}{interface} },
+ ],
+ next => 'ip_range',
+ no_back => 1,
+ },
+ ip_range => {
+ name => N("Range of addresses used by DHCP") . "\n" . N("Select the range of addresses assigned to the workstations by the DHCP service; unless you have special needs, you can safely accept the proposed values. (ie: 192.168.100.20 192.168.100.40)") . "\n\n" . N("If you want to enable PXE in your dhcp server please check the box (Pre-boot eXecution Environment, a protocol that allows computers to boot through the network)."),
+ pre => sub {
+ #($wiz_ip_server) = `/sbin/ip addr show dev $o->{var}{interface}` =~ /^\s*inet\s+(\d+\.\d+\.\d+\.\d+)/m;
+ ($wiz_ip_server) = $wiz->{net}->{itf}{$o->{var}{interface}}{IPADDR};
+ $wiz_tftpserverip = $wiz_ip_server;
+ my $d = $4 if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $s = "$1.$2.$3" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ $o->{var}{ip1} = compute_range($d, $s);
+ $o->{var}{ip2} = compute_range2($d, $s);
+ },
+ data => [
+ { label => N("Lowest IP address:"), val => \$o->{var}{ip1} },
+ { label => N("Highest IP address:"), val => \$o->{var}{ip2} },
+ { label => N("Gateway IP address:"), val => \$o->{var}{gateway} },
+ { label => N("Enable PXE:"), type => 'bool', val => \$o->{var}{pxe} },
+ ],
+ next => 'summary',
+ no_back => 1,
+ },
+ dhcp_warning => {
+ name => N("Warning") . "\n\n" . N("You are in dhcp, server may not work with your configuration."),
+ ignore => 1,
+ next => 'ip_range',
+ },
+ ip_range_error => {
+ name => N("Error") . "\n\n" . N("The IP range specified is not correct."),
+ ignore => 1,
+ next => 'ip_range',
+ },
+ ip_range_warning => {
+ name => N("Warning") . "\n\n" . N("The IP range specified is not in server address range."),
+ ignore => 1,
+ next => 'summary',
+ },
+ server_in_range => {
+ name => N("Error") . "\n\n" . N("The IP of the server must not be in range."),
+ ignore => 1,
+ next => 'ip_range',
+ },
+ summary => {
+ name => N("Configuring the DHCP server") . "\n\n" . N("The wizard collected the following parameters needed to configure your DHCP service:"),
+ pre => sub {
+ $o->{var}{pxeornot} = $o->{var}{pxe} ? N("enabled") : N("disabled");
+ },
+ data => [
+ { label => N("Lowest IP address:"), val_ref => \$o->{var}{ip1} },
+ { label => N("Highest IP address:"), val_ref => \$o->{var}{ip2} },
+ { label => N("Gateway IP address:"), val_ref => \$o->{var}{gateway} },
+ { label => N("Interface:"), val_ref => \$o->{var}{interface} },
+ { label => N("Enable PXE:"), val_ref => \$o->{var}{pxeornot} },
+ ],
+ post => \&do_it,
+ next => 'end',
+ },
+ end => {
+ name => N("Congratulations") . "\n\n" . N("The wizard successfully configured the DHCP services."),
+ end => 1,
+ no_back => 1,
+ },
+ error_end => {
+ name => N("Failed"),
+ data => [ { label => N("Relaunch drakwizard, and try to change some parameters.") } ],
+ no_back => 1,
+ end => 1,
+ },
+ };
+
+
+
+sub compute_range {
+ my ($d, $s) = @_;
+ my $n;
+ if ($d <= 64) { $n = "65" }
+ elsif ($d <= 128) { $n = "129" }
+ else { $n = "1" }
+ "$s.$n";
+}
+
+sub compute_range2 {
+ my ($d, $s) = @_;
+ my $n;
+ if ($d <= 128) { $n = "254" }
+ elsif ($d > 192) { $n = "192" }
+ else { $n = "128" }
+ "$s.$n";
+}
+
+sub check {
+ my $check_ip = sub { return $_[0] < 0 || $_[0] > 255 ? 0 : 1 };
+ my $r1_trunc = "$1.$2.$3" if $o->{var}{ip1} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ foreach ($1, $2, $3, $4) { $check_ip->($_) or return 'ip_range_error' }
+ my $r2_trunc = "$1.$2.$3" if $o->{var}{ip2} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ foreach ($1, $2, $3, $4) { $check_ip->($_) or return 'ip_range_error' }
+ my $d1 = $4 if $o->{var}{ip1} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $d2 = $4 if $o->{var}{ip2} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $s_trunc = "$1.$2.$3" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $ds = $4 if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ if (!$r1_trunc) { standalone::explanations("DHCP wizard : incorrect adress range 1"); return 'ip_range_error' }
+ if (!$r2_trunc) { standalone::explanations("DHCP wizard : incorrect adress range 2"); return 'ip_range_error' }
+ if ($r1_trunc ne $s_trunc || $r2_trunc ne $s_trunc) {
+ standalone::explanations("DHCP wizard : range not in network");
+ return 'ip_range_warning';
+ }
+ if (!$d1 || !$d2 || $d1 > $d2) { standalone::explanations("DHCP wizard : bad range"); return 'ip_range_error' }
+ if ($ds >= $d1 && $ds <= $d2) { standalone::explanations("DHCP wizard : server in range"); return 'server_in_range' }
+ return 'interface' if keys %{$wiz->{net}{itf}} > 1;
+ 0
+}
+
+sub do_it {
+ $::testing and return;
+ my $in = 'interactive'->vnew('su', 'DHCP');
+ check_starts_on_boot($in, 'dhcpd');
+ my $wiz_domain_name = $wiz->{net}->network_get("DOMAINNAME");
+ my $wiz_host_name = $wiz->{net}->network_get("HOSTNAME");
+ my $wiz_dns = $wiz->{net}->network_get("dnsServer");
+ if ($wiz_dns eq '127.0.0.1') {
+ $wiz_dns = $wiz_ip_server
+ }
+ if (!$o->{var}{gateway}) {
+ my $t = `LC_ALL=C /sbin/ip route list scope global`;
+ ($o->{var}{gateway}) = $t =~ /default via (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) dev/;
+ }
+ my $wiz_ip_net = "$1.$2.$3.0" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $err = check();
+ return $err if $err != 0;
+ my $wiz_ip_range1 = $o->{var}{ip1};
+ my $wiz_ip_range2 = $o->{var}{ip2};
+ my $wiz_ip_netmask = $wiz->{net}->itf_get("NETMASK");
+ if (!$wiz_ip_netmask) { $wiz_ip_netmask = "255.255.255.0" }
+ my $wiz_device = $o->{var}{interface};
+# patch to rewrite when got new file about dhcp with INTERFACES value
+# currently, I put the device to configure as dhcp server
+# in /etc/sysconfig/dhcpd
+
+#[ -f /etc/sysconfig/dhcpd ] && cp -f /etc/sysconfig/dhcpd /var/tmp/wiz_bck/orig/dhcpd
+ my $file = "/etc/sysconfig/dhcpd";
+ -f $file and MDK::Common::cp_af($file, $file.".orig");
+ standalone::explanations("now patching etc/sysconfig/dhcpd");
+ if (!`grep INTERFACES $file`) {
+ my $tmp = `/bin/mktemp /tmp/Dhcpconf.XXXXXX` or die "can't make a temp file: $!";
+ open(NEW, "> $tmp") or die "can't open $tmp: $!";
+ open(OLD, "< $file") or die "can't open default: $!";
+ while (<OLD>) {
+ if (m|INTERFACE|) {
+ print NEW "# $_";
+ }
+ print NEW $_;
+ }
+ MDK::Common::append_to_file($tmp, "\n# Added by drakwizard\nINTERFACES=$wiz_device");
+ close(OLD);
+ close(NEW);
+ chomp($tmp);
+ system("mv $tmp $file");
+ }
+ $file = "/etc/dhcpd.conf";
+ -f $file and MDK::Common::cp_af($file, $file.".orig");
+ output($file, map {
+ s|__hname__|$wiz_host_name|g;
+ s|__dns__|$wiz_dns|g;
+ s|__net__|$wiz_ip_net|g;
+ s|__ip__|$wiz_ip_server|g;
+ s|__mask__|$wiz_ip_netmask|g;
+ s|__rng1__|$wiz_ip_range1|g;
+ s|__rng2__|$wiz_ip_range2|g;
+ s|__dname__|$wiz_domain_name|g;
+ s|__gateway__|$o->{var}{gateway}|g;
+ s|__tftpserverip__|$wiz_tftpserverip|g;
+ s|__dhcpd_interface__|$wiz_device|g;
+ $_;
+ } cat_("/usr/share/wizards//dhcp_wizard/scripts/dhcpd.conf.default"));
+ standalone::explanations("$file: hname = $wiz_host_name, net = $wiz_ip_net, ip = $wiz_ip_server,
+mask = $wiz_ip_netmask, rng1 = $wiz_ip_range1, rng2 = $wiz_ip_range2, dname = $wiz_domain_name");
+ MDK::Common::touch("/var/dhcpd/dhcpd.leases");
+# modifying webmin config
+ $file="/etc/webmin/dhcpd/config";
+ if (-f $file) {
+ my %mdk = MDK::Wizard::Varspaceval->get($file);
+ $mdk{lease_file} = "/var/dhcpd/dhcpd.leases";
+ $mdk{interfaces} = $wiz_device;
+ standalone::explanations("$file: lease_file = $mdk{lease_file}, interfaces = $mdk{interfaces}");
+ MDK::Wizard::Varspaceval->commit($file, \%mdk);
+ !$o->{var}{wiz_authoritative} and output($file, map {
+ s|^\s*not\s*authoritative.*|#$&|i;
+ $_
+ } cat_("/etc/dhcpd.conf"));
+ }
+
+ if ($o->{var}{pxe} == '0') {
+ substInFile {
+ s/#\s+deny members of "PXE"/deny members of "PXE"/;
+ } "/etc/dhcpd.conf";
+ }
+
+ $o->{var}{gateway} or substInFile {
+ s/#\s+doption routers.*//;
+ } "/etc/dhcpd.conf";
+
+ if (services::is_service_running('dhcpd')) {
+ services::restart('dhcpd')
+ } else {
+ services::start('dhcpd')
+ }
+ 10;
+ check_started('dhcpd');
+}
+
+sub new {
+ my ($class) = @_;
+ bless $o, $class;
+}
+
+1;
diff --git a/dhcp_wizard/Makefile b/dhcp_wizard/Makefile
new file mode 100644
index 00000000..3a771fec
--- /dev/null
+++ b/dhcp_wizard/Makefile
@@ -0,0 +1,16 @@
+
+install2:
+ su -c 'make install'
+
+install:
+ mkdir -p --mode=u=rwx,g=rx,o=rx ${prefix}/share/wizards
+ mkdir -p --mode=u=rwx,g=rx,o=rx ${prefix}/share/wizards/dhcp_wizard
+ mkdir -p --mode=u=rwx,g=rx,o=rx ${prefix}/share/wizards/dhcp_wizard/scripts
+ mkdir -p --mode=u=rwx,g=rx,o=rx ${prefix}/share/wizards/dhcp_wizard/images
+ install --mode=u=rw,g=r,o=r -p dhcp.wiz ${prefix}/share/wizards/dhcp_wizard
+ install --mode=a=r -p ./images/DHCP.png ${prefix}/share/wizards/dhcp_wizard/images
+ install --mode=u=rwx,g=rx,o=rx -p scripts/*.sh ${prefix}/share/wizards/dhcp_wizard/scripts
+ install --mode=u=rw,g=r,o=r -p scripts/Dhcpconf.pm ${prefix}/share/wizards/dhcp_wizard/scripts
+ install --mode=u=rwx,g=rx,o=rx -p scripts/*.default ${prefix}/share/wizards/dhcp_wizard/scripts
+ install --mode=u=rwx,g=rx,o=rx -p scripts/*.patch ${prefix}/share/wizards/dhcp_wizard/scripts
+
diff --git a/dhcp_wizard/scripts/check_range.sh b/dhcp_wizard/scripts/check_range.sh
new file mode 100755
index 00000000..4f5de970
--- /dev/null
+++ b/dhcp_wizard/scripts/check_range.sh
@@ -0,0 +1,83 @@
+#!/bin/bash
+#
+# Wizard
+#
+# Copyright (C) 2000 Mandrakesoft.
+#
+# 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 2
+# of the License, or (at your option) any later version.
+# See file LICENSE for further informations on licensing terms.
+#
+# 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Authors: Jerome Dumonteil, Maurizio De Cecco, Enzo Maggi
+# icons: Helene Durosini <ln@mandrakesoft.com>
+# <corporate@mandrakesoft.com> http://www.mandrakesoft.com
+
+# script for wizard basic network configuration
+#
+# assuming :
+# - C class network, mask 255.255.255.0
+#
+# echo on stdout range of ip for DHCP subnet (second part of range)
+
+echo_debug "in $0"
+
+r1_trunc=${wiz_ip_range1%.*}
+r2_trunc=${wiz_ip_range2%.*}
+d1=${wiz_ip_range1##*.}
+d2=${wiz_ip_range2##*.}
+
+se=`get_var wiz_ip_server`
+
+s_trunc=${se%.*}
+ds=${se##*.}
+
+if [ -z "${r1_trunc}" ]; then
+ echo_debug "incorrect address range 1"
+ exit 1
+fi
+
+if [ -z "${r2_trunc}" ]; then
+ echo_debug "incorrect address range 2"
+ exit 1
+fi
+
+if [ "${s_trunc}" != "${r1_trunc}" -o "${s_trunc}" != "${r2_trunc}" ]; then
+ echo_debug "range not in network"
+ exit 1
+fi
+
+if [ -z "${d1}" -o -z "${d2}" ]; then
+ echo_debug "bad range"
+ exit 1
+fi
+
+if [ ${d1} -gt 254 -o ${d1} -lt 1 -o ${d2} -gt 254 -o ${d2} -lt 1 ]; then
+ echo_debug "bad range"
+ exit 1
+fi
+
+if [ ${d1} -gt ${d2} ]; then
+ echo_debug "bad range "
+ exit 1
+fi
+
+if [ ${ds} -ge ${d1} -a ${ds} -le ${d2} ]; then
+ echo_debug "server in range"
+ exit 1
+fi
+
+
+# should be ok
+exit 10
+
diff --git a/dhcp_wizard/scripts/compute_range1.sh b/dhcp_wizard/scripts/compute_range1.sh
new file mode 100755
index 00000000..8e1f89fb
--- /dev/null
+++ b/dhcp_wizard/scripts/compute_range1.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# Wizard
+#
+# Copyright (C) 2000 Mandrakesoft.
+#
+# 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 2
+# of the License, or (at your option) any later version.
+# See file LICENSE for further informations on licensing terms.
+#
+# 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Authors: Jerome Dumonteil, Maurizio De Cecco, Enzo Maggi
+# icons: Helene Durosini <ln@mandrakesoft.com>
+# <corporate@mandrakesoft.com> http://www.mandrakesoft.com
+
+# script for wizard basic network configuration
+#
+# assuming :
+# - C class network, mask 255.255.255.0
+#
+# echo on stdout range of ip for DHCP subnet (first part of range)
+
+#truncating addresses
+
+se=`get_var wiz_ip_server`
+
+s_trunc=${se%.*}
+d=${se##*.}
+
+if [ $d -le 64 ]; then
+ r=65
+elif [ $d -le 128 ]; then
+ r=129
+else
+ r=1
+fi
+
+echo "${s_trunc}.$r"
+
+exit 0
+
diff --git a/dhcp_wizard/scripts/compute_range2.sh b/dhcp_wizard/scripts/compute_range2.sh
new file mode 100755
index 00000000..3055a6e2
--- /dev/null
+++ b/dhcp_wizard/scripts/compute_range2.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# Wizard
+#
+# Copyright (C) 2000 Mandrakesoft.
+#
+# 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 2
+# of the License, or (at your option) any later version.
+# See file LICENSE for further informations on licensing terms.
+#
+# 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Authors: Jerome Dumonteil, Maurizio De Cecco, Enzo Maggi
+# icons: Helene Durosini <ln@mandrakesoft.com>
+# <corporate@mandrakesoft.com> http://www.mandrakesoft.com
+
+# script for wizard basic network configuration
+#
+# assuming :
+# - C class network, mask 255.255.255.0
+#
+# echo on stdout range of ip for DHCP subnet (second part of range)
+
+#truncating addresses
+se=`get_var wiz_ip_server`
+
+s_trunc=${se%.*}
+d=${se##*.}
+
+if [ $d -le 128 ]; then
+ r=254
+elif [ $d -gt 192 ]; then
+ r=192
+else
+ r=128
+fi
+
+
+echo "${s_trunc}.$r"
+
+exit 0
+
diff --git a/dhcp_wizard/scripts/dhcpd.conf.default b/dhcp_wizard/scripts/dhcpd.conf.default
new file mode 100644
index 00000000..80e43759
--- /dev/null
+++ b/dhcp_wizard/scripts/dhcpd.conf.default
@@ -0,0 +1,144 @@
+# for explanation in french go to : http://www.delafond.org/traducmanfr/man/man5/dhcpd.conf.5.html
+ddns-update-style none;
+allow booting;
+allow bootp;
+
+# Your dhcp server is not master on your network !
+#not authoritative;
+# Your dhcpd server is master on your network !
+authoritative;
+#not authoritative;
+
+#Interface where dhcpd is active
+DHCPD_INTERFACE = "__dhcpd_interface__";
+
+# Definition of PXE-specific options
+# Code 1: Multicast IP address of bootfile
+# Code 2: UDP port that client should monitor for MTFTP responses
+# Code 3: UDP port that MTFTP servers are using to listen for MTFTP requests
+# Code 4: Number of secondes a client must listen for activity before trying
+# to start a new MTFTP transfer
+# Code 5: Number of secondes a client must listen before trying to restart
+# a MTFTP transfer
+
+# define Option for the PXE class
+option space PXE;
+option PXE.mtftp-ip code 1 = ip-address;
+option PXE.mtftp-cport code 2 = unsigned integer 16;
+option PXE.mtftp-sport code 3 = unsigned integer 16;
+option PXE.mtftp-tmout code 4 = unsigned integer 8;
+option PXE.mtftp-delay code 5 = unsigned integer 8;
+option PXE.discovery-control code 6 = unsigned integer 8;
+option PXE.discovery-mcast-addr code 7 = ip-address;
+
+#Define options for pxelinux
+option space pxelinux;
+option pxelinux.magic code 208 = string;
+option pxelinux.configfile code 209 = text;
+option pxelinux.pathprefix code 210 = text;
+option pxelinux.reboottime code 211 = unsigned integer 32;
+site-option-space "pxelinux";
+# These lines should be customized to your setup
+#option pxelinux.configfile "configs/common";
+#option pxelinux.pathprefix "/pxelinux/files/";
+#filename "/pxelinux/pxelinux.bin";
+
+option pxelinux.magic f1:00:74:7e;
+option pxelinux.reboottime 30;
+#if exists dhcp-parameter-request-list {
+ # Always send the PXELINUX options
+# append dhcp-parameter-request-list 208, 209, 210, 211;
+# append dhcp-parameter-request-list 208,211;
+# }
+
+#Class that determine the options for Etherboot 5.x requests
+class "Etherboot" {
+
+#if The vendor-class-identifier equal Etherboot-5.0
+match if substring (option vendor-class-identifier, 0, 9) = "Etherboot";
+
+# filename define the file retrieve by the client, there nbgrub
+# our tftp is chrooted so is just the path to the file
+filename "/etherboot/nbgrub";
+
+#Used by etherboot to detect a valid pxe dhcp server
+option vendor-encapsulated-options 3c:09:45:74:68:65:72:62:6f:6f:74:ff;
+
+# Set the "vendor-class-identifier" field to "PXEClient" in dhcp answer
+# if this field is not set the pxe client will ignore the answer !
+option vendor-class-identifier "Etherboot";
+
+vendor-option-space PXE;
+option PXE.mtftp-ip 0.0.0.0;
+
+# IP of you TFTP server
+next-server __tftpserverip__;
+}
+
+
+# create the Class PXE
+class "PXE" {
+# if the "vendor-class-identifier" is set to "PXEClient" in the client dhcp request
+match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
+
+# filename define the file retrieve by the client, there pxelinux.0
+# our tftp is chrooted so is just the path to the file
+# If you prefer use grub, use pxegrub compiled for your ethernet card.
+#filename "/PXEClient/pxegrub";
+filename "/X86PC/linux/linux.0";
+
+# Set the "vendor-class-identifier" field to "PXEClient" in dhcp answer
+# if this field is not set the pxe client will ignore the answer !
+option vendor-class-identifier "PXEClient";
+
+
+vendor-option-space PXE;
+option PXE.mtftp-ip 0.0.0.0;
+
+# IP of you TFTP server
+next-server __tftpserverip__;
+}
+
+# the class know exist just for deny the response to other DHCP request
+class "known" {
+ match hardware;
+ one-lease-per-client on;
+ ddns-updates on;
+ ddns-domainname = "__dname__";
+ option domain-name "__dname__";
+ option domain-name-servers __ip__;
+ ddns-hostname = pick-first-value(ddns-hostname, option host-name);
+ option fqdn.no-client-update on;
+ set vendor_class_identifier = option vendor-class-identifier;
+}
+
+# TAG: COMPUTER_LIST_BEGIN
+#host compute9{
+# hardware ethernet 00:02:b3:3f:7e:b7;
+# fixed-address compute9;
+# TAG: COMPUTER_LIST_END
+
+# subnet 192.168.200.0 netmask 255.255.255.0 {
+subnet __net__ netmask __mask__ {
+ option subnet-mask __mask__;
+ option routers __gateway__;
+ default-lease-time 28800;
+ max-lease-time 86400;
+ option domain-name "__dname__";
+ option domain-name-servers __ip__;
+ next-server __tftpserverip__;
+
+ pool {
+ range __rng1__ __rng2__;
+# deny members of "PXE";
+# deny members of "Etherboot";
+ }
+
+# pool {
+# range 192.168.200.200 192.168.200.254;
+# give an address of the the pool for PXE client and deny the other
+#allow members of "PXE";
+#deny members of "known";
+#allow members of "Etherboot";
+# }
+} \ No newline at end of file
diff --git a/dhcp_wizard/scripts/dhcpd.patch b/dhcp_wizard/scripts/dhcpd.patch
new file mode 100644
index 00000000..45d84c4b
--- /dev/null
+++ b/dhcp_wizard/scripts/dhcpd.patch
@@ -0,0 +1,13 @@
+--- dhcpd.o Wed Mar 22 18:39:19 2000
++++ dhcpd Wed Mar 22 18:40:17 2000
+@@ -25,8 +25,9 @@
+ # # Note that this work around assumes only using eth0!!!
+ # echo -n "Adding local broadcast host route: "
+ # /sbin/route add -host 255.255.255.255 dev eth0
++ [ -f /etc/sysconfig/dhcpd ] && . /etc/sysconfig/dhcpd
+ echo -n "Starting dhcpd: "
+- daemon /usr/sbin/dhcpd
++ daemon /usr/sbin/dhcpd ${INTERFACES}
+ echo
+ touch /var/lock/subsys/dhcpd
+ ;;