summaryrefslogtreecommitdiffstats
path: root/src/usr/local/www
diff options
context:
space:
mode:
authorNOYB <Al_Stu@Frontier.com>2017-01-16 13:52:06 -0800
committerNOYB <Al_Stu@Frontier.com>2017-01-17 14:18:35 -0800
commit8333e25c71ceb5421bae8a6385e5a0a031fc9433 (patch)
tree3e0bb339f92a12e4136f94d1a81ba9f3c12cfdce /src/usr/local/www
parent873a236bfe372aa4df726929afa932e989a0898f (diff)
downloadpfsense-8333e25c71ceb5421bae8a6385e5a0a031fc9433.zip
pfsense-8333e25c71ceb5421bae8a6385e5a0a031fc9433.tar.gz
Status / Interfaces - Relinquish DHCP Lease
Send gratuitous DHCP release message to server. Dependency: To fully relinquish the DHCP lease, the "RELEASE" reason needs to be added to the /sbin/dhclient-script. s/EXPIRE|FAIL)/EXPIRE|FAIL|RELEASE)/ Without the 'RELEASE' reason, the DHCP release message will still be sent to the server, however the local dhclient leases will not reflect the relinquishment. Therefore, DHCP renewal will do a DHCP request for the previous address rather than doing a DHCP discovery and being more likely to be assigned a different address.
Diffstat (limited to 'src/usr/local/www')
-rw-r--r--src/usr/local/www/status_interfaces.php37
1 files changed, 29 insertions, 8 deletions
diff --git a/src/usr/local/www/status_interfaces.php b/src/usr/local/www/status_interfaces.php
index ae589b9..d08add9 100644
--- a/src/usr/local/www/status_interfaces.php
+++ b/src/usr/local/www/status_interfaces.php
@@ -69,6 +69,9 @@ require_once("filter.inc");
if ($_POST['ifdescr'] && $_POST['submit']) {
$interface = $_POST['ifdescr'];
if ($_POST['status'] == "up") {
+ if ($_POST['relinquish_lease']) {
+ dhcp_relinquish_lease($_POST['if'], $_POST['ifdescr'], $_POST['ipv']);
+ }
interface_bring_down($interface);
} else {
interface_configure($interface);
@@ -85,6 +88,7 @@ $formtemplate = '<form name="%s" action="status_interfaces.php" method="post">'
'<i class="fa fa-refresh icon-embed-btn"></i>' .
'%s' .
'</button>' .
+ '%s' .
'</form>';
// Display a term/definition pair
@@ -96,17 +100,28 @@ function showDef($show, $term, $def) {
}
// Display a term/definition pair with a button
-function showDefBtn($show, $term, $def, $ifdescr, $btnlbl) {
+function showDefBtn($show, $term, $def, $ifdescr, $btnlbl, $chkbox_relinquish_lease) {
global $formtemplate;
if ($show) {
print('<dt>' . $term . '</dt>');
print('<dd>');
- printf($formtemplate, $term, $ifdescr, $show, htmlspecialchars($def) . ' ', $btnlbl, $btnlbl);
+ printf($formtemplate, $term, $ifdescr, $show, htmlspecialchars($def) . ' ', $btnlbl, $btnlbl, $chkbox_relinquish_lease);
print('</dd>');
}
}
+// Relinquish the DHCP lease from the server.
+function dhcp_relinquish_lease($if, $ifdescr, $ipv) {
+ $leases_db = '/var/db/dhclient.leases.' . $if;
+ $conf_file = '/var/etc/dhclient_'.$ifdescr.'.conf';
+ $script_file = '/sbin/dhclient-script';
+
+ if (file_exists($leases_db) && file_exists($script_file)) {
+ mwexec('/usr/local/sbin/dhclient -'.$ipv.' -d -r -lf '.$leases_db.' -cf '.$conf_file.' -sf '.$script_file);
+ }
+}
+
$pgtitle = array(gettext("Status"), gettext("Interfaces"));
$shortcut_section = "interfaces";
include("head.inc");
@@ -116,6 +131,12 @@ $ifdescrs = get_configured_interface_with_descr(false, true);
foreach ($ifdescrs as $ifdescr => $ifname):
$ifinfo = get_interface_info($ifdescr);
$mac_man = load_mac_manufacturer_table();
+
+ $chkbox_relinquish_lease = '&nbsp;&nbsp;&nbsp;' .
+ '<input type="checkbox" name="relinquish_lease" value="true" title="Send a gratuitous DHCP release packet to the server." /> ' . gettext("Relinquish Lease") .
+ '<input type="hidden" name="if" value='.$ifinfo['if'].' />';
+ $chkbox_relinquish_lease_v4 = $chkbox_relinquish_lease . '<input type="hidden" name="ipv" value=4 />';
+ $chkbox_relinquish_lease_v6 = $chkbox_relinquish_lease . '<input type="hidden" name="ipv" value=6 />';
?>
<div class="panel panel-default">
@@ -124,12 +145,12 @@ foreach ($ifdescrs as $ifdescr => $ifname):
<dl class="dl-horizontal">
<?php
showDef(true, gettext("Status"), $ifinfo['status']);
- showDefBtn($ifinfo['dhcplink'], 'DHCP', $ifinfo['dhcplink'], $ifdescr, $ifinfo['dhcplink'] == "up" ? gettext("Release") : gettext("Renew"));
- showDefBtn($ifinfo['dhcp6link'], 'DHCP6', $ifinfo['dhcp6link'], $ifdescr, $ifinfo['dhcp6link'] == "up" ? gettext("Release") : gettext("Renew"));
- showDefBtn($ifinfo['pppoelink'], 'PPPoE', $ifinfo['pppoelink'], $ifdescr, $ifinfo['pppoelink'] == "up" ? gettext("Disconnect") : gettext("Connect"));
- showDefBtn($ifinfo['pptplink'], 'PPTP', $ifinfo['pptplink'], $ifdescr, $ifinfo['pptplink'] == "up" ? gettext("Disconnect") : gettext("Connect"));
- showDefBtn($ifinfo['l2tplink'], 'L2TP', $ifinfo['l2tplink'], $ifdescr, $ifinfo['l2tplink'] == "up" ? gettext("Disconnect") : gettext("Connect"));
- showDefBtn($ifinfo['ppplink'], 'PPP', $ifinfo['ppplink'], $ifdescr, ($ifinfo['ppplink'] == "up" && !$ifinfo['nodevice']) ? gettext("Disconnect") : gettext("Connect"));
+ showDefBtn($ifinfo['dhcplink'], 'DHCP', $ifinfo['dhcplink'], $ifdescr, $ifinfo['dhcplink'] == "up" ? gettext("Release") : gettext("Renew"), $ifinfo['dhcplink'] == "up" ? $chkbox_relinquish_lease_v4 : '');
+ showDefBtn($ifinfo['dhcp6link'], 'DHCP6', $ifinfo['dhcp6link'], $ifdescr, $ifinfo['dhcp6link'] == "up" ? gettext("Release") : gettext("Renew"), $ifinfo['dhcp6link'] == "up" ? $chkbox_relinquish_lease_v6 : '');
+ showDefBtn($ifinfo['pppoelink'], 'PPPoE', $ifinfo['pppoelink'], $ifdescr, $ifinfo['pppoelink'] == "up" ? gettext("Disconnect") : gettext("Connect"), '');
+ showDefBtn($ifinfo['pptplink'], 'PPTP', $ifinfo['pptplink'], $ifdescr, $ifinfo['pptplink'] == "up" ? gettext("Disconnect") : gettext("Connect"), '');
+ showDefBtn($ifinfo['l2tplink'], 'L2TP', $ifinfo['l2tplink'], $ifdescr, $ifinfo['l2tplink'] == "up" ? gettext("Disconnect") : gettext("Connect"), '');
+ showDefBtn($ifinfo['ppplink'], 'PPP', $ifinfo['ppplink'], $ifdescr, ($ifinfo['ppplink'] == "up" && !$ifinfo['nodevice']) ? gettext("Disconnect") : gettext("Connect"), '');
showDef($ifinfo['ppp_uptime'] || $ifinfo['ppp_uptime_accumulated'], gettext("Uptime") . ' ' . ($ifinfo['ppp_uptime_accumulated'] ? '(historical)':''), $ifinfo['ppp_uptime'] . $ifinfo['ppp_uptime_accumulated']);
showDef($ifinfo['cell_rssi'], gettext("Cell Signal (RSSI)"), $ifinfo['cell_rssi']);
showDef($ifinfo['cell_mode'], gettext("Cell Mode"), $ifinfo['cell_mode']);
OpenPOWER on IntegriCloud