Skip to content

Instantly share code, notes, and snippets.

@kanazux
Last active January 11, 2018 11:09
Show Gist options
  • Save kanazux/782de109f314a32bea2509a2dd7b8a18 to your computer and use it in GitHub Desktop.
Save kanazux/782de109f314a32bea2509a2dd7b8a18 to your computer and use it in GitHub Desktop.
Export dhcp static hosts to csv file on pfSense
<?php
require_once('config.inc');
$dhcp = $config['dhcpd'];
if (!empty($dhcp)) {
foreach ($dhcp as $name => $iface) {
if (!empty($iface['staticmap'])) {
file_put_contents("/root/{$name}.csv", "mac;ip;hostname;descr\n");
foreach ($iface['staticmap'] as $static) {
file_put_contents("/root/{$name}.csv", "{$static['mac']};{$static['ipaddr']};{$static['hostname']};{$static['descr']}\n", FILE_APPEND);
}
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment