Thank you, very much.
I appreciate the sharing!
Have a FANTASTIC weekend.
R,
-Joe Wulf
>________________________________
> From: Reindl Harald <h.rei...@thelounge.net>
>To: Mailing-List fedora-users <users@lists.fedoraproject.org>
>Sent: Friday, November 30, 2012 1:38 PM
>Subject: Re: <Private> Re: dynamic ip ok for NFS/LDAP servers? Network Gurus?
>
>
>Am 30.11.2012 19:23, schrieb Joe Wulf:
>> Reindl,
>>
>> I was instantly thrilled to see you had a process (script?) for
>> auto-generating dhcpd.conf in concert with a DNS database.
>> Is it possible for you to share the scripts and/or documentation for how
>> you generate, implement and/or manage your
>> dns and dhcp configurations?
>>
>> I've been working a project that would greatly benefit from not having
>> to reinvent the wheel
>
>the dhcp-wheel is simple, see below, you need a db-layer
>or replace some commands to work directly with php-mysqli
>
>write your config with base-values and a placeholder
>for the generated stuff somewhere else, generate the
>new config file based on the database and write it to
>disk if it differs from the old one an restart the service
>
>the dns-wheel i can not share because it is based on inernal
>libraries and our own cms-system and hardly wired to work
>with a lot of code for other services which a do not like
>to implement more generic beause i need here admin-code
>witout comprmoises by maintain all sort of network-services
>
>
>cat /scripts/dhcp/dhcpd.conf.template
>authoritative;
>ddns-update-style none;
>ddns-updates off;
>default-lease-time 86400;
>max-lease-time 172800;
>log-facility local7;
>subnet x.x.x.0 netmask 255.255.255.0 {
>option domain-name "thelounge.net";
>option domain-name-servers x.x.x.6, x.x.x.106, x.x.x.15;
>option routers x.x.x.1;
>option smtp-server x.x.x.15;
>option pop-server x.x.x.15;
>option ntp-servers x.x.x.103, x.x.x.110;
>option time-servers x.x.x.103, x.x.x.110;
>option subnet-mask 255.255.255.0;
>option broadcast-address x.x.x.255;
>option interface-mtu 1472;
>range x.x.x.x x.x.x.x;
>}
>[static]
>_______________________________________________________________________
>
>cat /scripts/dhcp/dhcpd-entry.template
>host [entry_name] {
>hardware ethernet [entry_mac];
>fixed-address [entry_value];
>}
>_______________________________________________________________________
>
>cat /scripts/dhcp/generate.php
>#!/usr/bin/php
><?php
>require('global.inc.php');
>$db = new mysql_class();
>$db->host = '****';
>$db->user = 'dns';
>$db->pwd = '****************';
>$db->db = ''****************';';
>$db->connect();
>$conf_file_live = '/etc/dhcp/dhcpd.conf';
>$template_file = file_get_contents(dirname(__FILE__) .
>'/dhcpd.conf.template');
>$template_entry = file_get_contents(dirname(__FILE__) .
>'/dhcpd-entry.template');
>$static = '';
>$result = $db->query_fetch_all("select entry_name, entry_value, entry_mac from
>dns_intern_entrys where
>entry_type='A' and entry_zone_cleartext='thelounge.net' and entry_mac!=''
>order by entry_name;");
>foreach($result as $row)
>{
> $static .= MY_LE . str_replace
> (
> array('[entry_name]', '[entry_value]', '[entry_mac]'),
> array($row['entry_name'], $row['entry_value'],
>strtoupper($row['entry_mac'])),
> $template_entry
> );
>}
>$conf = trim(str_replace('[static]', $static, $template_file)) . MY_LE;
>if(@file_get_contents($conf_file_live) != $conf)
>{
> file_put_contents($conf_file_live, $conf);
> chmod($conf_file_live, 0644);
> $out = '';
> $temp = popen('/sbin/service dhcpd condrestart', 'r');
> while($buffer = fread($temp, 1024))
> {
> $out .= $buffer;
> }
> pclose($temp);
> echo $out . MY_LE . MY_LE . MY_LE;
> echo $conf;
>}
>?>
>
>
>--
>users mailing list
>users@lists.fedoraproject.org
>To unsubscribe or change subscription options:
>https://admin.fedoraproject.org/mailman/listinfo/users
>Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
>Have a question? Ask away: http://ask.fedoraproject.org
>
>
>
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org