#!/usr/bin/perl
-#
-# SmoothWall CGIs
-#
-# This code is distributed under the terms of the GPL
-#
-# (c) The SmoothWall Team
-#
-# Copyright (C) 01-02-2002 Graham Smith <grhm@grhm.co.uk>
-# - Fixed DHCP Leases added
-#
-# $Id: dhcp.cgi,v 1.14.2.81 2006/01/20 12:05:29 franck78 Exp $
-#
-# Franck -rewrite for two or more interface
-# nov/2004 -check range is in correct subnet
-# -add NTP option
-# -add display sorting of actives leases
-# dec/2004 -add comment field to fixed leases
-#
-# to do : choose a correct format for displaying dates
-#
+###############################################################################
+# #
+# IPFire.org - A linux based firewall #
+# Copyright (C) 2007 Michael Tremer & Christian Schmidt #
+# #
+# 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/>. #
+# #
+###############################################################################
+
use strict;
# enable only the following on debugging purpose
$dhcpsettings{"NTP2_${itf}"} = '';
$dhcpsettings{"NEXT_${itf}"} = '';
$dhcpsettings{"FILE_${itf}"} = '';
+ $dhcpsettings{"DNS_UPDATE_KEY_NAME_${itf}"} = '';
+ $dhcpsettings{"DNS_UPDATE_KEY_SECRET_${itf}"} = '';
+ $dhcpsettings{"DNS_UPDATE_KEY_ALGO_${itf}"} = '';
}
$dhcpsettings{'SORT_FLEASELIST'} = 'FIPADDR';
$dhcpsettings{'SORT_LEASELIST'} = 'IPADDR';
+# DNS Update settings
+$dhcpsettings{'DNS_UPDATE_ENABLED'} = 'off';
+
#Settings2 for editing the multi-line list
#Must not be saved with writehash !
$dhcpsettings{'FIX_MAC'} = '';
<input type='checkbox' name='ENABLE_${itf}' $checked{'ENABLE'}{'on'} /></td>
<td width='25%' class='base'>$Lang::tr{'ip address'}<br />$Lang::tr{'netmask'}:</td><td><b>$netsettings{"${itf}_ADDRESS"}<br />$netsettings{"${itf}_NETMASK"}</b></td>
</tr><tr>
- <td width='25%' class='base'>$Lang::tr{'start address'} <img src='/blob.gif' alt='*' /></td>
+ <td width='25%' class='base'>$Lang::tr{'start address'}</td>
<td width='25%'><input type='text' name='START_ADDR_${itf}' value='$dhcpsettings{"START_ADDR_${itf}"}' /></td>
- <td width='25%' class='base'>$Lang::tr{'end address'} <img src='/blob.gif' alt='*' /></td>
+ <td width='25%' class='base'>$Lang::tr{'end address'}</td>
<td width='25%'><input type='text' name='END_ADDR_${itf}' value='$dhcpsettings{"END_ADDR_${itf}"}' /></td>
</tr><tr>
<td class='base'>$Lang::tr{'default lease time'}</td>
<tr>
<td class='base' width='25%'><img src='/blob.gif' align='top' alt='*' /> $Lang::tr{'this field may be blank'}</td>
<td class='base' width='30%'>$warnNTPmessage</td>
- <td width='40%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
- <td width='5%' align='right'> </td>
+ <td width='40%' align='right'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
</tr>
</table>
+END
+;
+&Header::closebox();
+
+# DHCP DNS update support (RFC2136)
+&Header::openbox('100%', 'left', $Lang::tr{'dhcp dns update'});
+
+my %checked = ();
+$checked{'DNS_UPDATE_ENABLED'}{'on'} = ( $dhcpsettings{'DNS_UPDATE_ENABLED'} ne 'on') ? '' : "checked='checked'";
+
+print <<END
+<table width='100%'>
+ <tr>
+ <td width='25%' class='boldbase'>$Lang::tr{'dhcp dns enable update'}</td>
+ <td class='base'><input type='checkbox' name='DNS_UPDATE_ENABLED' $checked{'DNS_UPDATE_ENABLED'}{'on'}>
+ </td>
+ <tr>
+</table>
+
+<table width='100%'>
+END
+;
+ my @domains = ();
+
+ # Print options for each interface.
+ foreach my $itf (@ITFs) {
+ # Check if DHCP for this interface is enabled.
+ if ($dhcpsettings{"ENABLE_${itf}"} eq 'on') {
+ # Check for same domain name.
+ next if ($dhcpsettings{"DOMAIN_NAME_${itf}"} ~~ @domains);
+ my $lc_itf = lc($itf);
+
+ # Select previously configured update algorithm.
+ my %selected = ();
+ $selected{'DNS_UPDATE_ALGO_${inf}'}{$dhcpsettings{'DNS_UPDATE_ALGO_${inf}'}} = 'selected';
+
+print <<END
+ <tr>
+ <td colspan='6'> </td>
+ </tr>
+ <tr>
+ <td colspan='6' class='boldbase'><b>$dhcpsettings{"DOMAIN_NAME_${itf}"}</b></td>
+ </tr>
+ <tr>
+ <td width='10%' class='boldbase'>$Lang::tr{'dhcp dns key name'}:</td>
+ <td width='20%'><input type='text' name='DNS_UPDATE_KEY_NAME_${itf}' value='$dhcpsettings{"DNS_UPDATE_KEY_NAME_${itf}"}'></td>
+ <td width='10%' class='boldbase' align='right'>$Lang::tr{'dhcp dns update secret'}: </td>
+ <td width='20%'><input type='password' name='DNS_UPDATE_SECRET_${itf}' value='$dhcpsettings{"DNS_UPDATE_SECRET_${itf}"}'></td>
+ <td width='10%' class='boldbase' align='right'>$Lang::tr{'dhcp dns update algo'}: </td>
+ <td width='20%'>
+ <select name='DNS_UPDATE_ALGO_${itf}'>
+ <option value='hmac-sha1' $selected{'DNS_UPDATE_ALGO_${itf}'}{'hmac-sha1'}>HMAC-SHA1</option>
+ <option value='hmac-md5' $selected{'DNS_UPDATE_ALGO_${itf}'}{'hmac-md5'}>HMAC-MD5</option>
+ </select>
+ </td>
+ </tr>
+END
+;
+ }
+
+ # Store configured domain based on the interface
+ # in the temporary variable.
+ push(@domains, $dhcpsettings{"DOMAIN_NAME_${itf}"});
+}
+print <<END
+</table>
+<hr>
+<table width='100%'>
+ <tr>
+ <td align='right'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
+ </tr>
+</table>
</form>
END
;
<table width='100%'>
<tr>
<td class='base' width='50%'><img src='/blob.gif' align='top' alt='*' /> $Lang::tr{'dhcp advopt scope help'}</td>
- <td width='50%' align='center'>
+ <td width='50%' align='right'>
<input type='hidden' name='ACTION' value='$Lang::tr{'add'}1' />
<input type='submit' name='SUBMIT' value='$buttontext' />
<input type='submit' name='SUBMIT' value='$Lang::tr{'dhcp advopt help'}' />
<table width='100%'>
<tr>
<td class='base' width='50%'><img src='/blob.gif' align='top' alt='*' /> $Lang::tr{'this field may be blank'}</td>
- <td width='50%' align='center'>
+ <td width='50%' align='right'>
<input type='hidden' name='ACTION' value='$Lang::tr{'add'}2' />
<input type='submit' name='SUBMIT' value='$buttontext' />
<input type='hidden' name='KEY2' value='$dhcpsettings{'KEY2'}' /></td>
print <<END
<hr />
-<table width='100%'>
+<table width='100%' class='tbl'>
<tr>
- <td width='20%' align='center'><a href='$ENV{'SCRIPT_NAME'}?FETHER'><b>$Lang::tr{'mac address'}</b></a></td>
- <td width='20%' align='center'><a href='$ENV{'SCRIPT_NAME'}?FIPADDR'><b>$Lang::tr{'ip address'}</b></a></td>
- <td width='15%' align='center'><b>$Lang::tr{'remark'}</b></td>
- <td width='15%' class='boldbase' align='center'><b>next-server</b></td>
- <td width='15%' class='boldbase' align='center'><b>filename</b></td>
- <td width='15%' class='boldbase' align='center'><b>root path</b></td>
- <td colspan='3' class='boldbase' align='center'><b>$Lang::tr{'action'}</b></td>
+ <th width='20%' align='center'><a href='$ENV{'SCRIPT_NAME'}?FETHER'><b>$Lang::tr{'mac address'}</b></a></th>
+ <th width='20%' align='center'><a href='$ENV{'SCRIPT_NAME'}?FIPADDR'><b>$Lang::tr{'ip address'}</b></a></th>
+ <th width='15%' align='center'><b>$Lang::tr{'remark'}</b></th>
+ <th width='15%' class='boldbase' align='center'><b>next-server</b></th>
+ <th width='15%' class='boldbase' align='center'><b>filename</b></th>
+ <th width='15%' class='boldbase' align='center'><b>root path</b></th>
+ <th colspan='3' class='boldbase' align='center'><b>$Lang::tr{'action'}</b></th>
</tr>
END
;
}
$key = 0;
+my $col="";
foreach my $line (@current2) {
my $gif = '';
my $gdesc = '';
}
if ($dhcpsettings{'KEY2'} eq $key) {
- print "<tr bgcolor='${Header::colouryellow}'>";
+ print "<tr>";
+ $col="bgcolor='${Header::colouryellow}'";
} elsif ($key % 2) {
- print "<tr bgcolor='$color{'color22'}'>";
+ print "<tr>";
+ $col="bgcolor='$color{'color20'}'";
} else {
- print "<tr bgcolor='$color{'color20'}'>";
+ print "<tr>";
+ $col="bgcolor='$color{'color22'}'";
}
my $TAG0 = '';
my $TAG1 = '';
}
print <<END
-<td align='center'>$TAG2$temp[0]$TAG3</td>
-<td align='center' $TAG4>$TAG0$temp[1]$TAG1</td>
-<td align='center'>$temp[6] </td>
-<td align='center'>$temp[3] </td>
-<td align='center'>$temp[4] </td>
-<td align='center'>$temp[5] </td>
-
-<td align='center'>
+<td align='center' $col>$TAG2$temp[0]$TAG3</td>
+<td align='center' $col $TAG4>$TAG0$temp[1]$TAG1</td>
+<td align='center' $col>$temp[6] </td>
+<td align='center' $col>$temp[3] </td>
+<td align='center' $col>$temp[4] </td>
+<td align='center' $col>$temp[5] </td>
+
+<td align='center' $col>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}2' />
<input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' alt='$gdesc' title='$gdesc' />
</form>
</td>
-<td align='center'>
+<td align='center' $col>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'edit'}2' />
<input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
</form>
</td>
-<td align='center'>
+<td align='center' $col>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='ACTION' value='$Lang::tr{'remove'}2' />
<input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' alt='$Lang::tr{'remove'}' title='$Lang::tr{'remove'}' />
&Header::closebox();
-&Header::openbox('100%', 'left', $Lang::tr{'arp table entries'});
-my @ip = qx(/sbin/ip neigh show | awk '{print \$1}');
-my @mac = qx(/sbin/ip neigh show | awk '{print \$5}');
-
-print <<END
-<hr />
-<table width='100%'>
-<tr>
-<td width='40%'><b>$Lang::tr{'ip address'}</b></td><td width='40%'><b>$Lang::tr{'mac address'}</b></td><td width='20%'>Optionen</td>
-</tr>
-END
-;
-my $i=0;
-
-foreach my $ip(@ip)
-{
- print"<tr><form method='post' action='$ENV{'SCRIPT_NAME'}'><td><input type='hidden' name='FIX_ADDR' value='$ip' />$ip</td>";
- print"<td><input type='hidden' name='FIX_MAC' value='@mac[$i]' />@mac[$i]</td>";
- print"<td><input type='hidden' name='ACTION' value='$Lang::tr{'add'}2' /><input type='submit' name='SUBMIT' value='$buttontext' /></td></form></tr>";
-}
-
-
-print"</table>";
-
-&Header::closebox();
-
-
foreach my $itf (@ITFs) {
if ($dhcpsettings{"ENABLE_${itf}"} eq 'on') {
# display leases with a list of actions to do with the global select checkbox.
flock(FILE, 2);
# Global settings
- print FILE "ddns-update-style none;\n";
print FILE "deny bootp; #default\n";
print FILE "authoritative;\n";
+
+ # DNS Update settings
+ if ($dhcpsettings{'DNS_UPDATE_ENABLED'} eq 'on') {
+ print FILE "ddns-updates on;\n";
+ print FILE "ddns-update-style interim;\n";
+ print FILE "ignore client-updates;\n";
+ print FILE "update-static-leases on;\n";
+ } else {
+ print FILE "ddns-update-style none;\n";
+ }
# Write first new option definition
foreach my $line (@current1) {
}# foreach line
print FILE "} #$itf\n";
+ if (($dhcpsettings{"DNS_UPDATE_ENABLED"} eq "on") && ($dhcpsettings{"DNS_UPDATE_KEY_NAME_${itf}"} ne "")) {
+ print FILE "key " . $dhcpsettings{"DNS_UPDATE_KEY_NAME_${itf}"} . "{\n";
+ print FILE "\talgorithm " . $dhcpsettings{"DNS_UPDATE_KEY_ALGO_${itf}"} . ";\n";
+ print FILE "\tsecret \"" . $dhcpsettings{"DNS_UPDATE_KEY_SECRET_${itf}"} . "\";\n";
+ print FILE "};\n\n";
+
+ print FILE "zone " . $dhcpsettings{"DOMAIN_NAME_${itf}"} . ". {\n";
+ print FILE "\tkey " . $dhcpsettings{"DNS_UPDATE_KEY_NAME_${itf}"} . ";\n";
+ print FILE "}\n\n";
+ }
+
system ('/usr/bin/touch', "${General::swroot}/dhcp/enable_${lc_itf}");
&General::log("DHCP on ${itf}: " . $Lang::tr{'dhcp server enabled'})
} else {
$key++;
}
}
+ print FILE "include \"${General::swroot}/dhcp/dhcpd.conf.local\";\n";
close FILE;
if ( $dhcpsettings{"ENABLE_GREEN"} eq 'on' || $dhcpsettings{"ENABLE_BLUE"} eq 'on' ) {system '/usr/local/bin/dhcpctrl enable >/dev/null 2>&1';}
else {system '/usr/local/bin/dhcpctrl disable >/dev/null 2>&1';}