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