1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

support dns options in dnsmasq configuration

This commit is contained in:
Yusnel Rojas Garcia 2019-10-11 13:24:22 -04:00
parent cf69881767
commit 4d45afa27b
3 changed files with 50 additions and 4 deletions

View File

@ -1,6 +1,7 @@
# RaspAP wlan0 configuration for wired (ethernet) AP mode # RaspAP wlan0 configuration for wired (ethernet) AP mode
interface=wlan0 interface=wlan0
dhcp-range=10.3.141.50,10.3.141.255,255.255.255.0,12h dhcp-range=10.3.141.50,10.3.141.255,255.255.255.0,12h
dhcp-option=6,1.1.1.1,8.8.8.8
# RaspAP uap0 configuration for wireless client AP mode # RaspAP uap0 configuration for wireless client AP mode
#interface=lo,uap0 # Use interfaces lo and uap0 #interface=lo,uap0 # Use interfaces lo and uap0

View File

@ -55,6 +55,17 @@ function DisplayDHCPConfig()
$config .= "dhcp-host=$mac,$ip".PHP_EOL; $config .= "dhcp-host=$mac,$ip".PHP_EOL;
} }
} }
if ($_POST['DNS1']){
$config .= "dhcp-option=6," . $_POST['DNS1'];
if ($_POST['DNS2']){
$config .= ','.$_POST['DNS2'];
}
$config .= PHP_EOL;
}
file_put_contents("/tmp/dnsmasqdata", $config); file_put_contents("/tmp/dnsmasqdata", $config);
system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_CONFIG, $return); system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_CONFIG, $return);
} else { } else {
@ -110,6 +121,23 @@ function DisplayDHCPConfig()
$dhcpHost = empty($dhcpHost) ? [] : $dhcpHost; $dhcpHost = empty($dhcpHost) ? [] : $dhcpHost;
$dhcpHost = is_array($dhcpHost) ? $dhcpHost : [ $dhcpHost ]; $dhcpHost = is_array($dhcpHost) ? $dhcpHost : [ $dhcpHost ];
$DNS1 = '';
$DNS2 = '';
if (isset($conf['dhcp-option'])){
$arrDns = explode(",", $conf['dhcp-option']);
if ($arrDns[0] == '6'){
if (count($arrDns) > 1){
$DNS1 = $arrDns[1];
}
if (count($arrDns) > 2){
$DNS2 = $arrDns[2];
}
}
}
$hselected = ''; $hselected = '';
$mselected = ''; $mselected = '';
$dselected = ''; $dselected = '';
@ -139,6 +167,8 @@ function DisplayDHCPConfig()
"serviceStatus", "serviceStatus",
"RangeStart", "RangeStart",
"RangeEnd", "RangeEnd",
"DNS1",
"DNS2",
"arrRangeLeaseTime", "arrRangeLeaseTime",
"mselected", "mselected",
"hselected", "hselected",

View File

@ -63,6 +63,21 @@
</select> </select>
</div> </div>
</div> </div>
<div class="row">
<div class="form-group col-md-4">
<label for="code"><?php echo _("DNS Server 1"); ?></label>
<input type="text" class="form-control"name="DNS1" value="<?php echo htmlspecialchars($DNS1, ENT_QUOTES); ?>" />
</div>
</div>
<div class="row">
<div class="form-group col-md-4">
<label for="code"><?php echo _("DNS Server 2"); ?></label>
<input type="text" class="form-control" name="DNS2" value="<?php echo htmlspecialchars($DNS2, ENT_QUOTES); ?>" />
</div>
</div>
<?php if (!RASPI_MONITOR_ENABLED) : ?> <?php if (!RASPI_MONITOR_ENABLED) : ?>
<input type="submit" class="btn btn-outline btn-primary" value="<?php echo _("Save settings"); ?>" name="savedhcpdsettings" /> <input type="submit" class="btn btn-outline btn-primary" value="<?php echo _("Save settings"); ?>" name="savedhcpdsettings" />
<?php if ($dnsmasq_state) : ?> <?php if ($dnsmasq_state) : ?>
@ -94,11 +109,11 @@
</thead> </thead>
<tbody> <tbody>
<?php foreach ($leases as $lease) : ?> <?php foreach ($leases as $lease) : ?>
<?php foreach (explode(' ', $lease) as $prop) : ?>
<tr> <tr>
<?php foreach (explode(' ', $lease) as $prop) : ?>
<td><?php echo htmlspecialchars($prop, ENT_QUOTES) ?></td> <td><?php echo htmlspecialchars($prop, ENT_QUOTES) ?></td>
</tr>
<?php endforeach ?> <?php endforeach ?>
</tr>
<?php endforeach ?> <?php endforeach ?>
</tbody> </tbody>
</table> </table>